/* Salto Wecosystem styling. Colours taken from the brand logo. */

@font-face {
  font-family: "Space Grotesk";
  src: url("../fonts/space-grotesk-latin-wght.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  --bg: #1b241c;          /* dark slide background */
  --bg-raised: #253027;
  --cream: #fff8e6;       /* light slide background */
  --ink: #1b241c;         /* text on cream / on accent colours */
  --on-dark: #ffffff;
  --muted: #5e6b60;
  --muted-on-dark: #a9b8ac;

  --cyan: #50c8ff;
  --teal: #00b0a2;
  --teal-text: #00877c;   /* teal dark enough for text on cream */
  --blue: #6e91ff;
  --green: #76dc87;
  --danger: #c4402f;

  --radius: 14px;
  --font: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--on-dark);
  overflow-x: hidden;
}

h1, h2 { letter-spacing: -0.01em; }

[hidden] { display: none !important; }

.muted { color: var(--muted); }

.btn {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 0.75rem 1.25rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--teal);
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.btn:hover { background: var(--green); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:disabled:hover { background: var(--teal); }
.btn:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }

.btn-quiet {
  background: transparent;
  border: 2px solid rgba(255, 248, 230, 0.35);
  color: var(--cream);
}
.btn-quiet:hover { background: rgba(255, 248, 230, 0.1); }

/* ---------- Shared: answer colours, pills, timer ---------- */

.opt-0 { --opt: var(--cyan); }
.opt-1 { --opt: var(--teal); }
.opt-2 { --opt: var(--blue); }
.opt-3 { --opt: var(--green); }

.pill {
  display: inline-block;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.timer {
  display: inline-grid;
  place-items: center;
  min-width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: var(--cream);
  color: var(--ink);
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timer:empty { visibility: hidden; }
.timer.urgent { background: var(--cyan); animation: pulse 1s infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- Player (mobile-first) ---------- */

body.player main {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 1.25rem 1rem 1rem;
}

.brand-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.25rem 0 1.5rem;
}
.brand-bar .brand-mark { height: 30px; width: auto; }
.brand-bar h1 { margin: 0; font-size: 1.6rem; font-weight: 700; }

.brand-footer {
  margin-top: auto;
  padding-top: 2rem;
  text-align: center;
}
.brand-footer img { height: 14px; width: auto; opacity: 0.85; }

.card {
  background: var(--cream);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 1.5rem 1.25rem;
  text-align: center;
}

.card label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 700;
}

.card input {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid #d9d2bf;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.25rem; /* >= 16px so iOS doesn't zoom on focus */
  text-align: center;
}
.card input:focus { outline: none; border-color: var(--teal); }

.error {
  margin: -0.25rem 0 1rem;
  color: var(--danger);
  font-weight: 600;
}

.player-name {
  margin: 0.25rem 0 1rem;
  font-size: 2rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.waiting { font-size: 1.15rem; margin: 0 0 1rem; }

.dots { display: flex; justify-content: center; gap: 0.5rem; }
.dots span {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--cyan);
  animation: bounce 1.2s infinite ease-in-out;
}
.dots span:nth-child(2) { animation-delay: 0.15s; background: var(--teal); }
.dots span:nth-child(3) { animation-delay: 0.3s; background: var(--green); }
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

body.player .status {
  margin-top: 1rem;
  text-align: center;
  color: var(--cyan);
}

.q-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

body.player .q-text {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.q-hint {
  margin: -0.5rem 0 1.25rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
}

.answers { display: grid; gap: 0.75rem; }

.answer {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 72px;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--opt);
  color: var(--ink);
  font: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.answer:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35); }
.answer:focus-visible { outline: 3px solid var(--cream); outline-offset: 3px; }
.answer:disabled { cursor: default; opacity: 0.3; }
.answer.chosen { opacity: 1; outline: 4px solid var(--cream); }
.answer .shape { font-size: 1.5rem; flex: none; }

