/* Quorble client: page layout only.
   Every component rule comes from design/components.css (served under /design/), the sketch look from
   design/theme-sketch.css. This file turns the wireframe's phone frame into the page itself: one screen
   at a time, the 480px measure centred, no frame border, the primary button pushed to the bottom. */

body { padding: 0; }
.app { max-width: var(--measure); margin: 0 auto; }

/* The screen is the wireframe .frame with its chrome removed: the page already is the paper. */
.app .frame { --frame-border: 0 solid transparent; --frame-radius: 0; --frame-shadow: none;
              --frame-bg: transparent; --frame-bg-image: none; --frame-bg-size: auto;
              width: 100%; }

/* [hidden] must beat the components' own display values (.frame, .look, .btn). */
.app [hidden] { display: none !important; }

/* One red line that is not under a field: a server refusal of the whole action. Same size and colour as a field's error line. */
.app .error-line { color: var(--color-danger); font-size: var(--text-sm); margin: 0; text-align: center; }
html[data-theme="sketch"] .app .error-line { color: var(--sk-danger); font-size: 16px; }

/* The quiet switch between Create and Join sits under the primary button. */
.app .btn.switch { align-self: center; }

/* A player whose connection dropped keeps their seat and look, dimmed. */
.app .player.away { opacity: .45; }

/* The native colour input shows the current colour; a label of one emoji reads at the entry size as it does on the dot. */
.app .look .input.entry { max-width: 12em; }

/* Settings: a gear in the top right corner, drawn like the pencil badge (white hairline circle, ink icon), which opens the
   settings menu directly under it: the design pages' Serious / Sketch switch (.theme-switch, from components.css) and, in a
   room, Leave as a secondary button under it, as wide as the switch. On the in-room screens the gear and the menu move into
   the room bar (app.js), as its last item, so the gear never sits on top of the bar. */
.settings { --settings-size: var(--space-7); --settings-icon: var(--space-5); --settings-bg: var(--color-surface);
            --settings-border: var(--border) solid var(--color-line); --settings-ink: var(--color-ink-2); --settings-shadow: none;
            position: fixed; right: var(--space-3); top: var(--space-3); z-index: 2; width: var(--settings-size); height: var(--settings-size);
            border-radius: 50%; padding: 0; display: grid; place-items: center; cursor: pointer;
            background: var(--settings-bg); border: var(--settings-border); color: var(--settings-ink); box-shadow: var(--settings-shadow); }
.settings svg { width: var(--settings-icon); height: var(--settings-icon); display: block; }
.settings:focus-visible { outline: var(--border-focus) solid var(--color-focus); outline-offset: calc(-1 * var(--border-focus)); }
.settings[aria-expanded="true"] { color: var(--color-ink); }
html[data-theme="sketch"] .settings { --settings-bg: var(--sk-surface); --settings-border: 2px solid var(--sk-line); --settings-ink: var(--sk-ink); --settings-shadow: var(--sk-shadow); }
/* The menu is one panel: the page's surface, a hairline and the radius in Serious; the sketch card (ink outline, wobble,
   offset shadow) in Sketch. */
.settings-menu { --menu-bg: var(--color-surface); --menu-border: var(--border) solid var(--color-line); --menu-radius: var(--radius);
                 --menu-shadow: 0 var(--space-2) var(--space-6) color-mix(in srgb, var(--color-ink) 22%, transparent);
                 position: fixed; right: var(--space-3); top: calc(var(--space-3) + var(--space-7) + var(--space-2)); z-index: 3;
                 display: flex; flex-direction: column; align-items: stretch; gap: var(--space-2); padding: var(--space-3);
                 background: var(--menu-bg); border: var(--menu-border); border-radius: var(--menu-radius); box-shadow: var(--menu-shadow); }
html[data-theme="sketch"] .settings-menu { --menu-bg: var(--sk-surface); --menu-border: 2px solid var(--sk-line); --menu-radius: var(--sk-wobble-2);
                                           --menu-shadow: var(--sk-shadow); }
/* The scrim behind an open menu: the page dimmed in ink, darker towards the edges (a vignette), so the menu and the gear are
   what is lit. It covers everything else, the room bar included, and a tap on it closes the menu. */
