/* ============================================================================
   Лучик — дизайн-система.
   Три режима подачи в одном имени: mode-young (малыши), mode-mid (5–8 класс),
   mode-teen (Лучик: Лицей, 9–11). Переключаются классом на <html>.
   ========================================================================== */

/* ---------- Токены: общие ---------- */
:root {
  --font: 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-play: 'Balsamiq Sans', 'Nunito', cursive;

  --sun-1: #FFC53D;
  --sun-2: #FF8A3D;
  --sun-3: #FF6B4A;

  --r-card: 22px;
  --r-btn: 16px;
  --r-chip: 999px;
  --tap: 48px;

  --shadow-1: 0 2px 6px rgba(30, 22, 10, .06);
  --shadow-2: 0 10px 26px -12px rgba(30, 22, 10, .28);
  --shadow-3: 0 22px 50px -22px rgba(30, 22, 10, .38);

  --maxw: 1120px;
  --dur: .22s;
}

/* ---------- Режим «Малыш»: подготовишка – 4 класс ---------- */
html.mode-young {
  --bg: #FFF7EC;
  --bg-2: #FFEFDA;
  --surface: #FFFFFF;
  --surface-2: #FFFBF4;
  --ink: #2A2118;
  --ink-soft: #6B5B47;
  --line: #F0E2CE;
  --accent: #FF8A3D;
  --accent-ink: #FFFFFF;
  --accent-2: #4CC9F0;
  --good: #3FBF6F;
  --bad: #F4635A;
  --star: #FFC53D;
  --r-card: 26px;
  --r-btn: 20px;
  --tap: 64px;
  --fs-body: 18px;
  --fs-h1: clamp(30px, 6.4vw, 52px);
  --fs-h2: clamp(23px, 4.4vw, 34px);
}

/* ---------- Режим «Школьник»: 5–8 класс ---------- */
html.mode-mid {
  --bg: #F4F7FE;
  --bg-2: #E8EEFC;
  --surface: #FFFFFF;
  --surface-2: #FAFBFF;
  --ink: #16203A;
  --ink-soft: #5B6885;
  --line: #E1E8F7;
  --accent: #4B6BFB;
  --accent-ink: #FFFFFF;
  --accent-2: #12B886;
  --good: #12B886;
  --bad: #F0564B;
  --star: #FFB020;
  --r-card: 18px;
  --r-btn: 14px;
  --tap: 48px;
  --fs-body: 17px;
  --fs-h1: clamp(28px, 5.4vw, 46px);
  --fs-h2: clamp(21px, 3.6vw, 30px);
}

/* ---------- Режим «Лицей»: 9–11 класс ---------- */
html.mode-teen {
  --bg: #0E1220;
  --bg-2: #151A2E;
  --surface: #171D33;
  --surface-2: #1E2540;
  --ink: #E9EEFB;
  --ink-soft: #98A4C4;
  --line: #26304F;
  --accent: #7C9CFF;
  --accent-ink: #0E1220;
  --accent-2: #4ADE80;
  --good: #4ADE80;
  --bad: #FF7A7A;
  --star: #FFD166;
  --r-card: 12px;
  --r-btn: 10px;
  --tap: 44px;
  --fs-body: 16px;
  --fs-h1: clamp(26px, 4.6vw, 42px);
  --fs-h2: clamp(20px, 3.2vw, 28px);
  --shadow-2: 0 10px 26px -14px rgba(0, 0, 0, .6);
  --shadow-3: 0 22px 50px -24px rgba(0, 0, 0, .75);
}

/* ---------- База ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(900px 500px at 12% -8%, var(--bg-2) 0, transparent 60%),
    radial-gradient(700px 420px at 92% 2%, var(--bg-2) 0, transparent 55%);
  background-attachment: fixed;
  min-height: 100vh;
}
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.12; margin: 0 0 .4em; letter-spacing: -.02em; font-weight: 900; }
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }
.muted { color: var(--ink-soft); }
.center { text-align: center; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }

/* Малышовое настроение: заголовки «рукописные» */
html.mode-young h1, html.mode-young h2, html.mode-young h3,
html.mode-young .btn, html.mode-young .chip { font-family: var(--font-play); }
html.mode-young h1 { letter-spacing: .005em; }

