/*
 * Quizmanjaro brand tokens and shared components, from the Brand & Asset Guide v1 (22 October 2026)
 * as set out in the Quizmanjaro design system. Night is the theme for anything played (big screen
 * and phones); Day is for the home page. Flat fills, no drop shadows: the only shadow is the focus
 * ring. "Colour on cream. Reverse on indigo."
 */

@font-face {
  font-family: "Baloo 2";
  src: url("/fonts/Baloo2.woff2") format("woff2");
  font-weight: 700 800;
  font-display: swap;
}

/* Atkinson Hyperlegible Next: the guide's text face, with the Welsh letters (ŵ, ŷ) the original lacks. */
@font-face {
  font-family: "Atkinson Hyperlegible Next";
  src: url("/fonts/AtkinsonNext.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

:root {
  /* Brand colours. The core four lead: indigo, cream, orange, gold. */
  --qm-indigo: #12133a;
  --qm-cream: #fff9f0;
  --qm-orange: #ff6b2c;
  --qm-gold: #ffc22e;
  --qm-forest: #1e6b45;
  --qm-forest-shade: #14513a;
  --qm-heather: #74469b;
  --qm-heather-shade: #5a3580;
  --qm-sage: #a3b98c;
  --qm-ice: #9ad8f2;
  --qm-ice-shade: #6dbce0;
  --qm-snow-shade: #d3e6f2;
  --qm-glacier: #1f6e9e;
  --qm-earth: #b0452a;
  --qm-sand: #c9b07a;
  --qm-coral: #f28c8c;
  --qm-stone: #a3a7da;

  /* Zones explain the climb: each has a colour, a pattern and its name. Uhuru Peak is a gold moment. */
  --zone-rainforest: var(--qm-forest);
  --on-zone-rainforest: var(--qm-cream);
  --zone-moorland: var(--qm-heather);
  --on-zone-moorland: var(--qm-cream);
  --zone-arctic: var(--qm-ice);
  --on-zone-arctic: var(--qm-indigo);
  --zone-summit: var(--qm-gold);
  --on-zone-summit: var(--qm-indigo);
  --pattern-rainforest: url("/brand/pattern-rainforest.svg");
  --pattern-moorland: url("/brand/pattern-moorland.svg");
  --pattern-arctic: url("/brand/pattern-arctic.svg");

  /* Players identify people: colour + symbol + animal + name, never colour alone (see look.ts). */
  --qm-player-1: var(--qm-orange);
  --qm-player-2: var(--qm-gold);
  --qm-player-3: var(--qm-ice);
  --qm-player-4: var(--qm-sage);
  --qm-player-5: var(--qm-heather);
  --qm-player-6: var(--qm-coral);

  /* Answers are numbered 1 to 4 on cream. Orange = the one you picked; gold = the right one. */
  --answer-face: var(--qm-cream);
  --on-answer-face: var(--qm-indigo);
  --answer-selected: var(--qm-orange);
  --on-answer-selected: var(--qm-indigo);

  /* Game states: colour + icon + word, always. Focus is a gold outline and never means right. */
  --state-right: var(--qm-gold);
  --on-state-right: var(--qm-indigo);
  --state-strike: var(--qm-earth);
  --on-state-strike: var(--qm-cream);
  --state-slide: var(--qm-ice);
  --on-state-slide: var(--qm-indigo);
  --state-quickfoot: var(--qm-orange);
  --on-state-quickfoot: var(--qm-indigo);

  /* Type: Baloo 2 for the brand's voice, Atkinson Hyperlegible for questions, answers and instructions. */
  --font-display: "Baloo 2", "Arial Rounded MT Bold", system-ui, sans-serif;
  --font-text: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;

  /* Spacing (4px steps), corners and sizes */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --radius-control: 16px;
  --radius-card: 24px;
  --radius-panel: 32px;
  --radius-pill: 999px;
  --tap-min: 48px;
  --answer-phone-height: 88px;

  /* Motion: focus 120ms, reveal 220ms, a step uphill 350ms, the summit 1.2s with no flashing. */
  --motion-focus: 120ms;
  --motion-reveal: 220ms;
  --motion-step: 350ms;
  --motion-summit: 1200ms;

  /* Night theme (the default) */
  --bg: var(--qm-indigo);
  --surface: #1c1e52;
  --surface-raised: #2b2e70;
  --line: #6066bc;
  --ink: var(--qm-cream);
  --ink-muted: var(--qm-stone);
  --focus-ring: var(--qm-gold);
  /* Cream answers stand out on indigo by themselves; on cream they need an edge. */
  --answer-edge: transparent;
  --shadow-focus: 0 0 0 4px var(--bg), 0 0 0 10px var(--focus-ring);
  color-scheme: dark;
}

/* Day theme: the website, help pages, rules and print */
[data-theme="day"] {
  --bg: var(--qm-cream);
  --surface: #ffffff;
  --surface-raised: #f4ede2;
  --line: #7d80ae;
  --ink: var(--qm-indigo);
  --ink-muted: #4b4e7e;
  /* Gold on cream is too faint, so focus is indigo by day. */
  --focus-ring: var(--qm-indigo);
  --answer-edge: var(--qm-indigo);
  color-scheme: light;
}

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

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

body {
  margin: 0;
  font-family: var(--font-text);
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.05;
  margin: 0;
  font-weight: 800;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

img {
  display: block;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Button: orange for the one main action, cream for the next one ---------- */

.qm-btn {
  font: 800 22px/1 var(--font-display);
  padding: 18px 28px 15px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--qm-orange);
  color: var(--qm-indigo);
  text-decoration: none;
  text-align: center;
  transition: transform var(--motion-focus) ease-out;
}

.qm-btn:active:not([disabled]) {
  transform: scale(0.97);
}

.qm-btn--secondary {
  background: var(--answer-face);
  color: var(--on-answer-face);
  box-shadow: inset 0 0 0 3px var(--answer-edge);
}

.qm-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  transform: scale(1.03);
}

.qm-btn[disabled] {
  background: var(--surface-raised);
  color: var(--ink-muted);
  box-shadow: none;
  cursor: not-allowed;
}

/* ---------- Answer buttons: a number and the answer, on cream ---------- */

.qm-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  width: 100%;
}

.qm-answers.is-long {
  grid-template-columns: 1fr;
}

/* A comparison has two answers: one above the other, each taller, so long contenders read in full */
.qm-answers.is-two {
  grid-template-columns: 1fr;
}

.qm-answers.is-two .qm-answer {
  min-height: calc(var(--answer-phone-height) * 1.25);
}

.qm-answer {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--answer-phone-height);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-3);
  border: 0;
  border-radius: var(--radius-control);
  background: var(--answer-face);
  color: var(--on-answer-face);
  box-shadow: inset 0 0 0 2px var(--answer-edge);
  font: 700 22px/1.2 var(--font-text);
  text-align: left;
  overflow-wrap: break-word;
  hyphens: auto;
  transition:
    transform var(--motion-focus) ease-out,
    background-color var(--motion-reveal) ease-out;
}