.settings-scrim { --scrim-centre: color-mix(in srgb, var(--color-ink) 35%, transparent); --scrim-edge: color-mix(in srgb, var(--color-ink) 88%, transparent);
                  position: fixed; inset: 0; z-index: 1;
                  background: radial-gradient(ellipse 120% 90% at 50% 40%, var(--scrim-centre) 0%, var(--scrim-centre) 25%, var(--scrim-edge) 100%); }
html[data-theme="sketch"] .settings-scrim { --scrim-centre: color-mix(in srgb, var(--sk-ink) 32%, transparent); --scrim-edge: color-mix(in srgb, var(--sk-ink) 85%, transparent); }
.settings-scrim[hidden] { display: none !important; }
/* In the bar the gear is in the flow: no corner offsets (they would shift it onto the name). */
.roombar .settings { position: relative; inset: auto; z-index: 2; }
.settings-menu[hidden], .settings-menu [hidden] { display: none !important; }
.settings-menu .theme-switch { position: static; }
.settings-menu .btn.leave { width: 100%; }
.roombar .settings-wrap { position: relative; z-index: 1; flex: none; }
.roombar .settings-menu { position: absolute; top: calc(100% + var(--space-2)); right: 0; }
/* The create and join headings keep clear of the gear in the corner. */
.app .frame > h1 { padding-right: calc(var(--space-7) + var(--space-3)); }

/* In a room the bar (and the Leave confirm under it) stays at the top while the screen scrolls, and the screen fills the
   rest of the viewport, so a screen's bottom button stays in thumb reach. */
.app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.app .roomtop { position: sticky; top: 0; z-index: 2; }
.app .frame { min-height: 0; flex: 1; }

/* The top line of a play screen: the next line and the goal share it, and wrap onto two lines rather than squeeze. */
.app .frame .top { flex-wrap: wrap; gap: var(--space-1) var(--space-3); }
/* Room name on Create a room: the five names wrap as a choice (three a row) with solid borders, the chosen one marked by
   the highlight alone; Generate new names is the sixth box, dashed, so it reads as the action at the end of the list. */
.app #create-room-choice .btn.more-names { border-style: dashed; white-space: normal; line-height: 1.1; text-align: center; }   /* Generate new names may take two lines */
html[data-theme="sketch"] .app #create-room-choice .btn[aria-pressed] { --btn-border: 2px solid var(--sk-line); --btn-transform: none; }
html[data-theme="sketch"] .app #create-room-choice .btn.more-names { --btn-border: 2px dashed var(--sk-line); color: var(--sk-ink-2); }


/* Checkboxes (Keep score on Create a room, Allow spoilers in the locked lobby): a box and its label on one row, the whole row
   the tap target, and for Keep score a grey line under it saying what it means. The box is drawn here at a thumb's
   size, filled with the primary's colour (ink in Sketch) with a white tick when ticked. */
.app .check { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control); cursor: pointer;
              font-size: var(--text-md); color: var(--color-ink); }
.app .check input { --check-size: 26px; --check-bg: var(--color-surface); --check-border: 2px solid var(--color-ink-2);
                    --check-radius: calc(var(--radius) / 2); --check-on-bg: var(--color-coop); --check-on-border: var(--color-coop);
                    width: var(--check-size); height: var(--check-size); margin: 0; flex: none; cursor: pointer;
                    background: var(--check-bg); border: var(--check-border); border-radius: var(--check-radius);
                    background-position: center; background-repeat: no-repeat; background-size: 80%; }