/* ---------- Кнопки ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--ink);
  --btn-edge: var(--line);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 22px;
  font: inherit; font-weight: 800; font-size: 1rem;
  color: var(--btn-ink); background: var(--btn-bg);
  border: 2px solid var(--btn-edge); border-radius: var(--r-btn);
  box-shadow: 0 4px 0 0 var(--btn-edge);
  cursor: pointer; user-select: none; text-decoration: none;
  transition: transform var(--dur), box-shadow var(--dur), background var(--dur);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 0 var(--btn-edge); }
.btn--primary {
  --btn-bg: var(--accent); --btn-ink: var(--accent-ink);
  --btn-edge: color-mix(in srgb, var(--accent) 62%, #000);
  background-image: linear-gradient(180deg, rgba(255,255,255,.18), rgba(255,255,255,0));
}
html.mode-young .btn--primary {
  --btn-bg: var(--sun-2); --btn-edge: #C9541F;
  background-image: linear-gradient(180deg, var(--sun-1), var(--sun-2));
}
.btn--ghost { --btn-bg: transparent; --btn-edge: var(--line); box-shadow: none; }
.btn--ghost:hover { background: var(--surface); }
.btn--good { --btn-bg: var(--good); --btn-ink: #fff; --btn-edge: color-mix(in srgb, var(--good) 65%, #000); }
.btn--bad { --btn-bg: var(--bad); --btn-ink: #fff; --btn-edge: color-mix(in srgb, var(--bad) 65%, #000); }
.btn--lg { min-height: calc(var(--tap) + 14px); font-size: 1.12rem; padding: 0 30px; }
.btn--sm { min-height: 38px; font-size: .9rem; padding: 0 14px; box-shadow: 0 3px 0 0 var(--btn-edge); }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Карточки, чипы ---------- */
.card {
  background: var(--surface); border: 2px solid var(--line);
  border-radius: var(--r-card); box-shadow: var(--shadow-2); padding: 20px;
}
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 14px; border-radius: var(--r-chip);
  background: var(--surface); border: 2px solid var(--line);
  font-weight: 800; font-size: .9rem; white-space: nowrap;
}
.chip--accent { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

/* ---------- Прогресс ---------- */
.bar { height: 14px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--sun-1), var(--sun-2)); transition: width .45s ease; }
html.mode-mid .bar > i, html.mode-teen .bar > i { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }

/* ---------- Звёзды и лучики ---------- */
.stars { display: inline-flex; gap: 3px; font-size: 1.1em; }
.stars .on { color: var(--star); }
.stars .off { color: var(--line); }

/* ---------- Маскот Лучик ---------- */
.luchik { display: block; width: 100%; height: auto; overflow: visible; }
.luchik .ray { transform-origin: 50px 50px; animation: rayPulse 3.4s ease-in-out infinite; }
.luchik .ray:nth-child(2n) { animation-delay: .5s; }
.luchik .ray:nth-child(3n) { animation-delay: 1.1s; }
.luchik .eye { transition: transform .2s; }
.luchik--cheer .face { animation: hop .6s ease; }
.luchik--think .brow { transform: translateY(-2px); }
.luchik--sad .mouth { transform: translateY(2px); }
@keyframes rayPulse { 0%,100% { transform: scale(1); opacity: .95; } 50% { transform: scale(1.09); opacity: 1; } }
@keyframes hop { 0%,100% { transform: translateY(0); } 40% { transform: translateY(-7px); } }

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

/* ---------- Служебные блоки ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-weight: 800;
  padding: 12px 20px; border-radius: var(--r-chip); box-shadow: var(--shadow-3);
  z-index: 80; max-width: 92vw; text-align: center;
}
.coin-pop {
  position: fixed; z-index: 90; font-weight: 900; font-size: 1.4rem; color: var(--sun-3);
  pointer-events: none; animation: coinUp 1.1s ease forwards; text-shadow: 0 2px 0 #fff8;
}
@keyframes coinUp { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-58px) scale(1.15); } }

/* ---------- Фрагменты текста заданий ---------- */
.emoji-row { display: inline-block; font-size: 1.5em; letter-spacing: .08em; margin: 6px 0; }
.emoji-row.big { font-size: 2.1em; display: block; margin: 10px 0; }
.shape-box { display: flex; justify-content: center; margin: 12px 0; }
.shape-box svg.shape { width: 132px; height: 132px; fill: var(--accent-2); stroke: var(--ink); stroke-width: 2.5; }
.frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center;
  font-size: .78em; line-height: 1.05; margin: 0 3px; }
.frac i { font-style: normal; padding: 0 4px; }
.frac i:first-child { border-bottom: 2px solid currentColor; }
.gap { display: inline-block; min-width: 1.2em; text-align: center; color: var(--accent); }
