/* Pip & Wick play pages (the play page and the apps). Colours come from brand.css (generated from
   brand/brand.json), loaded before this file; which colour does what: apps/BRAND_ROLES.md.
   Light by default; <html data-theme="dark"> for TV. Fraunces + Inter, self-hosted (OFL). */
@font-face {
  font-family: "Fraunces";
  src: url("/play/assets/fonts/Fraunces.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("/play/assets/fonts/Inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  /* roles, from brand.css (--bg --card --ink --primary --secondary --accent --muted --line) */
  --text: var(--ink);
  --surface: var(--card);
  --btn-bg: var(--primary);   --btn-ink: var(--on-primary);            /* light: evergreen + cream */
  --stop-bg: var(--secondary); --stop-ink: var(--on-secondary); --stop-line: var(--secondary);   /* Show answers: cranberry + cream */
  /* marks ON the photos look the same in both themes, so they use the fixed palette (--pw-*) */
  --mark: var(--pw-honey);
  --mark-outline: var(--pw-ink);
  --mark-ink: var(--pw-ink);
  --mark-answer: var(--pw-cream);
  --miss: var(--pw-cranberry);
  --gap: 12px;
  --ar: 1.7778;   /* picture width / height; the page sets it from the puzzle (4:3 crops) */
}

/* on dark (TV), buttons are card-coloured (evergreen) with cream text; brand.css's --focus / --on-focus
   (light: evergreen + cream; dark: honey + ink) light up the focused one, the same as Apple TV */
:root[data-theme="dark"] { --btn-bg: var(--card); --btn-ink: var(--ink); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, sans-serif;
  padding: 0 max(16px, env(safe-area-inset-right)) 32px max(16px, env(safe-area-inset-left));
}
a { color: var(--primary); }
a:focus-visible, button:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.top { max-width: 1600px; margin: 0 auto; padding: 20px 0 8px; }
.brand {
  font: 600 13px/1 Inter, system-ui, sans-serif; letter-spacing: .18em; text-transform: uppercase;
  color: var(--primary); text-decoration: none; display: inline-block; padding: 12px 0;
}
h1 { font: 500 clamp(26px, 4vw, 40px)/1.15 Fraunces, Georgia, serif; margin: 2px 0 4px; }
.lede { color: var(--muted); margin: 0; }

/* status + controls */
.bar {
  max-width: 1600px; margin: 12px auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  padding: 8px 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.count { font: 500 22px/1.2 Fraunces, Georgia, serif; margin: 0; }
.count span:first-child { color: var(--primary); }
.clock { margin: 0; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 4.5em; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.btn {
  min-height: 44px; min-width: 44px; padding: 10px 18px; border-radius: 999px;
  font: 600 15px/1 Inter, system-ui, sans-serif; color: var(--btn-ink); background: var(--btn-bg);
  border: 1px solid var(--btn-bg); cursor: pointer; touch-action: manipulation;
}
.btn:hover { filter: brightness(1.06); }
.btn-stop { background: var(--stop-bg); color: var(--stop-ink); border: 2px solid var(--stop-line); }
.btn:disabled { background: var(--line); border-color: var(--line); color: var(--muted); cursor: default; filter: none; }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--muted); }
.btn-quiet[aria-pressed="true"] { border-color: var(--primary); color: var(--primary); }
.sync-note { max-width: 1600px; margin: 0 auto 8px; color: var(--primary); }

/* the two pictures */
.boards {
  max-width: min(1600px, calc((100svh - 150px) * var(--ar, 1.7778) * 2 + var(--gap)));
  margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: var(--gap); position: relative;
}
@media (orientation: landscape) and (min-width: 560px), (min-width: 900px) {
  .boards { grid-template-columns: 1fr 1fr; }
}
.board { margin: 0; min-width: 0; }
.board figcaption { font: 500 18px/1 Fraunces, Georgia, serif; color: var(--muted); padding: 0 0 6px 2px; }
.frame {
  position: relative; aspect-ratio: var(--ar, 16 / 9); border-radius: 12px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  cursor: crosshair; touch-action: manipulation; -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.frame img { display: block; width: 100%; height: 100%; pointer-events: none; }
.marks { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }

/* flip mode: one picture at a time, swapped in place */
.boards[data-mode="flip"] { grid-template-columns: 1fr; max-width: min(1600px, calc((100svh - 210px) * var(--ar, 1.7778))); }
.boards[data-mode="flip"][data-show="a"] .board[data-side="b"],
.boards[data-mode="flip"][data-show="b"] .board[data-side="a"] { display: none; }
.flip-now { justify-self: center; }

/* marks */
.ring { fill: none; stroke: var(--mark); stroke-width: 3.5; vector-effect: non-scaling-stroke; }
.ring-shadow { fill: none; stroke: var(--mark-outline); stroke-opacity: .85; stroke-width: 7; vector-effect: non-scaling-stroke; }
.badge { fill: var(--mark); stroke: var(--mark-outline); stroke-width: 2; vector-effect: non-scaling-stroke; }
.badge-text { fill: var(--mark-ink); font: 700 26px Inter, system-ui, sans-serif; }
.mark.answer .ring { stroke: var(--mark-answer); stroke-dasharray: 7 5; }
.mark.answer .badge { fill: var(--mark-answer); }
.mark { animation: pop .35s ease-out; transform-box: fill-box; transform-origin: center; }
.miss path.miss-outline { stroke: var(--mark-outline); stroke-opacity: .85; stroke-width: 7; }
.miss path { stroke: var(--miss); stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke;
  animation: fade .9s ease-out forwards; }
.hint { fill: var(--mark); fill-opacity: .2; stroke: var(--mark); stroke-width: 2; vector-effect: non-scaling-stroke;
  animation: pulse 1.2s ease-in-out 3; }
.shake { animation: shake .28s ease-in-out; }

@keyframes pop { from { opacity: 0; transform: scale(1.35); } to { opacity: 1; transform: scale(1); } }
@keyframes fade { from { opacity: 1; } to { opacity: 0; } }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) {
  .mark, .shake, .hint, .miss path { animation: none; }
}

.status { max-width: 1600px; margin: 10px auto; min-height: 1.5em; color: var(--muted); }
.done {
  max-width: 1600px; margin: 8px auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px 20px;
}
.done h2 { font: 500 24px/1.2 Fraunces, Georgia, serif; margin: 0 0 8px; color: var(--primary); }
.done ol { margin: 0; padding-left: 1.4em; }
.done li { margin: 4px 0; }
.done li.missed { color: var(--muted); }
.foot { max-width: 1600px; margin: 24px auto 0; color: var(--muted); font-size: 14px; }

/* short landscape phones: keep both pictures on screen */
@media (max-height: 500px) and (orientation: landscape) {
  .top { padding-top: 4px; }
  .lede, .brand { display: none; }
  h1 { font-size: 20px; }
  .bar { margin: 4px auto; padding: 4px 0; }
  .boards { max-width: calc((100svh - 70px) * var(--ar, 1.7778) * 2 + var(--gap)); }
}

/* the puzzle list */
.list { max-width: 1100px; margin: 8px auto; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  color: var(--text); text-decoration: none;
}
.card img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.card span { display: block; padding: 12px 16px 14px; font: 500 19px/1.3 Fraunces, Georgia, serif; }
.card small { display: block; color: var(--muted); font: 14px/1.4 Inter, system-ui, sans-serif; margin-top: 2px; }
.card:hover { border-color: var(--primary); }
.list-page .top, .list-page .foot { max-width: 1100px; }

/* the puzzles hub (/play/): one section per kind of puzzle */
.list-page main { max-width: 1100px; margin: 0 auto; }
.kind { margin: 28px 0 0; }
.kind h2 { font: 500 clamp(22px, 3.4vw, 28px)/1.2 Fraunces, Georgia, serif; margin: 0 0 4px; }
.kind-lede { color: var(--muted); margin: 0 0 4px; }
.soon-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.soon-card { background: var(--surface); border: 1px dashed var(--muted); border-radius: 16px; padding: 14px 18px; }
.soon-card h3 { font: 500 19px/1.3 Fraunces, Georgia, serif; margin: 0 0 4px; }
.soon-card p { margin: 0; color: var(--muted); font-size: 15px; }
