/* style.css — UC-0102 Counting Sheep Generator retailer UI.
   Palette is the AUTHORITATIVE Serta brand palette (Serta_BrandGuidelines_
   2025.pdf p.6, already in lib/compose.py) — do not introduce any color not
   derived from these six. Type is Avenir Next/Century Gothic/Futura as a
   stand-in for GT Walsheim (Grilli Type) until Creative supplies a licensed
   webfont — swap the --font stack below when that happens, nothing else
   needs to change. Responsive is a standing SSB requirement, built in from
   the start, down to 360px. */

:root {
  --navy:      #00263E; /* PMS 2965 C — ink, primary actions, selected states */
  --sky:       #C3D4EB; /* PMS 2707 C — accents, selected fills */
  --sky-wash:  #F2F6FB; /* page ground — a tint of brand sky */
  --white:     #FFFFFF; /* cards */
  --yellow:    #FFFF00; /* secondary. Used once, tiny — the logo crescent */
  --line:      #DCE6F0; /* hairlines */

  --ink: var(--navy);
  --muted: #4C6480;
  --on-navy: #FFFFFF;

  --warn-bg: #FBF2CF;
  --warn-ink: #6B5300;
  --err-bg: #FBE3DE;
  --err-ink: #8A2A11;

  /* TODO: swap to GT Walsheim webfont when Creative supplies a licensed
     file — this is the single swap point for the whole app. */
  --font: "Avenir Next", "Century Gothic", Futura, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must always win over a class's own `display`
   rule — several controls below (rows, pills, frames) are toggled purely
   via el.hidden in app.js and would otherwise stay visible because e.g.
   `.preview-loading { display: flex }` has equal specificity to the
   browser's default `[hidden]` rule and comes later in the stylesheet. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  letter-spacing: -0.01em; /* brand spec: tracking at least -10 */
  background: var(--sky-wash);
  color: var(--ink);
}

button, input, select, textarea { font-family: inherit; letter-spacing: inherit; }

.app { max-width: 1180px; margin: 0 auto; padding: 28px 20px 56px; }

.app-header h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--navy);
}

/* The one, tiny, deliberate use of the brand yellow — a nod to the logo
   crescent. Never repeated elsewhere at this size/prominence. */
.accent-dot { color: var(--yellow); text-shadow: 0 0 0 1px rgba(0, 38, 62, 0.35); }

.app-header .subtitle { margin: 0 0 28px; color: var(--muted); font-size: 18px; }

/* ── Layout: controls (flexible, max 640px) + a sticky hero preview ──────── */

.layout {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

@media (min-width: 1000px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 640px) 460px;
    gap: 36px;
    align-items: start;
  }
}

@media (max-width: 999px) {
  .preview-pane { order: -1; } /* preview first below 1000px */
}

.controls { display: flex; flex-direction: column; gap: 22px; }

/* ── Steps — the signature element: an oversized numeral in the margin,
   echoing the knitted numerals on the sheep's flank ("1", "56"). Large,
   navy, tight tracking, low contrast against the page ground. The card
   itself stays quiet — everything else is deliberately undecorated. ────── */

.step {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 10px;
  align-items: start;
}

@media (min-width: 640px) {
  .step { grid-template-columns: 56px 1fr; gap: 16px; }
}

@media (min-width: 1000px) {
  .step { grid-template-columns: 72px 1fr; gap: 18px; }
}

.step[hidden] { display: none; }

.step-num {
  grid-column: 1;
  font-size: 32px;
  font-weight: 700;
  line-height: 1;
  color: var(--navy);
  opacity: 0.18;
  letter-spacing: -0.04em;
  text-align: right;
  padding-top: 6px;
  user-select: none;
}

@media (min-width: 640px) {
  .step-num { font-size: 48px; padding-top: 8px; }
}

@media (min-width: 1000px) {
  .step-num { font-size: 60px; padding-top: 10px; }
}

.step-body {
  grid-column: 2;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px;
  min-width: 0;
}

@media (min-width: 640px) {
  .step-body { padding: 22px 24px; }
}

.step-body h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--navy);
}

/* ── Generic pickers (pose, accessory, message) ──────────────────────────── */

.picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pick-btn {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}

.pick-btn:hover { border-color: var(--navy); }

.pick-btn[aria-checked="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--on-navy);
}

.pick-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pick-btn:disabled:hover { border-color: var(--line); }

/* the reason a card is greyed out ("Upload your logo first") */
.pick-note { font-size: 12px; color: var(--muted); }
.scene-pick-btn span.pick-note { font-size: 12px; }

.subsection { margin-top: 16px; }
.subsection:first-child { margin-top: 0; }