button.qm-answer:active:not([disabled]) {
  transform: scale(0.97);
}

button.qm-answer:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  transform: scale(1.02);
}

.qm-answer > span:not(.qm-answer__num, .qm-answer__flag) {
  min-width: 0;
}

.qm-answer__num {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--qm-indigo);
  color: var(--qm-cream);
  font: 800 24px/1 var(--font-display);
  padding-top: 3px;
}

.qm-answer.is-selected {
  background: var(--answer-selected);
  color: var(--on-answer-selected);
  box-shadow: none;
}

.qm-answer.is-dim {
  background: var(--surface-raised);
  color: var(--ink-muted);
  box-shadow: none;
}

.qm-answer.is-dim .qm-answer__num {
  background: var(--ink-muted);
  color: var(--surface-raised);
}

.qm-answer.is-right {
  background: var(--state-right);
  color: var(--on-state-right);
  box-shadow: none;
}

/* "Right answer" with the summit flag: the word and icon go with the gold, always. */
.qm-answer__flag {
  position: absolute;
  top: -16px;
  right: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--radius-pill);
  background: var(--qm-indigo);
  color: var(--qm-cream);
  font: 700 14px/1 var(--font-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qm-answer__flag img {
  width: 24px;
  height: 24px;
  padding: 2px;
  border-radius: 50%;
  background: var(--qm-cream);
}

/* ---------- Icons: the brand's indigo-outlined icons sit on a cream disc on dark grounds ---------- */

.qm-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--qm-cream);
}

