/* estiMate — "Cheese Pop": cheese yellow, ink outlines, hard offset shadows.
   Shared by the estimating tool and the check-in game. */

:root {
  --bg: #fff7d6;
  --surface: #ffffff;
  --ink: #111111;
  --ink-soft: #4a4536;
  --ink-faint: #6e6855;
  --line: #111111;
  --shadow: #111111;
  --cheese: #ffd23f;
  --cheese-soft: #fff0b3;
  --accent: #2b4bff;
  --on-accent: #ffffff;
  --sel-bg: #111111;
  --sel-fg: #ffd23f;
  --ok: #1f6b3a;
  --ok-bg: #d9f2df;
  --warn: #7a4a00;
  --warn-bg: #ffe7b8;
  --bw: 3px;
  --radius: 14px;
  --display: "Archivo Black", "Arial Black", "Helvetica Neue", Helvetica, system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --surface: #1f1f1f;
    --ink: #f5f1e6;
    --ink-soft: #c9c2ae;
    --ink-faint: #a39c8c;
    --line: #f5f1e6;
    --shadow: #ffd23f;
    --cheese-soft: #3a3214;
    --accent: #8ea2ff;
    --on-accent: #111111;
    --sel-bg: #ffd23f;
    --sel-fg: #111111;
    --ok: #8fdca8;
    --ok-bg: #18261d;
    --warn: #ffc56b;
    --warn-bg: #2e2412;
  }
}

* { box-sizing: border-box; }

/* Layout rules below use display:flex/grid, which would otherwise win over the
   hidden attribute's default display:none. */
[hidden] { display: none !important; }

/* The inline symbol sheet: present for <use>, never part of the layout. A
   class rather than a style attribute, which the page's CSP would block. */
.sprite { position: absolute; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view { width: 100%; }
.view.narrow { max-width: 28rem; }

.display {
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: -.01em;
  line-height: 1;
  margin: 0;
}
.small-display { font-size: 1.35rem; }

.lede { color: var(--ink-soft); margin: .75rem 0 1.5rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; }

/* ─── Top bar ──────────────────────────────────────────────────────────── */

/* Yellow in both themes — it is the brand, and its colours are fixed so the
   band reads the same in dark mode. */
.topbar {
  background: #ffd23f;
  color: #111111;
  border-bottom: var(--bw) solid #111111;
}
.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: .8rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.5rem;
}
/* Referenced from an inline <symbol> rather than <img src>: currentColor only
   resolves inside the document. */
.logo { width: 40px; height: 40px; flex: 0 0 auto; }

.topbar-session { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }
.chip {
  font-family: var(--display);
  font-weight: 900;
  letter-spacing: .12em;
  background: #ffffff;
  color: #111111;
  border: var(--bw) solid #111111;
  border-radius: 10px;
  padding: .3rem .7rem;
}
.scale-tag { font-weight: 700; font-size: .9rem; }
.topbar button.ink {
  background: #111111;
  color: #ffd23f;
  border-color: #111111;
  box-shadow: 4px 4px 0 #2b4bff;
}

/* ─── Controls ─────────────────────────────────────────────────────────── */

button, input, select, a.button { font: inherit; }

button, a.link, a.button {
  /* Without these a tap on a phone selects the label instead of pressing. */
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

button, a.button {
  background: var(--surface);
  color: var(--ink);
  border: var(--bw) solid var(--line);
  border-radius: 12px;
  padding: .55rem 1rem;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--shadow); }
button:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
button.primary { background: #ffd23f; color: #111111; }
button.big { min-height: 56px; padding: 0 1.6rem; font-size: 1.1rem; box-shadow: 6px 6px 0 var(--shadow); }
button.small { min-height: 36px; padding: .25rem .7rem; font-size: .9rem; box-shadow: 3px 3px 0 var(--shadow); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* Feedback for a click still in flight. Applied only after a short delay
   (see PENDING_AFTER in client.js), so a fast answer never makes it flicker. */
@keyframes pp-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

button.busy {
  animation: pp-pulse 1.1s ease-in-out infinite;
  cursor: progress;
  pointer-events: none;   /* a second click would only queue up trouble */
}

a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--accent); }