.msg-icon { font-size: 4rem; line-height: 1; }
.msg-title { margin: 0.75rem 0 0.25rem; font-size: 2rem; font-weight: 700; }
.msg-text { margin: 0 0 1rem; font-size: 1.2rem; overflow-wrap: anywhere; }
.card.msg-good { background: #e2f7e6; box-shadow: inset 0 0 0 4px var(--green); }
.card.msg-bad { background: #fbe9e4; }

/* ---------- Host (projector) ---------- */

body.host main {
  min-height: 100vh;
  padding: 2rem 3rem 1.5rem;
}

body.host #host {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 3.5rem);
}

/* Content sits above the decorative chevrons. */
#host > :not(.chev) { position: relative; z-index: 1; }

.host-header { text-align: center; }
.host-header h1 { margin: 0; font-size: clamp(2.75rem, 5.5vw, 5rem); font-weight: 700; }
/* Wordmark image + tagline as text, laid out like the official logo (1391 × 187 px):
   the tagline starts under the W (x = 450) and its capitals are 43 px high. */
.brand-logo { --logo-h: clamp(56px, 6vw, 92px); display: block; margin-bottom: 2.5rem; text-align: left; }
.brand-logo img { display: block; height: calc(var(--logo-h) * 104 / 187); width: auto; }
.brand-tagline {
  display: block;
  margin: calc(var(--logo-h) * 0.12) 0 0 calc(var(--logo-h) * 450 / 187);
  color: var(--teal);
  font-size: calc(var(--logo-h) * 0.41);
  font-weight: 400;
  line-height: 1;
  text-transform: uppercase;
}
.host-title { display: flex; align-items: center; justify-content: center; gap: 1rem; }
.host-title .brand-mark { display: none; height: 2.2rem; width: auto; }
.join-url { margin: 0.75rem 0 0; font-size: clamp(1.5rem, 2.5vw, 2.25rem); color: var(--muted-on-dark); }
.join-url strong { color: var(--cyan); }

.lobby { flex: 1; margin-top: 2.5rem; }
.lobby h2 { margin: 0 0 1.5rem; text-align: center; font-size: clamp(2rem, 3.5vw, 3rem); }
.lobby .muted { text-align: center; font-size: 1.75rem; color: var(--muted-on-dark); }

.player-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}
.player-list li {
  padding: 0.5rem 1.25rem;
  border-radius: 999px;
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  font-weight: 700;
}
.player-list li.new { animation: pop 0.3s ease-out; }
.player-list li.offline { opacity: 0.4; }
@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.host-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1.5rem;
  margin-top: 2rem;
}
.footer-wordmark { height: 20px; width: auto; margin-right: auto; }
#host[data-phase="lobby"] .footer-wordmark,
#host:not([data-phase]) .footer-wordmark { visibility: hidden; }
.host-footer .status { color: var(--cyan); font-size: 1.25rem; }
.host-footer .btn { width: auto; font-size: 1.1rem; min-height: 48px; }
.host-footer #next-button { font-size: 1.4rem; padding: 0.75rem 2rem; }

/* In-game: compact header row, like a content slide. */
#host.in-game .host-header { display: flex; justify-content: space-between; align-items: center; gap: 2rem; text-align: left; }
#host.in-game .brand-logo { display: none; }
#host.in-game .host-title .brand-mark { display: block; }
#host.in-game .host-header h1 { font-size: 2rem; }
#host.in-game .join-url { font-size: 1.25rem; margin: 0; }

/* Decorative chevron blocks (lobby: title-slide corners; scoreboard/final: framed sides). */
.chev {
  display: none;
  position: fixed;
  z-index: 0;
  pointer-events: none;
  background: no-repeat center / contain;
}
#host[data-phase="lobby"] .chev,
#host:not([data-phase]) .chev { display: block; background-image: url("../img/chevrons-wide.svg"); }
#host[data-phase="lobby"] .chev-a,
#host:not([data-phase]) .chev-a { top: 2rem; right: 2rem; width: 28vw; height: 16vw; background-position: left top; transform: scaleX(-1); }
#host[data-phase="lobby"] .chev-b,
#host:not([data-phase]) .chev-b { bottom: 6rem; left: 2rem; width: 34vw; height: 20vw; background-position: left bottom; }

#host[data-phase="scoreboard"] .chev,
#host[data-phase="final"] .chev { display: block; top: 9rem; bottom: 7rem; width: 13vw; background-image: url("../img/chevrons-tall.svg"); }
#host[data-phase="scoreboard"] .chev-a,
#host[data-phase="final"] .chev-a { right: 3rem; transform: scaleX(-1); }
#host[data-phase="scoreboard"] .chev-b,
#host[data-phase="final"] .chev-b { left: 3rem; }

/* ---------- Host: question ---------- */

body.host .question,
body.host .board { flex: 1; margin-top: 2rem; }

.q-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
}
body.host .timer { min-width: 6rem; height: 6rem; font-size: 3rem; }

body.host .q-text {
  margin: 2rem auto;
  max-width: 1400px;
  text-align: center;
  font-size: clamp(2rem, 4vw, 3.75rem);
  font-weight: 700;
  line-height: 1.2;
}

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  max-width: 1600px;
  margin: 0 auto;
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  min-height: 7rem;
  padding: 1rem 1.75rem;
  border-radius: var(--radius);
  background: var(--opt);
  color: var(--ink);
  font-size: clamp(1.5rem, 2.5vw, 2.5rem);
  font-weight: 700;
  overflow: hidden;
  transition: opacity 0.3s;
}
.tile .shape { font-size: 1.2em; flex: none; }
.tile .tile-text { flex: 1; overflow-wrap: anywhere; }
.tile .tile-count { font-size: 1.1em; }
.tile .bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 10px;
  background: rgba(27, 36, 28, 0.6);
}
.tile.dim { opacity: 0.3; }
.tile.correct { outline: 6px solid var(--cream); }