.qm-icon img {
  width: 76%;
  height: 76%;
}

/* ---------- Player badge: colour + symbol, with a cream ring so every colour holds on indigo ---------- */

.qm-badge {
  flex: none;
  display: block;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--qm-cream);
}

.qm-badge svg {
  display: block;
  width: 100%;
  height: 100%;
}

.qm-pips {
  display: inline-flex;
  gap: 4px;
}

.qm-pip {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px var(--line);
}

.qm-pip.is-on {
  background: var(--state-strike);
  box-shadow: inset 0 0 0 2px var(--qm-cream);
}

/* ---------- Zone label: colour + pattern + name ---------- */

.qm-zone {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 6px 18px 6px 6px;
  border-radius: var(--radius-pill);
  font: 700 14px/1.2 var(--font-text);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qm-zone__swatch {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-size: 36px;
  box-shadow: inset 0 0 0 2px var(--qm-indigo);
}

.qm-zone small {
  display: block;
  font: 400 14px/1.3 var(--font-text);
  letter-spacing: 0;
  text-transform: none;
}

.qm-zone--rainforest {
  background: var(--zone-rainforest);
  color: var(--on-zone-rainforest);
}

.qm-zone--rainforest .qm-zone__swatch {
  background-image: var(--pattern-rainforest);
}

.qm-zone--moorland {
  background: var(--zone-moorland);
  color: var(--on-zone-moorland);
}

.qm-zone--moorland .qm-zone__swatch {
  background-image: var(--pattern-moorland);
}

.qm-zone--arctic {
  background: var(--zone-arctic);
  color: var(--on-zone-arctic);
}

.qm-zone--arctic .qm-zone__swatch {
  background-image: var(--pattern-arctic);
}

.qm-zone--summit {
  background: var(--zone-summit);
  color: var(--on-zone-summit);
}

.qm-zone--summit .qm-zone__swatch {
  background: var(--qm-cream) url("/icons/summit-flag.svg") center / 70% no-repeat;
}

/* ---------- Countdown ring ---------- */

.qm-timer {
  position: relative;
  width: 112px;
  height: 112px;
  flex: none;
}

.qm-timer svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  display: block;
}

.qm-timer__track {
  fill: none;
  stroke: var(--surface-raised);
  stroke-width: 12;
}

.qm-timer__fill {
  fill: none;
  stroke: var(--qm-gold);
  stroke-width: 12;
  stroke-linecap: round;
}

.qm-timer.is-low .qm-timer__fill {
  stroke: var(--qm-orange);
}

.qm-timer__num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 800 44px/1 var(--font-display);
  color: var(--ink);
  padding-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- View as (milestone 60): the band while an admin views the site as someone else ---------- */

.view-as-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 16px;
  background: var(--qm-heather);
  color: var(--qm-cream);
  font: 400 16px/1.35 var(--font-text);
}
.view-as-band p {
  margin: 0;
  flex: 1 1 280px;
}
.view-as-band strong {
  display: block;
  font: 800 20px/1.2 var(--font-display);
}
.view-as-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.view-as-pick label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.view-as-band .view-as-pick label span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.view-as-pick select {
  font: 400 16px/1.2 var(--font-text);
  padding: 10px 12px;
  border-radius: var(--radius-control);
  border: 2px solid var(--qm-indigo);
  background: var(--qm-cream);
  color: var(--qm-indigo);
  max-width: 100%;
}
/* Host pages lay the body out as header, main, footer: the band adds a row above them. */
body:has(> .view-as-band) {
  grid-template-rows: auto auto 1fr auto;
}
.view-as-pick .qm-btn,
.view-as-band .qm-btn {
  width: auto;
  font-size: 18px;
  padding: 12px 18px 10px;
}
.view-as-error {
  flex-basis: 100%;
  font-weight: 700;
}

/* ---------- Day pages (home, host pages): a calmer, modern finish (21 Nov 2026 UX review) ---------- */

/* The header's links are pills: no underlines; where you are is filled indigo. */
[data-theme="day"] header nav {
  align-items: center;
  gap: 4px;
}

[data-theme="day"] header nav a {
  padding: 10px 14px 8px;
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition:
    background-color var(--motion-focus) ease-out,
    color var(--motion-focus) ease-out;
}

[data-theme="day"] header nav a:hover {
  background: var(--surface-raised);
}

