/* Configurator only. Classes are prefixed cfg- so they never clash with website styles. */

.cfg-preview-layout {
  display: grid;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 32px;
}

/* On phones the drawing stays pinned while the controls scroll under it. */
.cfg-stage {
  position: sticky;
  top: var(--header-h);
  z-index: 1;
  margin: 0 -16px;
  padding: 12px 16px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.cfg-stage-canvas svg { display: block; width: 100%; height: auto; max-height: 52vh; }
.cfg-canvas-wrap { position: relative; }
.cfg-restart {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 6px 10px;
  font-size: 13px;
  background: var(--bg);
}

/* Steps: one section per option, separated by full-width lines. Only the open section
   shows its options; greys mark which section is active and which are still locked. */
.cfg-steps { margin: 0 -16px; border-top: 1px solid var(--line); }
.cfg-step { border-bottom: 1px solid var(--line); }
.cfg-step.is-open { background: var(--grey-1); }

.cfg-step-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  width: 100%;
  padding: 15px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}
.cfg-step-head:hover { background: var(--grey-1); color: var(--text); }
.cfg-step.is-open .cfg-step-head { background: var(--grey-2); }
.cfg-step-head:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.cfg-step-num { width: 20px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--muted); }
.cfg-step-title { font-size: 13px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.cfg-step-value { margin-left: auto; font-size: 14px; color: var(--muted); }
.cfg-step-sign { width: 14px; text-align: right; font-size: 16px; }

.cfg-step-body { padding: 14px 16px 20px 48px; }

.cfg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cfg-chip, .cfg-swatch { position: relative; }
.cfg-chip input, .cfg-swatch input { position: absolute; opacity: 0; pointer-events: none; }
.cfg-chip span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  user-select: none;
}
.cfg-chip input:checked + span { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.cfg-chip input:disabled + span { color: var(--muted); border-color: var(--line-soft); cursor: not-allowed; text-decoration: line-through; }
.cfg-chip input:focus-visible + span,
.cfg-swatch input:focus-visible + svg { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Choices under a step's main choice: embroidery motif, placement, thread; pattern and rib colours. */
.cfg-sub { margin-top: 18px; }
.cfg-sub-label { display: block; margin: 0 0 8px; font-size: 13px; }
.cfg-sub-label small { color: var(--muted); font-size: 12px; }

/* Last row: price and the button to the summary page, not a dropdown. Same height as the step titles. */
.cfg-order-row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; min-height: 50px; }
.cfg-order-price { font-size: 14px; }
.cfg-order-button {
  margin-left: auto;
  padding: 6px 14px;
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cfg-order-button:hover { background: #333333; color: var(--accent-text); }
.cfg-order-status { margin: 0; padding: 0 16px 14px 48px; font-size: 13px; color: var(--muted); }
.cfg-order-status:empty { display: none; }

/* Colour / Pattern tabs inside the colour step */
.cfg-tabs { display: flex; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.cfg-tab {
  flex: 1;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.cfg-tab:hover { background: transparent; color: var(--text); }
.cfg-tab[aria-selected="true"] { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }
.cfg-tab:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.cfg-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 8px; }
/* Solid colours: five a row, one season per row (config.js lists them in that order). */
.cfg-swatches-rows { grid-template-columns: repeat(5, minmax(36px, 48px)); }
/* Pattern and rib colours: one season per row, the same columns in every row (a row can
   have one more, e.g. cream next to optic white). */
.cfg-palette { display: grid; gap: 8px; }
.cfg-palette-row { grid-template-columns: repeat(5, minmax(36px, 48px)); }
.cfg-swatch svg {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  cursor: pointer;
}
.cfg-swatch input:checked + svg { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (min-width: 860px) {
  .cfg-preview-layout { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; padding-top: 16px; }
  .cfg-stage { top: calc(var(--header-h) + 16px); margin: 0; padding: 0; border-bottom: 0; }
  .cfg-steps { margin: 0; }
  .cfg-stage-canvas svg { max-height: calc(100vh - 120px); }
  /* The top bar's logo starts where the drawing does and its links end where the options do:
     the same width and side padding as .cfg-preview-layout. */
  .topbar { padding: 0 max(16px, calc((100% - 1200px) / 2 + 16px)); }
}
