/* ============================================================================
   课堂答题 · COMMON — shared design system
   ----------------------------------------------------------------------------
   Design language: "Chalk & Neon"
   A live-classroom game show. Analog warmth (paper, ink, chalk) meets the
   electric energy of a quiz show. Risograph-leaning jewel tones, chunky
   tactile "sticker" buttons, heavy condensed numerals, a fine grain overlay.
   Offline-first: no webfonts / no CDN (classroom may be offline), so we build
   a *characterful* native stack with deliberate weight + tracking instead of
   defaulting to Inter.
   ========================================================================== */

:root {
  /* ---- Core ink + paper ---------------------------------------------------
     Warm desaturated indigo-charcoal as "ink"; a real paper cream as light. */
  --ink:        #17151f;   /* deepest — big-screen base */
  --ink-2:      #201d2b;   /* raised surfaces on dark */
  --ink-3:      #2c2838;   /* hover / inset on dark */
  --ink-line:   #3a3550;   /* hairlines on dark */
  --paper:      #f6f1e7;   /* student base — warm paper cream */
  --paper-2:    #fffdf8;   /* cards on paper */
  --paper-edge: #e7dfcf;   /* paper hairline */

  --fg:         #1c1925;   /* primary text on paper */
  --fg-soft:    #5b5566;   /* secondary text on paper */
  --fg-faint:   #8a8394;   /* tertiary / placeholder */
  --fg-inv:     #f3eee3;   /* primary text on ink */
  --fg-inv-soft:#aaa2bd;   /* secondary text on ink */

  /* ---- Signature accents (riso) -------------------------------------------
     Coral + aqua tie the whole product together. */
  --coral:      #ff5a5f;   /* primary brand accent */
  --coral-deep: #e63e54;
  --aqua:       #16c8c8;   /* secondary accent / focus */
  --aqua-deep:  #0f9d9d;
  --gold:       #ffb23e;   /* highlights, points */

  /* ---- Kahoot four-color answer system (jewel, not candy) -----------------
     Each gets a paired "deep" tone for the tactile button underside, plus a
     glyph so color is never the only cue. */
  --o0:         #f04b56;   --o0-deep: #c0303c;   /* ▲ red    */
  --o1:         #2f7df6;   --o1-deep: #1e5ed1;   /* ◆ blue   */
  --o2:         #f5b327;   --o2-deep: #cf8f0e;   /* ● gold   */
  --o3:         #29b46b;   --o3-deep: #1c8c52;   /* ■ green  */
  --o4:         #8a63e8;   --o4-deep: #6c46c6;   /* ✦ violet (5th+) */
  --o5:         #ff8a3d;   --o5-deep: #d96a1e;   /* ✚ orange (6th)  */

  /* True / False */
  --yes:        #29b46b;   --yes-deep: #1c8c52;  /* 对 ✓ */
  --no:         #f04b56;   --no-deep:  #c0303c;  /* 错 ✗ */

  /* ---- State semantics ---- */
  --correct:    #2fbd72;
  --correct-soft: #d9f3e5;
  --wrong:      #ef5560;
  --wrong-soft: #fbe2e4;

  /* ---- Type --------------------------------------------------------------- */
  /* Display: lean on heavy grotesques that ship on the platform; SF on Apple,
     Segoe on Windows, then condensed/CJK fallbacks. */
  --font-display: "Avenir Next", "Helvetica Neue",
                  "PingFang SC", "Hiragino Sans GB",
                  "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  /* Body: humanist + CJK-friendly. */
  --font-body:    -apple-system, BlinkMacSystemFont,
                  "PingFang SC", "Hiragino Sans GB",
                  "Microsoft YaHei", "Segoe UI", Roboto, system-ui, sans-serif;
  /* Numerals / countdown — same family but used at extreme weight + tracking. */
  --font-num:     "SF Pro Display", "Avenir Next", "Helvetica Neue",
                  "PingFang SC", system-ui, sans-serif;

  /* ---- Spacing scale (8pt-ish, with a couple of in-betweens) ---- */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px;

  /* ---- Radii ---- */
  --r-sm: 10px; --r-md: 16px; --r-lg: 24px; --r-xl: 32px; --r-pill: 999px;

  /* ---- Tactile shadow tokens (hard "sticker" offsets) ---- */
  --lift:   0 2px 0 rgba(0,0,0,.18);
  --press:  0 1px 0 rgba(0,0,0,.20);
  --float:  0 18px 40px -18px rgba(28,22,40,.45);
  --float-dark: 0 24px 60px -20px rgba(0,0,0,.6);

  /* ---- Motion ---- */
  --ease-out:  cubic-bezier(.22,.61,.36,1);
  --ease-back: cubic-bezier(.34,1.56,.64,1);   /* gentle overshoot */
  --ease-soft: cubic-bezier(.4,0,.2,1);
}

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

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

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "tnum" 1, "ss01" 1;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }

img { max-width: 100%; display: block; }

button {
  font-family: var(--font-body);
  font-size: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

input {
  font-family: var(--font-body);
  font-size: inherit;
  color: inherit;
}

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

/* Hide native number-input spinners (used in the bank time field) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ---------------------------------------------------------------------------
   Shared utility: fine grain overlay (riso paper feel).
   Applied per-view via .grain so each surface picks its own blend.
   ------------------------------------------------------------------------- */
.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: .035;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ---------------------------------------------------------------------------
   Shared button primitive — a chunky tactile "sticker" button.
   Pages opt in with .btn; modifiers below. The hard offset shadow + downward
   translate on :active gives a satisfying physical "press".
   ------------------------------------------------------------------------- */
.btn {
  --btn-bg: var(--ink-2);
  --btn-fg: var(--fg-inv);
  --btn-edge: rgba(0,0,0,.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 14px 22px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .01em;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border-radius: var(--r-pill);
  box-shadow: 0 4px 0 var(--btn-edge);
  transition: transform .08s var(--ease-out),
              box-shadow .08s var(--ease-out),
              filter .15s var(--ease-out);
}
.btn:hover { filter: brightness(1.06); }
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--btn-edge);
}
.btn-primary {
  --btn-bg: var(--coral);
  --btn-fg: #fff;
  --btn-edge: var(--coral-deep);
}
.btn-accent {
  --btn-bg: var(--aqua);
  --btn-fg: #04302f;
  --btn-edge: var(--aqua-deep);
}

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