/* Дроби по шагам — палитра и шрифты взяты у сайта «Траектории» */
:root {
  color-scheme: light;
  --ink: #0f100d;
  --ink-2: #2b2d27;
  --muted: #6c7067;
  --faint: #9b9f95;
  --line: #e8e9e3;
  --paper: #ffffff;
  --sand: #f5f5f0;

  --lime: #c8f169;
  --lime-deep: #a6d93b;
  --lime-ink: #2f4a00;
  --sky: #e7f0ff;
  --sky-deep: #3d73e8;
  --mint: #e5f6e3;
  --mint-ink: #1d6b2a;
  --lilac: #efe9ff;
  --lilac-deep: #7a5cf0;
  --peach: #ffeedd;
  --peach-deep: #e66a1f;
  --butter: #fff5d1;
  --butter-ink: #7a5600;
  --rose: #ffe7e7;
  --rose-deep: #d63b3b;

  --fill: #7a5cf0;          /* закрашенная доля */
  --fill-2: #3d73e8;        /* вторая дробь при сравнении */

  --r-card: 28px;
  --r-tile: 20px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  --display: "Unbounded", ui-sans-serif, system-ui, sans-serif;
  --sans: "Onest", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sand);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}
main { flex: 1; outline: none; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.03em; line-height: 1.12; margin: 0; }
p { margin: 0; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--lime); }
:focus-visible { outline: 3px solid var(--sky-deep); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }

/* ── Шапка ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px;
  background: rgb(245 245 240 / 0.86);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent;
}
@media (min-width: 720px) { .topbar { padding: 14px 28px; } }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: var(--lime);
  transition: transform .5s var(--spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { font: 700 16px/1 var(--display); letter-spacing: -0.03em; }
.brand-by { font-size: 13px; color: var(--muted); text-align: right; }
@media (max-width: 420px) { .brand-by { display: none; } }

/* ── Общие элементы ───────────────────────────────── */
.card { background: var(--paper); border-radius: var(--r-card); padding: 22px; }
@media (min-width: 720px) { .card { padding: 32px; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 24px;
  border: 0; border-radius: 999px;
  font-weight: 600; font-size: 16px; text-decoration: none;
  background: var(--ink); color: #fff;
  transition: transform .2s var(--ease), background-color .2s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-lime { background: var(--lime); color: var(--ink); }
.btn-lime:hover { background: var(--lime-deep); }
.btn-ghost { background: var(--paper); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { box-shadow: inset 0 0 0 1.5px var(--ink); }
.btn-sm { min-height: 42px; padding: 0 18px; font-size: 15px; }
.btn svg { width: 18px; height: 18px; flex: none; }

.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.linkbtn:hover { color: var(--ink); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--paper); font-size: 13px; font-weight: 500; color: var(--ink-2);
}
.eyebrow { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.fade-in { animation: rise .7s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-5px); } 40%, 60% { transform: translateX(5px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── Главная ──────────────────────────────────────── */
.hero { padding: 28px 0 8px; }
@media (min-width: 720px) { .hero { padding: 56px 0 16px; } }
.hero-grid { display: grid; gap: 28px; align-items: center; }
@media (min-width: 900px) { .hero-grid { grid-template-columns: 1.15fr .85fr; gap: 48px; } }
.hero h1 { font-size: clamp(32px, 7.4vw, 60px); font-weight: 700; }
.hero h1 mark { background: var(--lime); padding: 0 .12em; border-radius: .18em; color: inherit; }
.hero-lead { margin-top: 18px; font-size: clamp(17px, 2.2vw, 20px); color: var(--ink-2); max-width: 34em; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; align-items: center; }
.hero-cta .note { font-size: 14px; color: var(--muted); }

.hero-art { position: relative; aspect-ratio: 1 / .86; border-radius: var(--r-card); background: var(--lilac); overflow: hidden; }
.hero-art svg { display: block; width: 100%; height: auto; }
.hero-art .pie { position: absolute; width: 42%; left: 9%; top: 9%; animation: float 6s ease-in-out infinite; --r: -6deg; }
.hero-art .bar { position: absolute; width: 74%; right: 8%; bottom: 11%; animation: float 7s ease-in-out infinite .6s; --r: 3deg; }
.hero-art .tag {
  position: absolute; right: 9%; top: 14%;
  background: var(--paper); border-radius: 18px; padding: 12px 16px;
  font: 700 22px/1 var(--display); box-shadow: 0 12px 30px -12px rgb(15 16 13 / .25);
  animation: float 5s ease-in-out infinite .3s; --r: 4deg;
}
.hero-art .tag .eq { color: var(--lilac-deep); }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(var(--r, 0deg)); } 50% { transform: translateY(-10px) rotate(var(--r, 0deg)); } }

.section { padding: 28px 0; }
@media (min-width: 720px) { .section { padding: 44px 0; } }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.section-head h2 { font-size: clamp(24px, 4vw, 34px); }
.section-head p { color: var(--muted); max-width: 30em; }

.how { display: grid; gap: 12px; }
@media (min-width: 720px) { .how { grid-template-columns: repeat(3, 1fr); } }
.how .card { display: flex; flex-direction: column; gap: 10px; }
.how .num { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; font: 700 15px var(--display); }
.how h3 { font-size: 18px; }
.how p { color: var(--ink-2); }

/* Маршрут из станций */
.route { display: grid; gap: 12px; counter-reset: st; }
@media (min-width: 640px) { .route { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 980px) { .route { grid-template-columns: repeat(3, 1fr); } }
.station {
  position: relative; display: flex; flex-direction: column; gap: 12px;
  text-align: left; border: 0; padding: 22px; border-radius: var(--r-tile);
  background: var(--paper); color: inherit; text-decoration: none;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease);
  min-height: 190px;
}
.station:hover { transform: translateY(-3px); box-shadow: 0 18px 40px -22px rgb(15 16 13 / .35); }
.station-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.station-n { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; font: 700 16px var(--display); }
.station h3 { font-size: 19px; }
.station p { color: var(--muted); font-size: 15px; }
.station-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 500; }
.station-foot .go { display: inline-flex; align-items: center; gap: 6px; }
.station-foot .go svg { width: 16px; height: 16px; transition: transform .3s var(--ease); }
.station:hover .go svg { transform: translateX(3px); }
.station.is-next { box-shadow: inset 0 0 0 2px var(--ink); }
.station .badge-next { position: absolute; top: -10px; right: 18px; background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }

.stars { display: inline-flex; gap: 2px; }
.stars svg { width: 18px; height: 18px; }
.stars .on { color: #f2b200; }
.stars .off { color: var(--line); }

.tone-lime { background: var(--lime); }
.tone-sky { background: var(--sky); }
.tone-lilac { background: var(--lilac); }
.tone-peach { background: var(--peach); }
.tone-mint { background: var(--mint); }
.tone-butter { background: var(--butter); }

.overall { display: grid; gap: 14px; align-items: center; }
@media (min-width: 720px) { .overall { grid-template-columns: auto 1fr auto; gap: 24px; } }
.overall-num { font: 700 44px/1 var(--display); }
.overall-num small { font-size: 18px; color: var(--muted); }
.meter { height: 12px; border-radius: 99px; background: var(--sand); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--lime-deep); border-radius: inherit; transition: width .9s var(--ease); }
.overall-text { color: var(--ink-2); margin-top: 8px; }

.audience { display: grid; gap: 12px; }
@media (min-width: 720px) { .audience { grid-template-columns: repeat(2, 1fr); } }
.audience ul { margin: 12px 0 0; padding-left: 20px; color: var(--ink-2); }
.audience li + li { margin-top: 6px; }

/* ── Экран станции ─────────────────────────────────── */
.play { padding: 16px 0 40px; }
@media (min-width: 720px) { .play { padding: 28px 0 56px; } }
.play-wrap { max-width: 760px; }
.play-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.back {
  flex: none; width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: var(--paper); display: grid; place-items: center; color: var(--ink); text-decoration: none;
}
.back:hover { background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink); }
.back svg { width: 20px; height: 20px; }
.play-title { min-width: 0; }
.play-title .eyebrow { font-size: 12px; }
.play-title h1 { font-size: clamp(18px, 3.6vw, 24px); }

