/* Swatchle prototype: the desktop layout.
   index.html loads this file only on wide screens with a mouse:
   (min-width: 1024px) and (pointer: fine). js/game.js checks the same query.
   It restyles the elements app.css lays out for phones, so it has to load after it.
   Values come from the Paper "Desktop screens" page (1440 x 900 artboards)
   unless a comment says otherwise. */

.for-touch { display: none; }
.for-mouse { display: inline; }

.app {
  --app-w: 100vw;
  --header-h: 72px;
  --page-margin: var(--spacing-8);
  /* The round's two columns. Board 110 at full size: 400 side panel + 64 gap + 708 board = 1172.
     Not in Paper: on a smaller window the board shrinks to fit the height, then
     the side panel and the gap give up width. */
  --fit-w: calc(100vw - 2 * var(--page-margin));
  --col-gap: clamp(var(--spacing-10), 4.444vw, var(--spacing-16));
  --board-w: max(420px, min(708px, (100dvh - var(--header-h) - 2 * var(--spacing-6)) * 708 / 636, var(--fit-w) - var(--col-gap) - 320px));
  --board-h: calc(var(--board-w) * 636 / 708);
  --side-w: min(400px, var(--fit-w) - var(--col-gap) - var(--board-w));
  --content-w: calc(var(--side-w) + var(--col-gap) + var(--board-w));
}
.bottom { padding: 0; }
.key-hint {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--text-label);
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.btn-sm { height: 40px; padding-inline: var(--spacing-5); font-size: var(--text-body); line-height: 20px; }
@media (hover: hover) {
  /* Hover states are not drawn in Paper. */
  .btn-primary:hover:not(:disabled) { filter: brightness(1.04); }
  .btn-secondary:hover, .icon-btn:hover:not(:disabled) { background: var(--color-bg); }
}

/* ---------- 1 · Home ---------- */
.home { justify-content: center; }
.home-hero { position: static; flex: none; gap: var(--spacing-10); padding-inline: 0; }   /* static: the stickers are placed on the whole screen */
.logo-hero { width: 447px; height: 123px; background-position: -31px -18px; background-size: 511px; rotate: -2deg; }
.pitch { padding-top: 0; }
.tagline { font-size: var(--text-title); }
.tagline-sub { font-size: var(--text-button); }
.home-actions { padding: var(--spacing-16) 0 0; }
.home .btn-xl { width: 358px; }
/* Pinned to the bottom of the window, so the hero and buttons stay centered. */
.home-foot { position: absolute; inset: auto 0 var(--spacing-4); padding-bottom: 0; }

/* Loose swatch stickers, on either side of the hero. Placed as a share of the
   1440 x 900 artboard so they drift in with the window. */
.home-stickers { --k: 1; display: block; inset: 0; }
.home-sticker { border-width: var(--spacing-sticker-border); opacity: 1; }
.home-sticker:nth-child(1) { --size: 120px; left: 11.667%; top: 16.667%; rotate: -8deg; border-radius: var(--radius-xl); }
.home-sticker:nth-child(2) { display: block; --size: 72px; left: 6.667%; top: 47.778%; rotate: 9deg; border-radius: var(--radius-lg); }
.home-sticker:nth-child(3) { --size: 96px; left: 17.361%; top: 67.778%; rotate: 5deg; border-radius: var(--radius-xl); }
.home-sticker:nth-child(4) { --size: 88px; left: 78.472%; top: 13.333%; rotate: 7deg; border-radius: var(--radius-lg); }
.home-sticker:nth-child(5) { --size: 136px; left: 82.639%; top: 43.333%; rotate: -6deg; border-radius: var(--radius-xl); }
.home-sticker:nth-child(6) { display: block; --size: 76px; left: 74.306%; top: 75.556%; rotate: -10deg; border-radius: var(--radius-lg); }

/* ---------- 2 · How to play: a modal over a scrim ---------- */
.howto {
  align-items: center;
  justify-content: center;
  padding: var(--spacing-6);
  background: var(--color-overlay);
  animation: fade-in 160ms linear both;
}
.howto-card {
  position: relative;
  flex: none;
  gap: var(--spacing-8);
  width: 560px;
  max-height: 100%;
  overflow-y: auto;
  padding: var(--spacing-12) 56px;
  border-radius: var(--radius-xl);
  background: var(--color-surface);
  box-shadow: var(--shadow-raised);
  animation: screen-in 220ms var(--ease-out) both;
}
.howto-top { position: absolute; right: var(--spacing-5); top: var(--spacing-5); padding: 0; }
.howto-body { flex: none; overflow: visible; gap: var(--spacing-8); padding: 0; }
.howto-title { line-height: 44px; }
.steps { gap: var(--spacing-6); max-width: none; }
.step-num { width: 36px; }
.score-demo { --num-w: 36px; gap: var(--spacing-3); margin-top: var(--spacing-8); }
.demo-arrow { width: 56px; height: 32px; }
.score-scale { --num-w: 36px; gap: var(--spacing-2); margin-top: var(--spacing-6); }
.steps .scale-hint { --num-w: 36px; margin-top: var(--spacing-1); }