button.link, a.link {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--ink-soft);
  padding: .4rem 0;
  min-height: 44px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
button.link:hover, button.link:active { color: var(--ink); transform: none; box-shadow: none; }

input, select {
  background: var(--surface);
  color: var(--ink);
  border: var(--bw) solid var(--line);
  border-radius: 12px;
  padding: .6rem .8rem;
  min-height: 48px;
  width: 100%;
}
input:focus-visible, button:focus-visible, a:focus-visible, select:focus-visible,
.seg input:focus-visible + span {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

#input-code {
  font-family: var(--display);
  text-transform: uppercase;
  letter-spacing: .2em;
  font-size: 1.4rem;
  text-align: center;
}

label { font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack label { margin-bottom: -.35rem; }
.field { display: flex; flex-direction: column; gap: .35rem; }

.panel {
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: 20px;
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 1.5rem;
}

/* ─── Start ────────────────────────────────────────────────────────────── */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2.5rem;
  padding-top: 1.5rem;
}
.hero-text { flex: 1 1 26rem; display: flex; flex-direction: column; }
.hero .display { font-size: clamp(2.6rem, 6.5vw, 5rem); line-height: 1.12; }
.hero .mark {
  background: #ffd23f;
  color: #111111;
  padding: 0 .15em;
  border-radius: .12em;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.hero .lede { font-size: 1.15rem; max-width: 30rem; margin-top: 1.25rem; }
.hero #form-code { margin-top: 1.5rem; max-width: 22rem; }

.hero-cards {
  flex: 1 1 18rem;
  max-width: 24rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .9rem;
}
.hero-cards span {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.4rem;
  background: var(--surface);
  border: var(--bw) solid var(--line);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--shadow);
}
.hero-cards .alt { background: #ffd23f; color: #111111; }
.hero-cards .blue { background: #2b4bff; color: #ffffff; }
.hero-cards .dark { background: var(--sel-bg); color: var(--sel-fg); }
.hero-cards span:nth-child(odd) { transform: rotate(-2deg); }
.hero-cards span:nth-child(even) { transform: rotate(2deg); }

/* ─── Name & scale ─────────────────────────────────────────────────────── */

#view-name .panel { display: flex; flex-direction: column; gap: .5rem; }
#view-name .lede { margin: .25rem 0 .75rem; }
#scale-picker { display: flex; flex-direction: column; gap: .75rem; margin: .25rem 0 .5rem; }
#custom-hint { margin: 0; }
.deck-preview { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 2.2rem; }
.deck-preview span {
  font-family: var(--display);
  font-weight: 900;
  min-width: 2.2rem;
  padding: .25rem .5rem;
  text-align: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--cheese-soft);
}
.deck-preview .invalid { font-family: inherit; font-weight: 600; border: none; background: none; color: var(--warn); padding: 0; }

/* ─── Banners ──────────────────────────────────────────────────────────── */

.banner {
  transition: opacity .35s ease;
  width: 100%;
  border: var(--bw) solid var(--line);
  background: var(--warn-bg);
  color: var(--ink);
  font-weight: 600;
  padding: .7rem .9rem;
  margin-bottom: 1.25rem;
  border-radius: 12px;
  box-shadow: 4px 4px 0 var(--shadow);
}
.banner.subtle { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--cheese-soft); }
.banner.status { background: var(--surface); color: var(--ink-soft); }
.banner.fading { opacity: 0; }
#error { cursor: pointer; }
.control-actions { display: flex; gap: .6rem; margin-left: auto; }

/* ─── Invite ───────────────────────────────────────────────────────────── */

