/* Ordleg - big-screen layout and default theme.
 * Themes (css/themes/*.css, phase 5) override only the tokens in html[data-ordleg-theme="..."].
 * (data-theme is reserved for Pico, which is pinned to "dark".) */

@font-face {
  font-family: "Fredoka";
  src: url("../assets/fonts/fredoka-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Nunito";
  src: url("../assets/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  /* Theme token contract - css/themes/*.css override ONLY these, under
   * html[data-ordleg-theme="<name>"], plus .theme-deco decorations. */
  --bg: radial-gradient(ellipse at 20% 0%, #3b2a7a 0%, transparent 55%),
        radial-gradient(ellipse at 90% 100%, #7a2a6b 0%, transparent 50%),
        #17122e;
  --fg: #fbf8ff;
  --fg-muted: #c9c0e6;
  --accent: #ffc94d;
  --accent-fg: #2a1d00;
  --card: rgba(255, 255, 255, 0.08);
  --card-strong: rgba(28, 21, 58, 0.88);
  --card-border: rgba(255, 255, 255, 0.16);
  --taboo: #ff6b81;
  --taboo-bg: rgba(255, 107, 129, 0.14);
  --timer-ok: #6ee7b7;
  --timer-warn: #ff6b81;
  --timer-warn-fg: #ffffff;                 /* text on the "Tiden løb ud" banner */
  --ok: #6ee7b7;
  --bad: #ff8fa0;
  --subtle: rgba(255, 255, 255, 0.16);      /* tracks, dots, hover */
  --selected-bg: rgba(255, 201, 77, 0.16);  /* selected category card */
  --selected-ring: rgba(255, 201, 77, 0.25);
  --overlay: rgba(10, 6, 24, 0.75);         /* pause backdrop */

  --font-display: "Fredoka", "Nunito", system-ui, sans-serif;
  --font-ui: "Nunito", system-ui, sans-serif;
  --radius: clamp(14px, 1.4vw, 32px);
  --gutter: clamp(16px, 2.5vw, 64px);

  /* Pico overrides */
  --pico-font-family: var(--font-ui);
  --pico-background-color: transparent;
  --pico-color: var(--fg);
}

/* The default theme's pink warn colour needs dark banner text (7.2:1; white is 2.7:1). */
html[data-ordleg-theme="default"] { --timer-warn-fg: #1a0508; }

[x-cloak] { display: none !important; }

html, body { height: 100%; }
html.hide-cursor, html.hide-cursor * { cursor: none !important; }

body {
  margin: 0;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: clamp(16px, 1.15vw, 34px);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; }

/* Theme decoration layer. Themes style .theme-deco and its three spans
 * (edges/corners only). Empty by default. */
.theme-deco {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.theme-deco > span { position: absolute; display: block; }

body { transition: background 0.6s ease; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  padding: var(--gutter);
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- Start ---------- */
.start-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1em 2em;
  margin-bottom: 0.9em;
}
.brand { justify-self: start; }
.header-tools { justify-self: end; display: flex; gap: 0.6em; }
.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 3.6vw, 7rem);
  line-height: 1;
  margin: 0;
  color: var(--accent);
  letter-spacing: 0.01em;
  text-shadow: 0 0.06em 0 rgba(0, 0, 0, 0.25);
}
.tagline { margin: 0.15em 0 0; color: var(--fg-muted); font-size: 1.1em; }

.icon-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--fg);
  border-radius: 999px;
  width: 2.6em;
  height: 2.6em;
  padding: 0;
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--subtle); }

.seg-group { display: flex; flex-wrap: wrap; gap: 0.5em; }
.seg-group.audience { justify-content: center; gap: 0.8em; }
.seg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1em;
  padding: 0.6em 1.2em;
  margin: 0;
  width: auto;
  border-radius: 999px;
  border: 2px solid var(--card-border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.seg:hover { border-color: var(--accent); }
.seg.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.seg-label { font-weight: 800; font-size: 1.05em; }
.seg-sub { font-size: 0.78em; opacity: 0.85; }
.audience .seg { padding: 0.55em 1.8em; }
.audience .seg-label { font-size: 1.35em; font-family: var(--font-display); font-weight: 600; }
.seg-compact .seg { padding: 0.6em 0.95em; }

.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5em;
  margin: 0 0 0.6em;
  color: var(--fg);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 13vw, 380px), 1fr));
  gap: clamp(10px, 1.2vw, 28px);
  flex: 1;
  align-content: start;
  margin-bottom: 1em;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25em;
  padding: 0.8em 0.7em;
  margin: 0;
  width: 100%;
  border-radius: var(--radius);
  border: 2px solid var(--card-border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.cat-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.cat-card.is-selected {
  border-color: var(--accent);
  background: var(--selected-bg);
  box-shadow: 0 0 0 4px var(--selected-ring);
}
.cat-icon { font-size: 2em; line-height: 1.1; }
.cat-name { font-family: var(--font-display); font-weight: 600; font-size: 1.25em; }
.cat-desc { font-size: 0.85em; color: var(--fg-muted); line-height: 1.3; }

.setup-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1.2em 2em;
  padding: 1em 1.4em;
  border-radius: var(--radius);
  background: var(--card-strong);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
}
.setup-field { display: flex; flex-direction: column; gap: 0.4em; }
.setup-label { font-weight: 800; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); }
.setup-start { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 0.3em; }
.selected-name { margin: 0; font-family: var(--font-display); font-size: 1.2em; font-weight: 600; }
.selected-name.is-muted { color: var(--fg-muted); font-weight: 400; }
.error { margin: 0; color: var(--bad); font-weight: 700; }