.dots { display: flex; gap: 6px; margin: 0 0 14px; }
.dots i { flex: 1; height: 8px; border-radius: 99px; background: rgb(15 16 13 / .08); transition: background-color .3s; }
.dots i.cur { background: var(--ink); }
.dots i.first { background: var(--lime-deep); }
.dots i.second { background: #f2b200; }
.dots i.miss { background: var(--rose-deep); }

.task { display: flex; flex-direction: column; gap: 20px; }
.task-n { font-size: 14px; color: var(--muted); font-weight: 500; }
.prompt { font-size: clamp(19px, 3vw, 23px); font-weight: 600; line-height: 1.35; }
.prompt .frac { font-size: 1.05em; }
.visual { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 16px; padding: 18px; border-radius: var(--r-tile); background: var(--sand); }
.visual svg { display: block; max-width: 100%; height: auto; }

/* Дробь в тексте: числитель над знаменателем */
.frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 .12em; font-variant-numeric: tabular-nums; }
.frac > span:first-child { border-bottom: .09em solid currentColor; padding: 0 .18em .04em; }
.frac > span:last-child { padding: .04em .18em 0; }
.frac.big { font: 700 34px/1.05 var(--display); }
.mixed { display: inline-flex; align-items: center; gap: .1em; vertical-align: middle; }

/* Ввод дроби */
.answer { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
.answer-label { font-weight: 500; color: var(--ink-2); }
.frac-input { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; }
.frac-input .line { width: 100%; height: 3px; border-radius: 3px; background: var(--ink); }
.num-input {
  width: 84px; height: 56px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--paper);
  text-align: center; font: 700 24px var(--display);
  transition: border-color .2s, box-shadow .2s;
  -moz-appearance: textfield; appearance: textfield;
}
.num-input.wide { width: 120px; }
.num-input::-webkit-outer-spin-button, .num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px rgb(200 241 105 / .7); }
.num-input:disabled { background: var(--sand); color: var(--ink-2); }
.unit { font-size: 18px; font-weight: 500; color: var(--ink-2); }
.is-wrong .num-input, .is-wrong .choices { animation: shake .45s; }

/* Выбор знака сравнения */
.choices { display: flex; gap: 10px; margin: 0 auto; }
.choice {
  width: 72px; height: 64px; border-radius: 18px; border: 2px solid var(--line); background: var(--paper);
  font: 700 28px var(--display); transition: border-color .2s, background-color .2s, transform .2s var(--ease);
}
.choice:hover:not(:disabled) { border-color: var(--ink); transform: translateY(-2px); }
.choice[aria-pressed="true"] { border-color: var(--ink); background: var(--lime); }
.choice:disabled { cursor: default; }
.compare-row { display: flex; align-items: center; justify-content: center; gap: 18px; flex-wrap: wrap; }
.compare-row .slot { width: 56px; height: 56px; border-radius: 16px; border: 2px dashed var(--faint); display: grid; place-items: center; font: 700 28px var(--display); }