/* components.css resets every input's appearance, so the box and its tick are drawn here: the tick is white on the fill. */
.app .check input:checked { background-color: var(--check-on-bg); border-color: var(--check-on-border);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4 10.5l4.2 4.2L16 6' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.app .check input:focus-visible { outline: var(--border-focus) solid var(--color-focus); outline-offset: 2px; }
.app .check input:disabled { border-style: dashed; cursor: default; }
.app .check input:disabled + span { color: var(--color-ink-2); }
html[data-theme="sketch"] .app .check { font-size: 19px; color: var(--sk-ink); }
html[data-theme="sketch"] .app .check input { --check-bg: var(--sk-surface); --check-border: 2px solid var(--sk-line); --check-radius: var(--sk-wobble-2);
                                              --check-on-bg: var(--sk-ink); --check-on-border: var(--sk-line); box-shadow: var(--sk-shadow); }

/* Landing: the name as a big heading, one line, and the two ways in under them (Create the primary), all centred on the
   screen, across and down. */
.app .frame.home { justify-content: center; align-items: center; text-align: center; }
.app .frame.home h1 { font-size: var(--text-3xl); padding-right: 0; }
.app .frame.home .cta { margin-top: var(--space-4); width: min(100%, 320px); }

/* The mode's rules: a quiet grey paragraph, the grey line's size with a little more leading. */
.app .line.rules { line-height: var(--leading-snug); }

/* Reveal: the host's Next turn sits right under the points line, which already takes the space at the bottom. */
.app .frame .bottom + .cta { margin-top: 0; }

/* Reveal: while the round-over hold runs, a tap anywhere on the screen goes on to Round over. */
.app .frame.tappable { cursor: pointer; }

/* ---- Motion ------------------------------------------------------------------------------------------------------------
   Short and small, no bounce; durations, easing and distance are tokens (--dur-*, --ease-*, --move in design/tokens.css).
   Everything is inside prefers-reduced-motion: no-preference, so a phone set to reduce motion gets the end state at once.
   app.js decides when an animation starts (see "motion" there) and passes per-row delays as --d. Keyframes move with the
   individual translate and scale properties, never transform, so they add to a component's own transform (the sketch
   heading's tilt, the sent mark's centring) instead of replacing it. */
@media (prefers-reduced-motion: no-preference) {
  /* Screen changes: the new screen fades in; the old one is already hidden. Opacity only: a transform would make the
     screen the containing block of anything fixed inside it. */
  .app .screen:not([hidden]) { animation: q-fade var(--dur-med) var(--ease-out); }

  /* Reveal: each row rises into place after the one before it (--d), and its dots, the count of players on the word, grow
     in from the right edge just behind it. */
  .app .anim-in { animation: q-rise var(--dur-med) var(--ease-out) var(--d, 0ms) both; }
  .app .word.anim-in .dots { animation: q-grow var(--dur-med) var(--ease-out) calc(var(--d, 0ms) + 80ms) both; }

  /* Match: once the matched word is in, a thin ring in the outline's colour spreads off it and fades, and the dots of the
     players who matched pulse once. */
  .app .word.match.anim-in { position: relative; z-index: 1; }   /* over the next row, so the sparks off its bottom edge show */
  .app .word.match.anim-in::after { content: ""; position: absolute; inset: calc(-1 * var(--border-strong)); pointer-events: none;
                                    border: var(--word-match-border); border-radius: inherit;
                                    animation: q-burst var(--dur-slow) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med)) both; }
  .app .word.match.anim-in .dot { animation: q-pulse var(--dur-slow) var(--ease-in-out) calc(var(--d, 0ms) + var(--dur-med)) both; }
  /* The fanfare on top: a second ring just behind the first, the row flushing sage (marker in Sketch) and fading back,
     and the sparks, dots in the matching players' colours, flying off its edges (app.js places them). */
  .app .word.match.anim-in::before { content: ""; position: absolute; inset: calc(-1 * var(--border-strong)); pointer-events: none;
                                     border: var(--word-match-border); border-radius: inherit;
                                     animation: q-burst calc(1.5 * var(--dur-slow)) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med) + 120ms) both; }
  .app .word.match.anim-in { --glow-bg: var(--color-highlight);
                             animation: q-rise var(--dur-med) var(--ease-out) var(--d, 0ms) both,
                                        q-glow calc(2 * var(--dur-slow)) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med)) both; }
  .app .word.match.glow { --glow-bg: var(--color-highlight); position: relative;
                          animation: q-glow calc(2 * var(--dur-slow)) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med)) both; }
  html[data-theme="sketch"] .app .word.match.anim-in,
  html[data-theme="sketch"] .app .word.match.glow { --glow-bg: color-mix(in srgb, var(--sk-marker) 70%, transparent); }
  .app .spark { display: block; position: absolute; width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
                background: var(--player-bg); pointer-events: none;
                animation: q-spark calc(1.5 * var(--dur-slow)) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med) + var(--sd, 0ms)) both; }

  /* Spoiler: Spoiled! comes down onto the page like a stamp; a failed spoiler only fades in, slower, without rising. */
  .app .word.spoiled.anim-in { animation-name: q-stamp; animation-duration: var(--dur-fast); }
  .app .word.fail.anim-in { animation-name: q-fade; animation-duration: var(--dur-slow); }

  /* Turn timer, last five seconds: the bar and the seconds breathe once a second (the urgent red is already on). */
  .app .timer-row.closing .timer i { animation: q-breathe 1s var(--ease-in-out) infinite; }
  .app .timer-row.closing span { animation: q-throb 1s var(--ease-in-out) infinite; display: inline-block; }

  /* Sent: the box with your word slides off to the right and settles back as played, and the sent mark pops in after it. */
  .app #turn-box.just .input { animation: q-send var(--dur-slow) var(--ease-in-out); }
  .app #turn-box.just .sent { animation: q-pop var(--dur-fast) var(--ease-out) var(--dur-med) both; }
  .app #turn-spoiling.just { animation: q-rise var(--dur-med) var(--ease-out); }
  .app #turn-spoiling.just .sent { animation: q-pop var(--dur-fast) var(--ease-out) var(--dur-med) both; }

  /* Round over: a row whose place changed slides from where it stood before the round (--shift rows away) to its new
     place while the totals count up (app.js). The Spoiled! heading stamps down as the reveal's row did. */
  .app .score.anim-move { position: relative; z-index: 1;
                          animation: q-move var(--dur-slow) var(--ease-out) calc(var(--d, 0ms) + var(--dur-med)) both; }
  .app .outcome.stamp { animation: q-stamp var(--dur-fast) var(--ease-out) var(--dur-fast) both; }

  /* Game over: the standings rise in from the bottom up (anim-in, delays from app.js), the winner's name last; then the
     winning rows light up briefly, sage in Serious, the marker in Sketch, and the light fades. */
  .app .score.win { --win-bg: var(--color-highlight);
                    animation: q-rise var(--dur-med) var(--ease-out) var(--d, 0ms) both,
                               q-highlight calc(2 * var(--dur-slow)) var(--ease-out) var(--dw, 0ms) both; }
  html[data-theme="sketch"] .app .score.win { --win-bg: color-mix(in srgb, var(--sk-marker) 70%, transparent); }
}