.invite {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}
.invite.accent { background: #2b4bff; color: #ffffff; }
/* The QR keeps its own white ground: inverting it would stop it scanning. */
#qr {
  background: #ffffff;
  border: var(--bw) solid #111111;
  border-radius: 12px;
  width: 180px;
  height: 180px;
}
.invite-actions { display: flex; flex-direction: column; gap: .6rem; min-width: 0; flex: 1 1 18rem; }
#invite-url { word-break: break-all; margin: 0; font-weight: 600; }
.invite .row button, .invite .row a.button { background: #ffffff; color: #111111; border-color: #111111; box-shadow: 4px 4px 0 #111111; }

/* ─── Session layout ───────────────────────────────────────────────────── */

.session-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: flex-start;
}
.session-main { flex: 999 1 30rem; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
.session-side { flex: 1 1 18rem; display: flex; flex-direction: column; gap: 1.25rem; }

/* ─── Timer ────────────────────────────────────────────────────────────── */

/* Sticks to the top edge so the countdown stays readable while scrolling. */
.timer {
  position: sticky;
  top: .5rem;
  z-index: 3;
  align-self: flex-start;
  font-family: var(--display);
  font-weight: 900;
  font-size: 2.6rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  background: #ffd23f;
  color: #111111;
  border: var(--bw) solid #111111;
  border-radius: 14px;
  padding: .4rem 1rem;
  box-shadow: 5px 5px 0 var(--shadow);
  transition: font-size .18s ease, padding .18s ease;
}
.timer.stuck { font-size: 1.5rem; padding: .3rem .8rem; }
.timer-unit { font-size: .45em; margin-left: .15rem; }
.timer.expired { background: var(--surface); color: var(--ink-faint); }

/* ─── Cards ────────────────────────────────────────────────────────────── */

.cards {
  display: grid;
  /* Up to four per row on a wide screen, so a 12-card custom deck stays tidy. */
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: 1.1rem;
}

.card {
  height: 9rem;
  font-family: var(--display);
  font-weight: 900;
  font-size: 3rem;
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--shadow);
  padding: 0;
}
.card:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--shadow); }

/* Your own card inverts and tilts — unmistakable at a glance. */
.card[aria-pressed="true"],
.card[aria-pressed="true"]:hover:not(:disabled) {
  background: var(--sel-bg);
  color: var(--sel-fg);
  box-shadow: 6px 6px 0 #2b4bff;
  transform: translate(-3px, -6px) rotate(-2deg);
}

/* The card already flipped optimistically; this says the server has not
   confirmed it yet. */
.card.pending { animation: pp-pulse 1.1s ease-in-out infinite; }

@media (prefers-reduced-motion: reduce) {
  button.busy, .card.pending { animation: none; opacity: .6; }
  button, .card { transition: none; }
}

.closed-note { color: var(--ink-soft); font-weight: 600; margin: 0; }

/* ─── Crew ─────────────────────────────────────────────────────────────── */

.crew { padding: 1.1rem 1.25rem; }
.crew-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .5rem; }
.progress { margin: 0; font-weight: 700; }

.participants { list-style: none; margin: 0; padding: 0; }
.participants li {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 48px;
}
.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--cheese-soft);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .95rem;
}
.participants li:nth-child(3n+2) .avatar { background: var(--surface); }
.participants .name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.participants .host-tag { color: var(--ink-soft); font-size: .8rem; font-weight: 600; }
.participants .away { color: var(--ink-faint); }
.participants .away .avatar { border-style: dashed; background: none; }
.participants .away .name::after { content: " · away"; font-weight: 500; font-size: .8rem; }

