/* DegenParty shared design system - dark + yellow quiz style.
   Loaded on every page via <link rel="stylesheet" href="/theme.css">. The
   :root values here are the built-in defaults (the slate+yellow palette);
   /branding.js overrides them at runtime with the admin's saved theme, so a
   page looks right even before that fetch lands or if it fails.

   Color tokens are admin-editable (Branding panel → palette). Shape/line tokens
   are fixed. Canvas game art is NOT themed - it draws its own colors. */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');

:root {
  /* surfaces */
  --bg:          #181B22;   /* page base */
  --surface:     #2A2F3A;   /* cards, rows */
  --raised:      #333947;   /* inputs, chips, progress track */

  /* accent (actions / "you" only) */
  --primary:     #F0E14C;
  --on-primary:  #1B1F27;   /* text on primary */
  /* primary as raw "r, g, b" so pages can build translucent accent tints with
     rgba(var(--accent-rgb), .18); branding.js keeps this in sync with --primary. */
  --accent-rgb:  240, 225, 76;

  /* buttons - a separate, editable colour so primary actions can be calmer than
     the bright accent. Default to the accent; the Branding panel overrides. */
  --button:        #F0E14C;
  --button-hover:  #F3E873;
  --on-button:     #1B1F27;

  /* feedback (answer states only) */
  --success:     #2FBE6E;
  --danger:      #E0524E;

  /* text */
  --text:        #FFFFFF;   /* headings */
  --text-body:   #E2E5EA;   /* body */
  --text-muted:  #9AA0AC;   /* secondary */
  --text-faint:  #6B7280;   /* metadata, counters */

  /* neutral overlays - flip with light/dark mode (see [data-mode="light"] below)
     so borders, subtle fills and inputs stay visible on any background. */
  --line:        rgba(255,255,255,0.10);   /* borders */
  --soft:        rgba(255,255,255,0.04);   /* subtle neutral fill (chips/banners/rows) */
  --soft-strong: rgba(255,255,255,0.10);   /* hover / stronger neutral fill */
  --field:       rgba(0,0,0,0.30);         /* input / select / textarea background */

  /* fixed shape (not color) */
  --radius:      12px;
  --radius-lg:   16px;
  --radius-pill: 999px;

  /* legacy aliases so pages written against the old token names keep working.
     /branding.js also re-points these at the live theme values at runtime. */
  --brand-accent: var(--primary);
  --accent:       var(--primary);
  --amber:        var(--primary);
  --panel:        var(--surface);
  --green:        var(--success);
  --red:          var(--danger);
  --muted:        var(--text-muted);
}

/* Light mode: only the neutral overlays flip (the palette colours come from the
   theme). branding.js sets data-mode on <html> from the active theme's `mode`. */
:root[data-mode="light"] {
  --line:        rgba(0,0,0,0.14);
  --soft:        rgba(0,0,0,0.035);
  --soft-strong: rgba(0,0,0,0.07);
  --field:       #ffffff;
}

/* ---- base ---------------------------------------------------------------- */
/* Opt-in body class so a page adopts the themed background + Poppins without
   colliding with its own rules. Pages also just reference the var(--*) tokens. */
body.theme-base {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-body);
  margin: 0;
}
.theme-base h1, .theme-base h2, .theme-base h3 { color: var(--text); font-weight: 600; }

/* ---- native form controls (site-wide) ------------------------------------
   Selects and - critically - their <option> popups were falling back to the
   browser's white default, leaving the dropdown LIST unreadable on the dark
   themes (the closed box was already themed; the open menu was not). These
   bare element selectors are the lowest specificity, so any page's own
   `.foo select` rule still wins; the part that matters everywhere is `option`,
   which pages virtually never style. `option`/`optgroup` need a SOLID colour
   (native popups don't composite translucent values), so they use --surface,
   not the semi-transparent --field. Every token here is theme-driven, so this
   tracks each saved theme (light or dark) automatically - no per-theme edits. */
select {
  background-color: var(--field);
  color: var(--text-body);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
option, optgroup {
  background-color: var(--surface);
  color: var(--text-body);
}

/* ---- components ----------------------------------------------------------
   NAMESPACED with `dp-` so dropping /theme.css onto an existing page never
   restyles that page's own .btn/.pill/.card/.tabs/.progress classes. Use these
   for new UI (e.g. the Branding preview); existing pages just inherit tokens. */
.dp-btn {
  background: var(--button);
  color: var(--on-button);
  font: 500 15px 'Poppins', sans-serif;
  padding: 13px 26px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  transition: background .1s;
}
.dp-btn:hover { background: var(--button-hover); }
.dp-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.dp-pill {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font: 500 14px 'Poppins', sans-serif;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.dp-pill:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); }

.dp-card { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; }

/* answer states - feedback colors live ONLY here */
.dp-answer {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--raised);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 13px 16px;
  color: var(--text-body);
}
.dp-answer--correct { background: color-mix(in srgb, var(--success) 10%, transparent); border-color: var(--success); }
.dp-answer--wrong   { background: color-mix(in srgb, var(--danger)  10%, transparent); border-color: var(--danger); }
.dp-answer__mark { width: 20px; height: 20px; border-radius: 50%; flex: 0 0 20px; }
.dp-answer--correct .dp-answer__mark { background: var(--success); }
.dp-answer--wrong   .dp-answer__mark { background: transparent; border: 2px solid var(--danger); }

/* tabs (segmented control) */
.dp-tabs { display: inline-flex; gap: 6px; background: var(--surface); border-radius: var(--radius); padding: 5px; }
.dp-tab { flex: 1; text-align: center; padding: 9px 18px; border-radius: 9px; color: var(--text-muted);
  font: 400 14px 'Poppins', sans-serif; cursor: pointer; border: none; background: transparent; }
.dp-tab--active { background: var(--primary); color: var(--on-primary); font-weight: 500; }

/* progress / XP bar */
.dp-progress { background: var(--raised); height: 10px; border-radius: var(--radius-pill); overflow: hidden; }
.dp-progress__fill { height: 100%; background: var(--primary); border-radius: var(--radius-pill); }

/* ribbon banner */
.dp-ribbon {
  display: inline-block;
  background: var(--primary);
  color: var(--on-primary);
  font: 500 14px 'Poppins', sans-serif;
  padding: 10px 22px;
  border-radius: 6px;
}

/* avatars & badges */
.dp-avatar { border-radius: 50%; object-fit: cover; }
.dp-level-badge { background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: var(--radius-pill); }

/* results / "game over" - the ONE allowed gradient */
.dp-results {
  background:
    radial-gradient(ellipse at top, color-mix(in srgb, var(--primary) 20%, transparent), transparent 60%),
    var(--surface);
}