/* Movie still: image left, answers right. */
.question.has-still .q-text { margin: 1rem auto 1.5rem; font-size: clamp(1.75rem, 3vw, 3rem); }
.question.has-still .q-body {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 2rem;
  align-items: center;
  max-width: 1800px;
  margin: 0 auto;
}
.question.has-still .tiles { grid-template-columns: 1fr; gap: 1rem; }
.question.has-still .tile { min-height: 5rem; font-size: clamp(1.25rem, 2vw, 2rem); }

.still {
  position: relative;
  justify-self: center;
  overflow: hidden;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  line-height: 0;
}
.still-blur {
  display: block;
  max-width: 100%;
  max-height: 55vh;
  filter: blur(28px) brightness(0.85);
  transform: scale(1.1); /* hide the soft blurred edges */
}
.still-sharp {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  clip-path: inset(40% round 12px);
}

/* ---------- Host: scoreboard & podium ---------- */

.board h2 { margin: 0 0 2rem; text-align: center; font-size: clamp(2.5rem, 4vw, 4rem); font-weight: 700; }

.board-list {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.75rem;
}
.board-list li {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.5rem;
  border-radius: 12px;
  background: var(--cream);
  color: var(--ink);
  font-size: clamp(1.5rem, 2.2vw, 2.25rem);
  font-weight: 700;
}
.board-list .rank { min-width: 3.5rem; color: var(--teal-text); }
.board-list .name { flex: 1; overflow-wrap: anywhere; }
.board-list .score { font-variant-numeric: tabular-nums; }

.podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
.place {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(24vw, 320px);
  text-align: center;
}
.place .medal { font-size: 4rem; }
.place .place-name { font-size: clamp(1.75rem, 3vw, 3rem); font-weight: 700; overflow-wrap: anywhere; }
.place .place-score { font-size: clamp(1.25rem, 2vw, 2rem); color: var(--green); margin-bottom: 0.75rem; }
.place .block {
  display: grid;
  place-items: center;
  width: 100%;
  border-radius: 12px 12px 0 0;
  color: var(--ink);
  font-size: 2.5rem;
  font-weight: 700;
}
.place-1 .block { height: 14rem; background: var(--teal); }
.place-2 .block { height: 10rem; background: var(--cyan); }
.place-3 .block { height: 7rem; background: var(--blue); }

/* ---------- Chevron Christmas tree (game start and final results; built in host.js) ---------- */

.chev { transition: opacity 0.5s; }
#host.tree-playing .chev { opacity: 0; }

/* "#host >" beats the generic "#host > :not(.chev)" rule that would make it position: relative. */
#host > .tree-show {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2vh;
  background: var(--bg);
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}
#host > .tree-show.shown { opacity: 1; pointer-events: auto; }

.tree {
  position: relative;
  height: 68vh;
  aspect-ratio: 100 / 140;
}

.tree-chev {
  position: absolute;
  aspect-ratio: 2 / 1;
}
.tree-chev svg { display: block; width: 100%; height: 100%; overflow: visible; }

.tree-star {
  position: absolute;
  left: 42%;
  top: -3%;
  width: 16%;
  aspect-ratio: 1;
  opacity: 0;
  transform: scale(0) rotate(-90deg);
  transition: transform 0.6s cubic-bezier(.2, .8, .3, 1.4), opacity 0.3s;
}
.tree-star svg { display: block; width: 100%; height: 100%; fill: var(--cream); }

.tree-caption {
  margin: 0;
  color: var(--cream);
  font-size: 4.5rem;
  font-weight: 700;
  opacity: 0;
  transform: translateY(1rem);
  transition: opacity 0.6s 0.2s, transform 0.6s 0.2s;
}

.tree-show.lit .tree-star {
  opacity: 1;
  transform: none;
  animation: star-glow 1.4s ease-in-out 0.6s infinite alternate;
}
.tree-show.lit .tree-caption { opacity: 1; transform: none; }

@keyframes star-glow {
  from { filter: drop-shadow(0 0 0.4rem var(--cyan)); }
  to   { filter: drop-shadow(0 0 1.6rem var(--green)); }
}

@media (prefers-reduced-motion: reduce) {
  .dots span, .player-list li.new, .timer.urgent { animation: none; }
  /* The image reveal is game content, not decoration, so it keeps animating. */
}