/* ---------- Game header ---------- */
.game-header { align-self: center; width: var(--content-w); height: var(--header-h); padding-inline: 0; }
.logo { width: 174px; height: 38px; background-position: -6.6px -10.2px; background-size: 188px; }
.header-tools { gap: var(--spacing-8); }
.game-header .header-how { display: inline-flex; }

/* ---------- 2b · Loading ---------- */
.load-stage { padding-bottom: var(--header-h); }
.load-ring { --chip: 92px; --r: 128px; }
.load-swatch { border-width: var(--spacing-sticker-border); font-size: var(--text-stamp); }
.load-swatch::after { inset: calc(-1 * var(--spacing-sticker-border) - 1px); }
.load-date { font-size: var(--text-stamp); line-height: 48px; }

/* ---------- 3 · Clue ---------- */
.clue, .done { overflow-y: auto; }   /* a very short window scrolls rather than clipping the button */
.clue-stage { flex: none; margin-top: auto; padding-inline: 0; }
.clue-card-wrap { width: 640px; max-width: var(--fit-w); padding-top: 0; }
.clue-kicker { margin-bottom: 64px; }   /* the bigger badge pokes 45px above the card */
.clue-card {
  padding: 56px var(--spacing-12) var(--spacing-12);
  border: var(--spacing-sticker-border) solid var(--color-surface);
  font-size: 52px;
  line-height: 60px;
}
.clue-card.is-long { font-size: 44px; line-height: 52px; }   /* not in Paper: the artboard shows a short clue */
/* Paper turns the badges from their top-left corner. Here they turn (and pop in)
   from the center, so each offset is nudged to land in the same spot. */
.clue-stage .round-badge { left: calc(50% - 51px); top: -45px; width: 92px; height: 92px; margin-left: 0; }
.clue-stage .round-badge-num { font-size: var(--text-stamp); line-height: 40px; }
.clue .bottom { margin-bottom: auto; padding: var(--spacing-16) 0 var(--spacing-12); }
.clue .hint { font-size: var(--text-body-lg); line-height: 24px; }
.clue .btn-primary { width: 358px; }

/* ---------- 4 to 6 · Round: the side panel beside the board ---------- */
.round {
  display: grid;
  grid-template-columns: var(--side-w) var(--board-w);
  grid-template-rows: var(--header-h) minmax(0, 1fr);
  column-gap: var(--col-gap);
  justify-content: center;
  align-items: center;
  padding-bottom: var(--spacing-6);
  overflow-y: auto;   /* a very short window scrolls rather than clipping the lock button */
}
.round .game-header { grid-column: 1 / -1; align-self: stretch; width: auto; }
.side { display: flex; flex-direction: column; height: var(--board-h); }
.clue-compact, .pick-row, .side > .bottom, .play { order: 0; }   /* the panel stacks in source order */
.play { display: block; padding: 0; }

.clue-compact { position: relative; padding: 0; }
.clue-note {
  padding: 30px 28px;
  border-width: var(--spacing-sticker-border);
  border-radius: var(--radius-xl);
  font-size: 32px;
  letter-spacing: -0.01em;
  line-height: 38px;
}
.clue-note.is-long { font-size: 26px; line-height: 32px; }   /* not in Paper: the artboard shows a short clue */
.clue-compact .round-badge {
  display: flex;
  left: auto;
  right: -14px;
  top: -19px;
  width: 64px;
  height: 64px;
  margin: 0;
  border-width: 4px;
  animation: none;
}
.clue-compact .round-badge-num { font-size: 26px; line-height: 26px; }

/* Your pick: an empty dashed slot until a swatch is clicked */
.pick-row {
  flex: 1;
  min-height: 0;
  gap: var(--spacing-6);
  height: auto;
  margin: 0;
  padding: 0;
  visibility: visible;
}
.pick-row .swatch-sticker {
  width: 144px;
  height: 144px;
  border-width: 6px;
  border-radius: 30px;
  box-shadow: var(--shadow-raised);
  rotate: -5deg;
}
.pick-row:not(.has-pick) .swatch-sticker {
  border: 2.5px dashed var(--color-pip-empty);
  background: none;
  box-shadow: none;
}
.pick-meta { width: 150px; }
.pick-label { font-size: var(--text-body-lg); line-height: 24px; }
.pick-hex { font-size: var(--text-body); line-height: 22px; }
.pick-help { display: block; color: var(--color-text-muted); font-size: var(--text-body); line-height: 22px; }
.pick-row.has-pick .pick-help, .pick-row:not(.has-pick) .pick-hex { display: none; }
.side > .bottom { gap: var(--spacing-4); margin: 0; }

/* The board: all 110 swatches in view on a white sheet, big enough to click.
   js/lens.js fits the swatches to the sheet (56px at full size). */
.lens {
  flex: none;
  width: var(--board-w);
  height: var(--board-h);
  max-height: none;
  border-radius: var(--radius-lg);
  overflow: visible;   /* the hovered swatch's shadow may spill past the sheet */
}
/* Arrow keys work wherever the focus is and the picked swatch wears its own ring,
   so the sheet doesn't need a focus outline as well. */