.sub-label {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
}

.sub-hint { font-weight: 400; color: var(--muted); }

.scene-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scene-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 112px;
  padding: 6px;
}

/* 100 px = the full inner width of the 112 px card (was 84 px): Retail Marketing asked for clearer thumbnails
   (2026-11-23), and the seasonal ones now show the whole sheep, so they need the room. */
.scene-thumb {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.scene-pick-btn span {
  font-size: 16px;
  line-height: 1.2;
  text-align: center;
}

/* Placeholder thumb for cards with no art of their own (the "None" accessory
   card) — keeps the grid visually consistent instead of a lone text button
   among a row of images. */
/* "No background" (feedback #9) tile — no AI sample to show (there is
   nothing to sample, it's a plain white studio backdrop), so a plain white
   swatch with a hairline border stands in for a thumbnail. */
.scene-thumb-plain {
  width: 100px;
  height: 100px;
  border-radius: 6px;
  display: block;
  background: var(--white);
  border: 1px solid var(--line);
}

.scene-thumb-empty {
  width: 100px;
  height: 100px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sky-wash);
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 20px;
}

/* ── Accessory colour swatches (feedback #10) — a hex pick, resolved to a
   colour WORD server-side (app/color_names.py) before it ever reaches the AI
   prompt; the swatch fill IS the hex, purely for the dealer's own picking UI,
   never sent verbatim as "the colour" the way the resolved word is. ──────── */

.color-swatch-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
  padding: 0;
}

.color-swatch:hover { border-color: var(--navy); }

.color-swatch[aria-checked="true"] {
  border-color: var(--navy);
  box-shadow: 0 0 0 2px var(--sky);
}

.scene-prompt-row textarea {
  width: 100%;
  resize: vertical;
  font-size: 16px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

.scene-prompt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.char-counter { font-size: 16px; color: var(--muted); }

.copy-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.copy-row label {
  font-size: 16px;
  color: var(--muted);
}

select, input[type="file"] {
  font-size: 16px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

.copy-row select { flex: 1 1 auto; min-width: 0; }

/* ── SVG-only logo option — hidden entirely for PNG/JPEG uploads (see
   app.js's isSvgFile() and app/svg_raster.py). ─────────────────────────── */

.logo-svg-options { margin-top: 12px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--navy);
  cursor: pointer;
}

.hint { font-size: 16px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

.note {
  font-size: 16px;
  background: var(--warn-bg);
  color: var(--warn-ink);
  padding: 7px 11px;
  border-radius: 6px;
  margin: 10px 0 0;
  line-height: 1.5;
}

.note.error { background: var(--err-bg); color: var(--err-ink); }

#step-logo input[type="file"] { display: block; width: 100%; }

.logo-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.logo-preview img {
  max-width: 80px;
  max-height: 60px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  padding: 4px;
}

.logo-preview button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 6px;
  padding: 7px 11px;
  font-size: 16px;
  cursor: pointer;
}

button.primary {
  margin-top: 16px;
  width: 100%;
  border: none;
  border-radius: 8px;
  background: var(--navy);
  color: var(--on-navy);
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

button.primary:hover { opacity: 0.92; }
button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

button.secondary {
  margin-top: 4px;
  width: 100%;
  border: 1px solid var(--navy);
  border-radius: 8px;
  background: var(--white);
  color: var(--navy);
  padding: 11px 16px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

button.secondary:hover { background: var(--navy); color: var(--on-navy); }
button.secondary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Start over — quiet, full-width under Generate; underlined text so it reads as
   a labelled reset, not a second primary action. */
button.link-btn {
  margin-top: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--navy);
  padding: 8px 16px;
  font-size: 16px;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
button.link-btn:hover { background: rgba(0, 26, 58, 0.06); }
button.link-btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
button.link-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* AI photo variation picker — MAI is stochastic, so every generation shows
   all variations side by side; the dealer downloads whichever one they
   want. Reuses .preview-loading's non-veiling pill. */
.mai-edit-frame { position: relative; margin-top: 10px; }

.mai-edit-variations {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mai-edit-variation {
  flex: 1 1 140px;
  max-width: 200px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--sky-wash);
  display: flex;
  flex-direction: column;
}

.mai-edit-variation img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.mai-edit-variation button {
  border: none;
  border-top: 1px solid var(--line);
  background: var(--white);
  color: var(--navy);
  padding: 9px 6px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.mai-edit-variation button:hover { background: var(--navy); color: var(--on-navy); }

.mai-edit-frame .preview-loading { top: 8px; right: 8px; }

/* ── "Your selections" summary (AI photo only) — occupies the right-hand
   column in place of the live preview, which this mode never generates (see
   MAI_EDIT_PREVIEW_HINT in app.js). Same step-body card language (white,
   line border, 12px radius) as the left column so it reads as one system. ── */

.mai-summary-panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
}

.mai-summary-panel h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--navy);
}

.mai-summary-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0 0 14px;
}