@keyframes q-fade { from { opacity: 0; } }
@keyframes q-rise { from { opacity: 0; translate: 0 var(--move); } }
@keyframes q-grow { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
@keyframes q-burst { 0% { opacity: 0; scale: 1; } 20% { opacity: .7; } 100% { opacity: 0; scale: 1.03 1.25; } }
@keyframes q-pulse { 0%, 100% { scale: 1; } 50% { scale: 1.4; } }
@keyframes q-stamp { from { opacity: 0; scale: 1.08; } }
@keyframes q-breathe { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes q-throb { 0%, 100% { scale: 1; } 50% { scale: 1.12; } }
@keyframes q-send { 0% { translate: 0 0; opacity: 1; } 45% { translate: var(--move) 0; opacity: 0; } 46% { translate: calc(-1 * var(--move)) 0; } 100% { translate: 0 0; opacity: 1; } }
@keyframes q-glow { 0%, 100% { box-shadow: var(--word-shadow), inset 0 0 0 100vmax transparent; }
                    30% { box-shadow: var(--word-shadow), inset 0 0 0 100vmax var(--glow-bg); } }
@keyframes q-spark { 0% { opacity: 0; translate: 0 0; scale: .5; } 10% { opacity: 1; } 65% { opacity: 1; } 100% { opacity: 0; translate: var(--dx) var(--dy); scale: 1; } }
/* Sparks exist only while motion is on (app.js adds none under reduce); hidden if they ever outlive it. */
@media (prefers-reduced-motion: reduce) { .app .spark { display: none; } }
@keyframes q-highlight { 0%, 100% { background-color: transparent; } 30% { background-color: var(--win-bg); } }
@keyframes q-move { from { translate: 0 calc(var(--shift) * 100%); } }
@keyframes q-pop { from { opacity: 0; scale: .6; } }