.participants .state, .vote-chip {
  margin-left: auto;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: .1rem .55rem;
  font-size: .8rem;
  font-weight: 700;
  background: var(--surface);
  white-space: nowrap;
}
.participants .state:empty { display: none; }
.participants .state.voted { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.vote-chip {
  font-family: var(--display);
  font-weight: 900;
  font-size: 1.1rem;
  min-width: 2.4rem;
  text-align: center;
  background: #ffd23f;
  color: #111111;
  border-color: #111111;
}
.vote-chip.none { background: var(--surface); color: var(--ink-faint); border-color: var(--line); }

/* ─── Result ───────────────────────────────────────────────────────────── */

.result { display: flex; flex-direction: column; gap: 1.1rem; }
.result h2 { font-size: 1.8rem; }

.dist { display: flex; flex-direction: column; gap: .55rem; }
.dist-row { display: flex; align-items: center; gap: .8rem; }
.dist-value { width: 2.6rem; flex: none; text-align: center; font-family: var(--display); font-weight: 900; font-size: 1.3rem; }
.dist-track {
  flex: 1 1 6rem;
  height: 32px;
  background: var(--cheese-soft);
  border: 2px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.dist-fill { height: 100%; background: #ffd23f; border-right: 2px solid #111111; }
.dist-names { flex: 0 1 12rem; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }

/* The verdict: a tilted sticker. Words carry the meaning, colour only helps
   find it. */
.result .verdict {
  align-self: flex-start;
  max-width: 34rem;
  border: var(--bw) solid #111111;
  border-radius: 14px;
  padding: .8rem 1rem;
  box-shadow: 4px 4px 0 #111111;
  transform: rotate(-1.2deg);
}
.result .verdict strong { display: block; font-family: var(--display); font-weight: 900; font-size: 1.15rem; }
.result .verdict.spread { background: #2b4bff; color: #ffffff; }
.result .verdict.agreed { background: #ffd23f; color: #111111; }
.result .verdict.none { background: var(--surface); color: var(--ink); border-color: var(--line); }

/* ─── Host controls ────────────────────────────────────────────────────── */

.host-bar { display: flex; flex-direction: column; gap: .8rem; }
.host-bar > button { width: 100%; }
.timer-controls { display: flex; align-items: flex-end; gap: .6rem; flex-wrap: wrap; }

/* Segmented control: three choices in the space of one field. */
.seg { border: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 0; min-width: 0; }
.seg legend { float: left; font-weight: 700; margin-right: .6rem; padding: 0; line-height: 44px; }
.seg label { position: relative; font-weight: 700; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.seg span {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  padding: 0 .6rem;
  border: var(--bw) solid var(--line);
  margin-left: calc(-1 * var(--bw));
  background: var(--surface);
  cursor: pointer;
}
.seg label:first-of-type span { border-radius: 12px 0 0 12px; margin-left: 0; }
.seg label:last-of-type span { border-radius: 0 12px 12px 0; }
.seg input:checked + span { background: var(--sel-bg); color: var(--sel-fg); }

.bar-end { display: flex; justify-content: space-between; gap: 1rem; }

@media (min-width: 46rem) {
  .cards { --cols: 3; }
  .cards.many { --cols: 4; }
}

@media (max-width: 46rem) {
  .page { padding: 1.25rem 1rem 3rem; }
  .cards { --cols: 3; gap: .8rem; }
  .card { height: 5.75rem; font-size: 2rem; box-shadow: 4px 4px 0 var(--shadow); }
  .scale-tag { display: none; }   /* the code matters more on a phone */
  .hero-cards { display: none; }
  .wordmark { font-size: 1.25rem; }
  .logo { width: 32px; height: 32px; }

  /* The host reaches for these every round; on a phone they would otherwise
     sit permanently below the fold. */
  .host-bar {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--bg);
    border-top: var(--bw) solid var(--line);
    margin: 0 -1rem;
    padding: .7rem 1rem;
    /* Two buttons side by side, timer below: three rows would hide half the
       screen on a phone. */
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .6rem;
  }
  .host-bar > button { min-height: 48px; padding: 0 .6rem; font-size: 1rem; }
  .host-bar > button.big { box-shadow: 4px 4px 0 var(--shadow); }
  .host-bar .timer-controls { grid-column: 1 / -1; }
}