.mai-summary-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mai-summary-thumb {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--sky-wash);
}

.mai-summary-thumb-empty {
  border: 1px dashed var(--line);
}

.mai-summary-text { min-width: 0; }

.mai-summary-text dt {
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

.mai-summary-text dd {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  overflow-wrap: anywhere;
}

.mai-summary-panel .mai-edit-frame { margin-top: 4px; }

/* ── Right-hand column — sticky on desktop, holds "Your selections" +
   Generate + the resulting variations (see .mai-summary-panel above). ───── */

.preview-pane { position: static; }

/* Sticky only side by side: stacked (< 1000px) the panel is taller than a phone
   viewport at 16px type and would cover the controls while scrolling. */
@media (min-width: 1000px) {
  .preview-pane { position: sticky; top: 24px; }
}

/* Loading must NOT veil prior variations underneath it — a full-opacity veil
   previously made a render look washed out and drew a real complaint, so
   this stays an unobtrusive pill instead (see .mai-edit-frame). */
.preview-loading {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px 6px 10px;
  font-size: 16px;
  font-weight: 700;
  color: var(--on-navy);
  background: rgba(0, 38, 62, 0.85);
  border-radius: 999px;
  pointer-events: none;
}

.preview-loading::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .preview-loading::before { animation-duration: 2.4s; }
}

.app-footer {
  margin-top: 32px;
  font-size: 16px;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

/* ── Focus visibility — every interactive control gets a clear, consistent
   ring. Never removed, only ever restyled. ──────────────────────────────── */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

@media (max-width: 520px) {
  .app { padding: 18px 12px 40px; }
  .step-body { padding: 16px; }
  .pick-btn { flex: 1 1 auto; text-align: center; }
  .scene-pick-btn { width: calc(50% - 4px); }
  .scene-thumb, .scene-thumb-plain { width: 100%; height: 72px; }
  .scene-prompt-footer { flex-direction: column; align-items: stretch; }
  .mai-edit-variation { flex: 1 1 calc(50% - 5px); max-width: calc(50% - 5px); }
}

.serta-logo-choice { border: 0; padding: 0; margin: 14px 0 0; }
.serta-logo-choice legend { font-size: 16px; font-weight: 600; padding: 0; margin-bottom: 4px; }

/* Round 3 (2026-10-27): size steps share the Serta-logo radio group look. */
.size-choice .checkbox-row { display: inline-flex; margin-right: 16px; }

/* ── Round 4 (2026-11-03) ─────────────────────────────────────────────────── */

/* accessory groups: "Your logo on it" / "Your colour" */
.accessory-group .hint { margin: 0 0 8px; }
#accessory-picker-none { margin-bottom: 4px; }
#accessory-picker-none, #accessory-picker-logo, #accessory-picker-color { display: flex; flex-wrap: wrap; gap: 8px; }

/* logo placements + Serta logo position: stacked checkbox / radio rows, 44px-ish touch targets */
#logo-placements .checkbox-row,
#serta-logo-position-choice .checkbox-row { display: flex; padding: 5px 0; flex-wrap: wrap; }
.placement-why { color: var(--muted); }
.placement-row input:disabled + span { color: var(--muted); }
.placement-row:has(input:disabled) { cursor: not-allowed; opacity: 0.85; }
#scene-picker .pick-btn:disabled,
#scene-prompt-input:disabled { opacity: 0.5; cursor: not-allowed; }

/* email */
.email-row { margin: 0 0 14px; }
.email-row label { display: block; font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.email-row input[type="email"] {
  width: 100%;
  font-size: 16px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}
.email-row input[type="email"]:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.email-row input[aria-invalid="true"] { border-color: var(--err-ink); }
.email-row input[readonly] { background: var(--sky-wash); }

/* variation download buttons + brand-check failures */
.variation-actions { display: flex; flex-direction: column; }
.mai-edit-variation .variation-actions button { width: 100%; line-height: 1.25; }
.variation-status { font-size: 16px; margin: 0; padding: 7px 9px; background: var(--err-bg); color: var(--err-ink); }
.mai-edit-variation.failed { background: var(--white); }
.mai-edit-variation.failed img { opacity: 0.35; filter: grayscale(0.6); }
.variation-failed { font-size: 16px; margin: 0; padding: 8px 9px; background: var(--err-bg); color: var(--err-ink); line-height: 1.4; }