.lens:focus-visible { outline: none; }
.lens .chip { cursor: pointer; }
.lens .field.is-revealed .chip { cursor: default; }
.lens .chip.is-selected {
  --tilt: -4deg;
  --ring: 0 0 0 3px var(--color-surface), 0 0 0 6px var(--color-selection);
  --lift: var(--shadow-lifted);
}
.lens .field:not(.is-revealed) .chip.is-selected::after { width: 18px; height: 18px; margin: -10px 0 0 -9px; }
/* Hover zoom: the swatch under the cursor grows to 84px so its color can be judged.
   It is scaled, so the ring and shadow are divided by --zoom to land at their drawn sizes. */
@media (hover: hover) {
  .lens:hover .field:not(.is-revealed) .chip {
    transition: transform 140ms var(--ease-out), box-shadow 140ms var(--ease-out), opacity 240ms linear;
  }
  .lens .field:not(.is-revealed) .chip:hover:not(.is-selected) {
    z-index: 5;
    --scale: var(--zoom, 1);
    --ring: 0 0 0 calc(4px / var(--zoom, 1)) var(--color-surface), 0 0 0 0 transparent;
    --lift: 0 calc(14px / var(--zoom, 1)) calc(28px / var(--zoom, 1)) rgb(0 0 0 / 22%), 0 calc(2px / var(--zoom, 1)) calc(4px / var(--zoom, 1)) rgb(0 0 0 / 12%);
  }
}

/* ---------- 7 · Round: reveal ----------
   The board stays put and becomes the score map. The result takes the pick's
   place in the side panel instead of sliding up as a sheet. */
.lens .field.is-revealed .chip[data-pts]::before { font-size: calc(var(--s) * 0.43); line-height: 1.1; }   /* 24px on a 56px chip */
.lens .field.is-revealed .chip.is-target { --halo: 5px; outline-width: 2px; }
.result-sheet,
.round.is-reveal .result-sheet {
  position: static;
  z-index: auto;
  flex: 1;
  min-height: 0;
  gap: 0;
  padding: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  visibility: visible;
  translate: none;
  transition: none;
}
.result-sheet { display: none; }
.round.is-reveal .result-sheet { display: flex; animation: fade-in 200ms linear both; }
.stamp-row { align-items: flex-start; justify-content: center; gap: var(--spacing-5); width: auto; height: auto; margin-top: auto; padding: 0; }
.stamp { display: flex; flex-direction: column; align-items: center; gap: var(--spacing-4); padding-top: var(--spacing-3); }
.stamp .swatch-sticker { width: 88px; height: 88px; border-width: var(--spacing-sticker-border); border-radius: 24px; rotate: -8deg; }
.stamp .swatch-sticker.tilt-right { rotate: 8deg; }
.stamp-label { display: block; color: var(--color-text-muted); font-size: var(--text-label); font-weight: 800; line-height: 18px; }
.round.is-reveal .score-sticker { animation-delay: 200ms; }   /* no sheet to wait for */
.result-copy { gap: var(--spacing-1); max-width: none; margin: var(--spacing-6) 0 auto; }
.result-copy h2 { font-size: 24px; line-height: 30px; }
.result-copy p { line-height: 22px; }
.result-sheet .key-hint { margin-top: var(--spacing-4); }

/* ---------- Day complete ----------
   The mobile screen (artboard 12) in a centered column under the desktop header.
   Paper's desktop artboard 8 was drawn from these rules, not the other way round. */
.done-body { flex: none; overflow: visible; align-self: center; width: min(var(--container-app), var(--fit-w)); margin-top: auto; padding-top: var(--spacing-4); }
.done .bottom { margin-bottom: auto; padding: var(--spacing-6) 0 var(--spacing-12); }
.done .btn-primary { width: 358px; }

/* ---------- Short windows (not in Paper) ----------
   A laptop window can be well under the artboard's 900px. The board has already
   shrunk to fit, so trim the side panel to match. */
@media (max-height: 800px) {
  .clue-note { padding: 22px var(--spacing-6); font-size: 26px; line-height: 32px; }
  .clue-note.is-long { font-size: var(--text-clue); line-height: 28px; }
  .pick-row .swatch-sticker { width: 112px; height: 112px; border-radius: var(--radius-xl); }
  .stamp .swatch-sticker { width: 72px; height: 72px; border-radius: var(--radius-lg); }
  .score-sticker { width: 104px; height: 104px; }
  .score-sticker .badge { --size: 104px !important; }   /* js/game.js sets 124px inline */
  .result-copy { margin-top: var(--spacing-4); }
  .clue-card { padding: var(--spacing-10) var(--spacing-10) var(--spacing-8); font-size: 44px; line-height: 52px; }
  .clue-card.is-long { font-size: 36px; line-height: 44px; }
  .clue .bottom { padding-top: var(--spacing-10); }
}

@media (prefers-reduced-motion: reduce) {
  .howto-card, .round.is-reveal .result-sheet { animation: fade-in 150ms linear both; }
  .lens:hover .field:not(.is-revealed) .chip { transition: opacity 150ms linear; }
}
