/* =========================================================================
   QUIZZE! GAME — Shared Design System (theme.css)
   Self-contained. No external resources. System fonts only.
   Consumed by the player page and the admin page via <link>.
   ========================================================================= */

/* ----------------------------------------------------------------------- *
 * Design tokens — EXACT contract. Consumers reference these.              *
 * ----------------------------------------------------------------------- */
:root {
  --c-blue: #4453d6;
  --c-purple: #7b3fe4;
  --c-violet: #9a4ae0;

  --bg-grad: linear-gradient(140deg, #4453d6 0%, #7b3fe4 55%, #9a4ae0 100%);
  --accent-grad: linear-gradient(135deg, #ff8a5b 0%, #ff5670 100%);

  --accent: #ff6b6b;
  --gold: #ffc83d;
  --green: #3ddc97;
  --red: #ff5670;

  --card-glass: rgba(255, 255, 255, 0.12);
  --card-white: #ffffff;

  --navy: #2b2f6b;
  --navy-pill: rgba(28, 28, 74, 0.55);

  --text: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.78);
  --text-dark: #2b2f6b;

  --radius: 24px;
  --radius-sm: 16px;
  --radius-pill: 999px;

  --shadow-card: 0 18px 40px rgba(20, 16, 80, 0.35);
  --shadow-btn: 0 10px 22px rgba(255, 86, 112, 0.45);

  --font-display: "Arial Black", "Helvetica Neue", Helvetica, system-ui, sans-serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ----------------------------------------------------------------------- *
 * Reset-ish base                                                          *
 * ----------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  /* Ta bort systemets ljusa "tap flash" på mobil (annars blinkar det vitt
   * när man trycker på kort/listor som inte själva nollställt highlighten). */
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  min-height: 100%;
  /* EN solid lila färg på roten — medvetet INGEN gradient. Då finns ingen
   * gradientkant som kan skilja sig från iOS overscroll-studsen, så
   * bakgrunden är identisk åt alla håll (ingen skarv/"hack"). Root-bakgrunden
   * målas längst bak, så glyf-lagren (body::before/::after) syns ovanpå. */
  background: #5a47dd;
}

/* ----------------------------------------------------------------------- *
 * Body — diagonal gradient + scattered floating geometric glyphs          *
 * ----------------------------------------------------------------------- */
body {
  margin: 0;
  min-height: 100vh;
  /* Bakgrunden ligger på roten (html) så glyf-lagren syns ovanpå den.
   * Body är genomskinlig. */
  background: transparent;
  font-family: var(--font-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/*
 * Glyph layer: a fixed full-viewport pseudo element tiled with an inline
 * SVG data-URI containing PlayStation-style shapes (triangle, circle,
 * square, X, plus) drawn in white at low opacity. A second layer (::after)
 * is offset and counter-animated for parallax-ish depth.
 */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: -10%;
  z-index: -1;
  pointer-events: none;
  background-repeat: repeat;
}

body::before {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='320' height='320' viewBox='0 0 320 320'><g fill='none' stroke='%23ffffff' stroke-width='3' stroke-linejoin='round' stroke-linecap='round' opacity='0.11'><polygon points='52,30 76,72 28,72'/><circle cx='240' cy='54' r='22'/><rect x='150' y='118' width='40' height='40' rx='6'/><path d='M40 200 l30 30 M70 200 l-30 30'/><path d='M250 210 v40 M230 230 h40'/><circle cx='110' cy='250' r='16'/><polygon points='270,140 290,176 250,176'/><rect x='40' y='118' width='30' height='30' rx='5'/><path d='M200 280 l24 24 M224 280 l-24 24'/></g></svg>");
  background-size: 320px 320px;
  background-position: 0 0;
  opacity: 0.9;
}

body::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='360' height='360' viewBox='0 0 360 360'><g fill='%23ffffff' opacity='0.08'><circle cx='60' cy='80' r='9'/><rect x='280' y='40' width='26' height='26' rx='5' transform='rotate(18 293 53)'/><polygon points='180,40 198,74 162,74'/><circle cx='320' cy='200' r='7'/><rect x='90' y='220' width='22' height='22' rx='4' transform='rotate(-12 101 231)'/><polygon points='300,290 318,324 282,324'/><circle cx='200' cy='300' r='10'/><g stroke='%23ffffff' stroke-width='3' fill='none' stroke-linecap='round'><path d='M150 160 v26 M137 173 h26'/><path d='M40 300 l18 18 M58 300 l-18 18'/></g></g></svg>");
  background-size: 360px 360px;
  background-position: 80px 120px;
  opacity: 0.85;
}

@keyframes glyphFloat {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(14px, -22px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@keyframes glyphFloat2 {
  0%   { transform: translate3d(0, 0, 0); }
  50%  { transform: translate3d(-18px, 16px, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

/* ----------------------------------------------------------------------- *
 * App shell — phone-like centered column                                  *
 * ----------------------------------------------------------------------- */
.app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 22px 18px calc(28px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ----------------------------------------------------------------------- *
 * Display headings & wordmark                                             *
 * ----------------------------------------------------------------------- */
.display,
.display-xl,
.brand {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 900;
  text-transform: uppercase;
  line-height: 1.02;
  margin: 0;
}

.display {
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  letter-spacing: 0.5px;
  text-shadow: 0 4px 0 rgba(20, 16, 80, 0.25), 0 12px 26px rgba(20, 16, 80, 0.35);
}

.display-xl {
  font-size: clamp(2.4rem, 12vw, 3.8rem);
  letter-spacing: 1px;
  text-shadow: 0 5px 0 rgba(20, 16, 80, 0.28), 0 16px 34px rgba(20, 16, 80, 0.45);
}

.brand {
  font-size: clamp(1.4rem, 6vw, 2rem);
  letter-spacing: 0.5px;
  color: var(--text);
  text-shadow: 0 3px 0 rgba(20, 16, 80, 0.25), 0 10px 22px rgba(20, 16, 80, 0.35);
}

/* ----------------------------------------------------------------------- *
 * Keycap tiles (e.g. game PIN letters)                                    *
 * ----------------------------------------------------------------------- */
.tiles {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
}

.tile {
  width: clamp(34px, 11vw, 44px);
  height: clamp(34px, 11vw, 44px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-white);
  color: var(--text-dark);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(1rem, 4.5vw, 1.4rem);
  border-radius: 12px;
  border-bottom: 4px solid rgba(43, 47, 107, 0.22);
  box-shadow: 0 6px 14px rgba(20, 16, 80, 0.28);
  text-transform: uppercase;
  user-select: none;
}

/* ----------------------------------------------------------------------- *
 * Cards                                                                   *
 * ----------------------------------------------------------------------- */
.card {
  background: var(--card-glass);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px;
  color: var(--text);
}

.card--white {
  background: var(--card-white);
  color: var(--text-dark);
  border-color: rgba(43, 47, 107, 0.08);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.card--accent {
  background: var(--accent-grad);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: var(--shadow-card), var(--shadow-btn);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/* ----------------------------------------------------------------------- *
 * Buttons                                                                 *
 * ----------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px;
  border: none;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  background: var(--navy-pill);
  transition: transform 0.12s ease, box-shadow 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(2px);
}

.btn:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

.btn--primary {
  background: var(--accent-grad);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  box-shadow: var(--shadow-btn);
}

.btn--primary:hover {
  box-shadow: 0 14px 28px rgba(255, 86, 112, 0.55);
}

.btn--secondary {
  background: var(--navy-pill);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.btn--block {
  width: 100%;
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.25);
  box-shadow: none;
}

.btn:disabled:active,
.btn.is-disabled:active {
  transform: none;
}

/* ----------------------------------------------------------------------- *
 * Form fields                                                             *
 * ----------------------------------------------------------------------- */
.field {
  position: relative;
  width: 100%;
}

.field__icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  line-height: 1;
  color: rgba(43, 47, 107, 0.55);
  pointer-events: none;
  user-select: none;
}

.input {
  width: 100%;
  padding: 14px 18px;
  background: var(--card-white);
  color: var(--text-dark);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(20, 16, 80, 0.18);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  -webkit-appearance: none;
  appearance: none;
}

/* When a .field__icon is present, give room on the left. */
.field .input {
  padding-left: 44px;
}

.input::placeholder {
  color: rgba(43, 47, 107, 0.5);
  font-weight: 500;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 107, 0.28), 0 6px 16px rgba(20, 16, 80, 0.18);
}

/* ----------------------------------------------------------------------- *
 * Pill label                                                              *
 * ----------------------------------------------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--navy-pill);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ----------------------------------------------------------------------- *
 * Circular coral badge (timer / score)                                    *
 * ----------------------------------------------------------------------- */
.badge {
  width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-grad);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.6rem;
  border-radius: 50%;
  box-shadow: var(--shadow-btn), inset 0 -3px 8px rgba(20, 16, 80, 0.18);
  border: 3px solid rgba(255, 255, 255, 0.35);
  user-select: none;
}

/* ----------------------------------------------------------------------- *
 * Progress bar                                                            *
 * ----------------------------------------------------------------------- */
.progress {
  width: 100%;
  height: 14px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: inset 0 2px 5px rgba(20, 16, 80, 0.25);
}

.progress__bar {
  height: 100%;
  width: 0%;
  background: var(--accent-grad);
  border-radius: var(--radius-pill);
  box-shadow: 0 0 12px rgba(255, 86, 112, 0.6);
  transition: width 0.4s ease;
}

/* ----------------------------------------------------------------------- *
 * Answer options                                                          *
 * ----------------------------------------------------------------------- */
.option {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 18px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-dark);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(20, 16, 80, 0.22);
  transition: transform 0.12s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

/* Bara på enheter med riktig hover (mus). På touch "fastnar" :hover efter
 * tryck och ger en laggig efter-animation. */
@media (hover: hover) {
  .option:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 26px rgba(20, 16, 80, 0.3);
  }
}

.option:active {
  transform: translateY(1px);
}

.option:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.option__key {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1rem;
  border-radius: 50%;
  text-transform: uppercase;
}

.option--selected {
  background: rgba(255, 138, 91, 0.18);
  border-color: var(--accent);
}

.option--selected .option__key {
  background: var(--accent);
}

.option--correct {
  background: rgba(61, 220, 151, 0.2);
  border-color: var(--green);
}

.option--correct .option__key {
  background: var(--green);
  color: var(--text-dark);
}

.option--wrong {
  background: rgba(255, 86, 112, 0.18);
  border-color: var(--red);
}

.option--wrong .option__key {
  background: var(--red);
}

.option:disabled {
  cursor: not-allowed;
  opacity: 0.75;
  transform: none;
  box-shadow: 0 6px 14px rgba(20, 16, 80, 0.18);
}

/* ----------------------------------------------------------------------- *
 * Leaderboard                                                             *
 * ----------------------------------------------------------------------- */
.leader {
  display: flex;
  flex-direction: column;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.leader-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(20, 16, 80, 0.2);
}

.leader-row--me {
  background: rgba(255, 138, 91, 0.2);
  border: 2px solid var(--accent);
  box-shadow: 0 8px 20px rgba(255, 86, 112, 0.35);
}

.rank {
  flex: 0 0 auto;
  min-width: 26px;
  font-family: var(--font-display);
  font-weight: 900;
  font-style: italic;
  font-size: 1.1rem;
  text-align: center;
  color: var(--text-muted);
}

.medal {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.85rem;
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 -2px 4px rgba(20, 16, 80, 0.25), 0 2px 6px rgba(20, 16, 80, 0.25);
}

.medal--gold {
  background: var(--gold);
}

.medal--silver {
  background: #c9d2e3;
}

.medal--bronze {
  background: #d79a6a;
}

/* ----------------------------------------------------------------------- *
 * Circular play button with coral triangle                                *
 * ----------------------------------------------------------------------- */
.play-btn {
  width: 72px;
  height: 72px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-white);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(20, 16, 80, 0.35);
  transition: transform 0.12s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.play-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 16px 34px rgba(20, 16, 80, 0.42);
}

.play-btn:active {
  transform: scale(0.97);
}

.play-btn:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

/* CSS triangle, nudged right to optically center inside the circle. */
.play-btn::before {
  content: "";
  width: 0;
  height: 0;
  margin-left: 6px;
  border-style: solid;
  border-width: 13px 0 13px 22px;
  border-color: transparent transparent transparent var(--accent);
}

/* ----------------------------------------------------------------------- *
 * Helpers                                                                 *
 * ----------------------------------------------------------------------- */
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.center {
  text-align: center;
}

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

.hidden {
  display: none !important;
}

/* ----------------------------------------------------------------------- *
 * Spinner                                                                 *
 * ----------------------------------------------------------------------- */
.spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--text);
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------------- *
 * Reduced-motion: disable all decorative/loop animation                   *
 * ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  body::before,
  body::after,
  .spinner,
  .progress__bar,
  .play-btn,
  .option,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}

/* ----------------------------------------------------------------------- *
 * Mobile hardening — never overflow the column; tighten on tiny phones    *
 * ----------------------------------------------------------------------- */
img,
svg,
video {
  max-width: 100%;
  height: auto;
}

/* Long unbroken strings wrap instead of pushing the layout wider. */
.display,
.display-xl,
.brand,
.card,
.option,
.review-question,
.review-answer {
  overflow-wrap: anywhere;
}

@media (max-width: 380px) {
  .app {
    padding-left: 14px;
    padding-right: 14px;
    gap: 14px;
  }
  .card {
    padding: 16px;
  }
}