.start-btn {
  margin: 0;
  width: auto;
  padding: 0.65em 2.2em;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: var(--accent-fg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.5em;
  cursor: pointer;
  box-shadow: 0 0.2em 0 rgba(0, 0, 0, 0.25);
  transition: transform 0.1s, filter 0.15s;
}
.start-btn:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-2px); }
.start-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.ctrl-btn {
  margin: 0;
  width: auto;
  padding: 0.55em 1.3em;
  border-radius: 999px;
  border: 2px solid var(--card-border);
  background: var(--card);
  color: var(--fg);
  font-weight: 700;
  font-size: 1em;
  cursor: pointer;
}
.ctrl-btn:hover { border-color: var(--fg-muted); }
kbd {
  font-family: var(--font-ui);
  font-size: 0.75em;
  padding: 0.1em 0.45em;
  margin-left: 0.4em;
  border-radius: 6px;
  background: var(--subtle);
  color: inherit;
  box-shadow: none;
}

/* ---------- Countdown ---------- */
.screen-countdown { justify-content: center; align-items: center; text-align: center; }
.countdown-hint { font-size: 2em; color: var(--fg-muted); margin: 0; }
.countdown-num {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(8rem, 30vh, 40rem);
  line-height: 1;
  margin: 0;
  color: var(--accent);
  animation: pop 1s ease-out infinite;
}
@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  25% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ---------- Play ---------- */
.screen-play { height: 100vh; height: 100dvh; overflow: hidden; cursor: pointer; }
.play-top { display: flex; align-items: center; gap: 1.5em; min-height: 6vh; }
.progress { display: flex; flex-direction: column; gap: 0.4em; }
.progress-text { font-weight: 800; font-size: 1.4em; }
.dots { display: flex; gap: 0.45em; }
.dot { width: 0.9em; height: 0.9em; border-radius: 50%; background: var(--subtle); }
.dot.is-current { background: var(--fg); box-shadow: 0 0 0 3px var(--subtle); }
.dot.is-guessed { background: var(--ok); }
.dot.is-skipped, .dot.is-timeout { background: var(--bad); }
.total-time { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--fg-muted); font-size: 1.3em; }

.timer { position: relative; width: clamp(80px, 8vw, 260px); aspect-ratio: 1; --p: 1; }
.timer svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer circle { fill: none; stroke-width: 9; }
.timer-track { stroke: var(--subtle); }
.timer-fill {
  stroke: var(--timer-ok);
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: calc(283 * (1 - var(--p)));
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}
.timer-num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 2.8vw, 6rem);
  font-variant-numeric: tabular-nums;
}
.timer.is-warn .timer-fill { stroke: var(--timer-warn); }
.timer.is-warn .timer-num { color: var(--timer-warn); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }

.word-area { flex: 1; display: grid; place-items: center; position: relative; min-height: 0; }
.word-card {
  width: min(100%, 92vw);
  box-sizing: border-box;
  padding: clamp(24px, 4vh, 96px) clamp(16px, 3vw, 80px);
  border-radius: calc(var(--radius) * 1.5);
  background: var(--card-strong);
  border: 1px solid var(--card-border);
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.35);
  text-align: center;
}
.word-card.enter { animation: word-in 0.3s ease-out; }
@keyframes word-in {
  from { opacity: 0; transform: translateY(3vh) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.word {
  display: inline-block;
  white-space: nowrap;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(3.5rem, 12vw, 28rem);
  line-height: 1.1;
  color: var(--fg);
}
.taboo { margin-top: clamp(16px, 3vh, 64px); }
.taboo-title {
  margin: 0 0 0.6em;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--taboo);
  font-size: clamp(1rem, 1.6vw, 3.5rem);
}
.taboo-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em 0.6em;
}
.taboo-chip {
  list-style: none;
  margin: 0;
  padding: 0.2em 0.8em 0.2em 0.6em;
  border-radius: 999px;
  border: 2px solid var(--taboo);
  background: var(--taboo-bg);
  font-weight: 800;
  font-size: clamp(1.6rem, 3.5vw, 8rem);
  line-height: 1.25;
}
.taboo-chip::before { content: "🚫"; font-size: 0.7em; margin-right: 0.35em; vertical-align: 0.1em; }

.timeout-banner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-4deg);
  padding: 0.3em 1em;
  border-radius: var(--radius);
  background: var(--timer-warn);
  color: var(--timer-warn-fg);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.5rem, 7vw, 16rem);
  box-shadow: 0 2vh 6vh rgba(0, 0, 0, 0.45);
  animation: shake 0.5s ease-in-out;
  white-space: nowrap;
}
@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(-4deg); }
  25% { transform: translate(-52%, -50%) rotate(-6deg); }
  75% { transform: translate(-48%, -50%) rotate(-2deg); }
}

.play-bottom { display: flex; align-items: center; gap: 1em; min-height: 5vh; }
.play-hint { margin: 0 auto; color: var(--fg-muted); font-size: 1.1em; text-align: center; }
.ctrl-right { display: flex; gap: 0.6em; align-items: center; }

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--overlay);
  backdrop-filter: blur(8px);
  z-index: 10;
  cursor: default;
}
.overlay-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8em;
  padding: 2em 3em;
  border-radius: var(--radius);
  background: var(--card-strong);
  border: 1px solid var(--card-border);
  text-align: center;
}
.overlay-card h2 { font-family: var(--font-display); font-size: 3em; margin: 0; color: var(--fg); }
.overlay-card p { margin: 0 0 0.5em; color: var(--fg-muted); }

/* ---------- Results ---------- */
.screen-results { align-items: center; text-align: center; gap: 0.6em; }
.results-cat { margin: 0; color: var(--fg-muted); font-size: 1.3em; font-weight: 700; }
.results-message {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.2rem, 4.5vw, 10rem);
  color: var(--accent);
}
.results-stats { display: flex; gap: clamp(16px, 3vw, 80px); margin: 0.4em 0 0.8em; }
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.6em 1.6em;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
}
.stat-label { font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-muted); font-size: 0.9em; }
.stat-value {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 4vw, 9rem);
  font-variant-numeric: tabular-nums;
}
.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(100%, 1600px);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-flow: column;
  grid-template-rows: repeat(5, auto);
  gap: 0.5em 1.5em;
}
.result-row {
  list-style: none;
  margin: 0;
  display: grid;
  grid-template-columns: 1.6em 1fr auto auto;
  align-items: center;
  gap: 0.8em;
  padding: 0.5em 1em;
  border-radius: calc(var(--radius) * 0.7);
  background: var(--card);
  text-align: left;
  font-size: 1.15em;
}
.r-icon { font-weight: 800; font-size: 1.2em; text-align: center; }
.r-word { font-family: var(--font-display); font-weight: 600; font-size: 1.15em; }
.r-label { color: var(--fg-muted); font-size: 0.85em; }
.r-time { font-variant-numeric: tabular-nums; color: var(--fg-muted); }
.is-guessed .r-icon { color: var(--ok); }
.is-skipped .r-icon, .is-timeout .r-icon { color: var(--bad); }
.results-actions { display: flex; gap: 1em; margin-top: 1em; align-items: center; }

.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 20;
}

.noscript { padding: 2em; text-align: center; }

/* ---------- Smaller screens ---------- */
/* Short screens (laptops, 720p): a sticky bar would hide the cards */
@media (max-height: 900px) {
  .setup-bar { position: static; }
}

@media (max-width: 1100px) {
  .start-header { grid-template-columns: 1fr auto; }
  .start-header .audience { grid-column: 1 / -1; grid-row: 2; }
}

@media (max-width: 800px) {
  .setup-start { margin-left: 0; align-items: stretch; width: 100%; }
  .results-list { grid-template-columns: 1fr; grid-auto-flow: row; grid-template-rows: none; }
  .play-hint { display: none; }
  .play-bottom { justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