/* Полоска для закрашивания */
.shade-bar { display: flex; width: 100%; max-width: 560px; height: 76px; border-radius: 16px; overflow: hidden; border: 2.5px solid var(--ink); background: var(--paper); }
.shade-bar button {
  flex: 1; min-width: 0; border: 0; padding: 0; background: transparent;
  border-right: 1.5px solid rgb(15 16 13 / .35);
  transition: background-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.shade-bar button:last-child { border-right: 0; }
.shade-bar button.group-end { border-right: 3px solid var(--ink); }
.shade-bar button:hover:not(:disabled) { background: rgb(122 92 240 / .18); }
.shade-bar button[aria-pressed="true"] { background: var(--fill); }
.shade-bar button:disabled { cursor: default; }
.shade-meta { display: flex; justify-content: space-between; width: 100%; max-width: 560px; font-size: 14px; color: var(--muted); }
.shade-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions .spacer { flex: 1; }
.kbd-hint { font-size: 13px; color: var(--faint); }
@media (hover: none) { .kbd-hint { display: none; } }

/* Подсказка и разбор */
.hint { border-radius: var(--r-tile); padding: 16px 18px; background: var(--butter); color: var(--ink-2); display: flex; gap: 12px; }
.hint svg { flex: none; width: 22px; height: 22px; color: var(--butter-ink); margin-top: 1px; }
.feedback { border-radius: var(--r-tile); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; animation: rise .5s var(--ease) both; }
.feedback h3 { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.feedback h3 .ico { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; flex: none; animation: pop .45s var(--spring) both; }
.feedback h3 .ico svg { width: 18px; height: 18px; }
.feedback .body { color: var(--ink-2); }
.feedback .body p + p { margin-top: 8px; }
.feedback .steps { margin: 6px 0 0; padding: 12px 14px; border-radius: 14px; background: rgb(255 255 255 / .7); line-height: 2.1; }
.feedback .visual { background: rgb(255 255 255 / .7); padding: 14px; }
.fb-ok { background: var(--mint); }
.fb-ok .ico { background: var(--mint-ink); color: #fff; }
.fb-almost { background: var(--butter); }
.fb-almost .ico { background: #f2b200; color: var(--ink); }
.fb-bad { background: var(--rose); }
.fb-bad .ico { background: var(--rose-deep); color: #fff; }
.fb-solution { background: var(--sky); }
.fb-solution .ico { background: var(--sky-deep); color: #fff; }

/* Вводная карточка станции */
.intro { display: flex; flex-direction: column; gap: 18px; }
.intro .rule { font-size: 18px; color: var(--ink-2); }
.intro .rule b { color: var(--ink); }
.intro .example { border-radius: var(--r-tile); background: var(--sand); padding: 18px; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; }
.intro .facts { display: flex; flex-wrap: wrap; gap: 8px; }
.intro .facts .chip { background: var(--sand); }

/* Итог станции */
.result { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.result .big-stars svg { width: 48px; height: 48px; animation: pop .5s var(--spring) both; }
.result .big-stars svg:nth-child(2) { animation-delay: .12s; }
.result .big-stars svg:nth-child(3) { animation-delay: .24s; }
.result h2 { font-size: clamp(24px, 4.4vw, 32px); }
.result .score { color: var(--ink-2); font-size: 18px; }
.result-list { text-align: left; width: 100%; display: grid; gap: 8px; margin-top: 6px; }
.result-list .row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 16px; background: var(--sand); }
.result-list .row b { font-weight: 600; }
.result-list .dot { flex: none; width: 10px; height: 10px; border-radius: 99px; margin-top: 7px; }
.result .actions { justify-content: center; margin-top: 6px; }
.tip { width: 100%; text-align: left; border-radius: var(--r-tile); padding: 16px 18px; background: var(--lilac); }
.tip b { display: block; margin-bottom: 4px; }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i { position: absolute; top: -16px; width: 10px; height: 14px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .8; } }

/* ── Подвал ───────────────────────────────────────── */
.footer { padding: 24px 0 32px; color: var(--muted); font-size: 14px; }
.footer-in { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; border-top: 1px solid var(--line); padding-top: 18px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 899px) {
  .hero-art { aspect-ratio: 16 / 10; max-width: 560px; }
  .hero-art .pie { width: 34%; }
  .hero-art .bar { width: 66%; }
}
