/* Composition: the gallery wall the game is played on. Colours are the app's (Shared/Colours.swift, Painting.swift).
   Every size comes from two scales. Space: 4 8 12 16 24 32 48 64 96 128 192. Type: 12 14 16 18 20 24 30 36 48 60. */

@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Newsreader";
  src: url("/assets/fonts/newsreader-italic.woff2") format("woff2");
  font-style: italic;
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --wall: #ECEAE5;
  --ink: #171615;
  --quiet: #5C5853;          /* secondary text: 5.9:1 on the wall */
  --hairline: rgba(23, 22, 21, 0.14);
  --linen: #D7D0C2;
  --blue: #1F3D8B;
  --hung: 0 1px 2px rgba(23, 22, 21, 0.14), 0 12px 32px -8px rgba(23, 22, 21, 0.24);
  --serif: "Newsreader", ui-serif, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --gutter: 24px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wall: #171615;
    --ink: #EDE9E1;
    --quiet: #A6A097;          /* 7.4:1 on the dark wall */
    --hairline: rgba(237, 233, 225, 0.16);
    --hung: 0 1px 2px rgba(0, 0, 0, 0.5), 0 16px 40px -8px rgba(0, 0, 0, 0.7);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
p { margin: 0; }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; }
.board {
  position: relative;
  width: var(--board-w);
  aspect-ratio: 32 / 52;
  background: var(--linen);
  box-shadow: var(--hung);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.board.finished { touch-action: auto; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* The placard under the canvas, as in the app: the painting's name on the left, how it's going on the right. */
.placard { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; }
.placard-title { font: 600 20px/1.2 var(--serif); }
.placard-title i { display: block; margin-top: 4px; font-weight: 400; font-size: 18px; }
.placard-line { margin-top: 4px; font-size: 14px; line-height: 1.4; color: var(--quiet); text-wrap: balance; }
.placard-marks { display: flex; align-items: center; gap: 12px; flex: none; }

/* Spare lines, one stroke each: a lost one is broken. The game's mark for a line you can lose. */
.spare { display: flex; gap: 4px; height: 24px; }
.spare i { display: block; width: 4px; height: 100%; border-radius: 2px; background: var(--ink); }
.spare i.lost { background: linear-gradient(var(--ink) 0 36%, transparent 36% 64%, var(--ink) 64%); opacity: 0.4; }

.ring { width: 40px; height: 40px; }
.ring circle { fill: none; stroke-width: 3; }
.ring-track { stroke: var(--hairline); }
.ring-fill { stroke: var(--ink); stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; transition: stroke-dasharray 0.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ring-number { font: 600 12px var(--sans); fill: var(--ink); text-anchor: middle; dominant-baseline: central; font-variant-numeric: tabular-nums; }

/* After a round: what to do with this painting, then, set apart, what the app adds. */
.next p { font-size: 16px; line-height: 1.5; text-wrap: pretty; }
@keyframes arrive { from { opacity: 0; transform: translateY(8px); } }

/* Quiet actions: words with a mark, the way the app's toolbar reads. The touch target is 44 px tall. */
.action {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.action svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.action:active { opacity: 0.6; }

/* MARK: The daily board */

/* The clock, as in the app: grey until the first line starts it. */
.clock { font: 600 20px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.clock.idle { color: var(--quiet); }

/* After a round: the race's words, large like the app's finish, then the quiet detail. */
.result { display: grid; gap: 4px; margin-top: -8px; }
.result-big { font: 500 30px/1.1 var(--serif); letter-spacing: -0.01em; text-wrap: balance; }
.result-small { font-size: 16px; color: var(--quiet); font-variant-numeric: tabular-nums; }

/* Today's tries as small blank canvases, in the canvas's own proportions: a fresh one is linen, a spent one its outline. */
.tries { display: inline-flex; gap: 4px; }
.tries i { display: block; width: 8px; height: 13px; border: 1.2px solid var(--ink); opacity: 0.35; }
.tries i.left { background: var(--linen); opacity: 1; }
a.action { text-decoration: none; }
.next-board { margin-top: -16px; font-size: 16px; color: var(--quiet); font-variant-numeric: tabular-nums; }



.hung { margin: 0; display: grid; gap: 16px; width: min(256px, 72vw); }
.still { display: block; width: 100%; aspect-ratio: 32 / 52; background: var(--linen); box-shadow: var(--hung); }
.label { display: grid; gap: 4px; }

/* MARK: The board page, arriving from a shared link (P8)
   A dare link opens the board held still, the shared run as a person with a time (replayed before it can be raced),
   one primary action, and the App Store only once there's a result. On a phone everything is one column the canvas's
   width; on a computer the words sit beside the work. Sizes from the two scales above; the rival's face takes the
   canvas's own blue and white. */

:root { --rival: #1F3D8B; --on-rival: #F4F1EA; --sheet: #F7F6F2; }
@media (prefers-color-scheme: dark) { :root { --rival: #4064B9; --sheet: #23211F; } }

/* A rival: their face. Game Center gives a photo in the app; a link gives only a name, so the face is its initial,
   in the canvas's blue. One shape, one meaning: a circle with a letter is always the person whose run it is. */
.face {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--rival);
  color: var(--on-rival);
  font: 600 12px/1 var(--sans);
  user-select: none;
  -webkit-user-select: none;
}
.face:empty { background: none; box-shadow: inset 0 0 0 1.5px var(--rival); }

/* Beside a time, as the app draws them: a round check when the run plays back to its time, in ink; a round cross when
   it doesn't, in the quiet colour; a small turning mark while it's being checked. The check means only that: never
   chosen, done or hung. 15 beside a 20 time, 4 after it. */
.mark { display: inline-block; flex: none; width: 15px; height: 15px; transform: translateY(-1px); }
.mark-none { display: none; }
/* The app's checkmark.circle.fill and xmark.circle.fill, as masks so they take the text colour. A fresh check arrives
   with a small spring. */
.mark-checked, .mark-broken { background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.mark-checked { --m: url("/assets/img/checkmark.circle.fill.png"); }
.mark-broken { --m: url("/assets/img/xmark.circle.fill.png"); color: var(--quiet); }
.mark.draw { animation: mark-in 0.35s cubic-bezier(0.3, 1.5, 0.5, 1) both; }
@keyframes mark-in { from { transform: translateY(-1px) scale(0.4); opacity: 0; } to { transform: translateY(-1px) scale(1); opacity: 1; } }
.mark-checking { border-radius: 50%; border: 2px solid var(--hairline); border-top-color: currentColor; animation: turn 1s linear infinite; }
@keyframes turn { to { transform: rotate(1turn); } }

/* While the board is held, the dots' headings, drawn over the live canvas and never in the way of a finger. */
.board .board-wakes { pointer-events: none; }

/* The shared run: a person, then their time */

.sender {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}
.sender .face { width: 32px; height: 32px; font-size: 16px; }
/* "Shared run" stays on the name's line while it fits, and drops to the next line, whole, when the name is long: the
   row wraps rather than squeezing; a name too long for a line on its own is cut with an ellipsis. */
.sender-name { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; min-width: 0; }
.sender-name .name { min-width: 0; font-size: 16px; font-weight: 600; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* "Shared run": the badge the app puts on a received run (a pill is a badge), caption weight 500 in the quiet colour,
   with a hairline. It sits with the person who shared it, not on the board's heading. */
.sender-label {
  justify-self: start;
  align-self: center;
  padding: 4px 7px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--quiet) 45%, transparent);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  color: var(--quiet);
  white-space: nowrap;
}
.sender-name .name:empty { display: none; }
.sender-time {
  display: flex;
  align-items: center;
  gap: 4px;
  font: 600 20px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
/* A run that couldn't be checked keeps its name and its time, quietly; it's never raced. */
.sender.unchecked .sender-time { color: var(--quiet); font-weight: 500; }

/* Arriving on a dare */

.invite { display: grid; gap: 16px; }
.invite-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; }

/* The page's one primary action, as a capsule in ink. Everything else stays a quiet action. */
.action-primary {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 24px;
  border: 0;
  border-radius: 3px;   /* square, with corners just softened: a frame's edge, not a pill */
  background: var(--ink);
  color: var(--wall);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s;
}
.action-primary svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.action-primary .tries i { border-color: var(--wall); }
.action-primary:active { opacity: 0.6; }
.action-primary:disabled { opacity: 0.4; cursor: default; }
@media (hover: hover) { .action-primary:not(:disabled):hover { opacity: 0.8; } }

/* The time to beat, under the clock: the app's RivalChip (Marks.swift), their face and their time. */

.rival {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rival .face { margin-right: 4px; }
.rival .mark { width: 11px; height: 11px; color: var(--ink); }
/* An interrupted try isn't racing them any more: their time is struck, the tick goes. */
.rival.void .time { text-decoration: line-through; text-decoration-thickness: 1.5px; }
.rival.void .mark { display: none; }
.rival.void .face { opacity: 0.4; }

/* After a hidden tab mid-try: the clock goes quiet for the rest of the try, beside the words "Not ranked after a pause". */

.clock.unranked { color: var(--quiet); }

/* After a round */

.daily .after { gap: 24px; }
/* Finished: the time stands level with the title, however many lines the painting's name takes. */
.daily .board.finished ~ .placard { align-items: flex-start; }
/* The painting's name never leaves a word alone on its last line. */
.daily .placard-title i { text-wrap: balance; }
.daily .after-actions { margin-top: 0; gap: 4px 24px; align-items: center; }
.daily .next { margin-top: 24px; }
.daily .next-board { margin-top: -8px; }

/* The record book's line, keyed by the tick it explains. */
.record-line { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; font-size: 14px; line-height: 1.4; color: var(--quiet); text-wrap: balance; }
.record-line .mark { width: 14px; height: 14px; color: var(--ink); transform: translateY(2px); }

/* The App Store waits for a result. */
.board-page:not(.has-result) .top .badge { display: none; }
.daily .next .get-wide { display: none; }

/* Your painting beside theirs, when a shared run arrives after your tries are spent */

.diptych { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; width: var(--board-w); }
.hero-play:has(> .diptych:not([hidden])) { width: auto; }
.diptych figure { margin: 0; display: grid; gap: 12px; align-content: start; }
.diptych .still { display: block; width: 100%; aspect-ratio: 32 / 52; background: var(--linen); box-shadow: var(--hung); }
.hung-label { display: grid; gap: 4px; }
.hung-time { display: flex; align-items: center; gap: 4px; font: 600 20px/1.2 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.hung-who { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 16px; line-height: 1.25; min-width: 0; }
.hung-who .name { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Their painting, opened: a sheet from the bottom on a phone, a card on a computer (as the language menu) */

.painting-sheet {
  width: 320px;
  max-width: calc(100vw - 32px);
  max-height: calc(100svh - 32px);
  margin: auto;
  padding: 32px;
  border: 0;
  border-radius: 16px;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--hung);
  overflow: auto;
  overscroll-behavior: contain;
}
.painting-sheet[open] { display: grid; justify-items: start; gap: 16px; }
.painting-sheet::backdrop { background: rgba(23, 22, 21, 0.32); }
.painting-sheet .still { display: block; width: 224px; aspect-ratio: 32 / 52; background: var(--linen); box-shadow: var(--hung); justify-self: center; margin-bottom: 8px; }
.painting-sheet .label { width: 100%; }
.painting-sheet .sender { width: 100%; }
.painting-sheet .action-primary { width: 100%; margin-top: 8px; }
.sheet-close {
  appearance: none;
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: none;
  color: var(--quiet);
  cursor: pointer;
}
.sheet-close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }
.sheet-close:hover { background: var(--hairline); }

@media (max-width: 599px) {
  .painting-sheet {
    inset: auto 0 0 0;
    width: auto;
    max-width: none;
    max-height: 92svh;
    margin: 0;
    padding: 24px 24px max(24px, env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(23, 22, 21, 0.18);
  }
}