[data-theme="day"] header nav a[aria-current="page"] {
  background: var(--qm-indigo);
  color: var(--qm-cream);
}

[data-theme="day"] header nav a:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Buttons by day: a little smaller and lighter, with a hover. Primary orange; secondary white
   with a thin indigo edge; quiet is text only; small for the row of actions on a card. */
[data-theme="day"] .qm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 19px;
  padding: 15px 24px 13px;
  cursor: pointer;
  transition:
    transform var(--motion-focus) ease-out,
    background-color var(--motion-focus) ease-out,
    filter var(--motion-focus) ease-out;
}

[data-theme="day"] .qm-btn:hover:not([disabled]) {
  filter: brightness(1.06);
}

[data-theme="day"] .qm-btn--secondary {
  background: var(--surface);
  color: var(--qm-indigo);
  box-shadow: inset 0 0 0 2px var(--qm-indigo);
}

[data-theme="day"] .qm-btn--secondary:hover:not([disabled]) {
  filter: none;
  background: var(--surface-raised);
}

[data-theme="day"] .qm-btn--quiet {
  background: transparent;
  color: var(--ink-muted);
  box-shadow: none;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

[data-theme="day"] .qm-btn--quiet:hover:not([disabled]) {
  filter: none;
  color: var(--ink);
  background: var(--surface-raised);
}

[data-theme="day"] .qm-btn--small {
  font-size: 16px;
  padding: 11px 16px 9px;
}

[data-theme="day"] .qm-btn--secondary:focus-visible,
[data-theme="day"] .qm-btn--quiet:focus-visible {
  box-shadow: var(--shadow-focus);
}

/* The plan at the end of the header's links (21 Nov 2026): Upgrade in orange on the free version
   and passes; otherwise the plan's name with a gold dot, quietly, as a link to the plans page. */
[data-theme="day"] header nav a[data-plan="upgrade"] {
  margin-left: 6px;
  background: var(--qm-orange);
  color: var(--qm-indigo);
}

[data-theme="day"] header nav a[data-plan="upgrade"]:hover {
  background: var(--qm-orange);
  filter: brightness(1.06);
}

[data-theme="day"] header nav a[data-plan="plan"] {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: inset 0 0 0 2px var(--surface-raised);
}

[data-theme="day"] header nav a[data-plan="plan"]::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--qm-gold);
}

[data-theme="day"] header nav a[data-plan][aria-current="page"] {
  background: var(--qm-indigo);
  color: var(--qm-cream);
}

/* Sign out sits quietly at the end of the header's links. */
[data-theme="day"] header nav a[data-sign-out] {
  color: var(--ink-muted);
  font-weight: 400;
}

/* ---------- Laptops: the links stay on one line (6 Dec 2026 review: a school admin's eight wrapped
   onto a second row at full width). With seven or more, the pills and logo get a little smaller;
   on a narrow window the row scrolls sideways, as on a phone, rather than wrapping. ---------- */
@media (min-width: 601px) {
  [data-theme="day"] body > header {
    min-width: 0;
  }
  [data-theme="day"] body > header > a:first-child {
    flex: none;
  }
  [data-theme="day"] header nav {
    flex-wrap: nowrap;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }
  [data-theme="day"] header nav::-webkit-scrollbar {
    display: none;
  }
  [data-theme="day"] header nav a {
    white-space: nowrap;
    flex: none;
  }
  [data-theme="day"] header:has(nav > a:nth-child(7)) nav {
    gap: 2px;
    padding-left: 0;
    padding-right: 0;
    font-size: 16px;
  }
  [data-theme="day"] header:has(nav > a:nth-child(7)) nav a {
    padding: 9px 11px 7px;
  }
  [data-theme="day"] header:has(nav > a:nth-child(7)) img {
    width: 210px;
  }
}

/* ---------- Phones: the header's links scroll sideways in one row rather than wrapping (UX review) ---------- */
@media (max-width: 600px) {
  [data-theme="day"] header nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    align-self: stretch;
    min-width: 0;
    max-width: 100vw;
    margin: 0 -16px;
    padding: 2px 16px 6px;
    scrollbar-width: none;
  }
  [data-theme="day"] body > header {
    min-width: 0;
  }
  [data-theme="day"] header nav::-webkit-scrollbar {
    display: none;
  }
}
