/* ════════════════════════════════════════════════════════════════
   evolution — terminal-lab design system
   Motion contract (Emil Kowalski rules):
   · every transition ≤ 300ms, ease-out
   · transform / opacity only
   · origin-aware where elements grow
   · high-frequency actions (lang toggle) — no animation at all
   ════════════════════════════════════════════════════════════════ */

:root {
  --bg:      #0F0D0A;
  --bg2:     #15120E;
  --panel:   #1A1612;
  --panel2:  #201B15;
  --line:    #2B261F;
  --line2:   #3D352A;
  --text:    #EFE9DD;
  --dim:     #A89B8A;
  --faint:   #6F665A;
  --accent:  #E09356;
  --accent2: #F2B583;
  --ok:      #94C780;
  --serif:   "Instrument Serif", Georgia, serif;
  --sans:    "Spline Sans", -apple-system, sans-serif;
  --mono:    "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Atmosphere: scanlines + top glow. Fixed, non-interactive. */
body::before {
  content: "";
  position: fixed; inset: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(224,147,86,.07), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.022) 0 1px, transparent 1px 3px);
  pointer-events: none;
  z-index: 0;
}

#app, .topbar, .footer { position: relative; z-index: 1; }

::selection { background: rgba(224,147,86,.32); }

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 24px; }

/* ── Reveal on load: one orchestrated stagger ─────────────────── */
.rv {
  opacity: 0;
  animation: rise .22s ease-out both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.topbar .wrap {
  display: flex; align-items: center; gap: 28px;
  height: 58px;
}
.brand {
  font-family: var(--mono);
  font-size: 15px; font-weight: 700;
  color: var(--text);
  letter-spacing: -.02em;
}
.brand:hover { text-decoration: none; }
.brand .tld { color: var(--accent); }
.brand .caret {
  display: inline-block; width: 8px; height: 15px;
  background: var(--accent);
  vertical-align: -2px; margin-left: 2px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav { display: flex; gap: 18px; margin-left: auto; }
.nav a {
  font-family: var(--mono); font-size: 12.5px;
  color: var(--dim); text-transform: lowercase;
}
.nav a:hover { color: var(--text); text-decoration: none; }
.nav a.on { color: var(--accent); }

/* Lang toggle — high-frequency control: NO transitions by design */
.lang {
  display: flex; border: 1px solid var(--line2); border-radius: 6px; overflow: hidden;
}
.lang button {
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  padding: 5px 10px; cursor: pointer;
  background: transparent; border: 0; color: var(--faint);
}
.lang button.on { background: var(--panel2); color: var(--accent); }

/* ── Hero (dashboard) ─────────────────────────────────────────── */
.hero { padding: 64px 0 40px; }
.kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent);
}
.hero h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(40px, 6vw, 64px); line-height: 1.04;
  letter-spacing: -.01em;
  margin: 14px 0 10px; max-width: 17ch;
}
.hero h1 em { font-style: italic; color: var(--accent2); }
.hero .sub { color: var(--dim); max-width: 56ch; font-size: 17px; }

.term {
  margin-top: 26px;
  font-family: var(--mono); font-size: 13.5px;
  color: var(--faint);
}
.term .p { color: var(--ok); }
.term .c { color: var(--text); }

/* Stats band */
.stats {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: stretch;
  margin: 36px 0 8px;
}
.gauge {
  display: flex; align-items: center; gap: 16px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
  padding: 16px 22px 16px 16px;
}
.gauge svg { display: block; }
.gauge .ring-bg { stroke: var(--line2); }
.gauge .ring-fg { stroke: var(--ok); stroke-linecap: round; }
.gauge .pct {
  font-family: var(--mono); font-size: 24px; font-weight: 700; line-height: 1;
}
.gauge .lbl { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 4px; }

.stat {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
  padding: 16px 22px;
  display: flex; flex-direction: column; justify-content: center;
}
.stat .n {
  font-family: var(--mono); font-size: 24px; font-weight: 700; line-height: 1.1;
}
.stat .n b { color: var(--accent); font-weight: 700; }
.stat .lbl { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 6px; }

/* ── Module grid ──────────────────────────────────────────────── */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px; padding: 26px 0 70px;
}
.card {
  display: block;
  border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg2) 100%);
  padding: 20px 20px 18px;
  color: var(--text);
  transition: transform .15s ease-out, border-color .15s ease-out;
  position: relative; overflow: hidden;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--line2);
  text-decoration: none;
}
.card:active { transform: translateY(0); }
.card.is-outline { border-style: dashed; }
.card .row1 { display: flex; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.card .num {
  font-family: var(--mono); font-size: 26px; font-weight: 700;
  color: var(--accent); letter-spacing: -.04em;
}
.card.is-outline .num { color: var(--faint); }
.chip {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase;
  border: 1px solid var(--line2); border-radius: 99px;
  padding: 3px 9px; color: var(--dim);
  margin-left: auto; white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.chip.acc { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.card h3 {
  font-family: var(--serif); font-weight: 400;
  font-size: 27px; line-height: 1.1; letter-spacing: -.01em;
  margin-bottom: 4px;
}
.card .tag { color: var(--faint); font-size: 14px; font-style: italic; font-family: var(--serif); }
.card .meta {
  display: flex; gap: 14px; align-items: center;
  margin-top: 16px;
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
}
.card .meta .cta { margin-left: auto; color: var(--accent); }
.rbar {
  height: 3px; border-radius: 2px; background: var(--line);
  margin-top: 12px; overflow: hidden;
}
.rbar i { display: block; height: 100%; background: var(--ok); }

/* ── Topic page ───────────────────────────────────────────────── */
.tp-head { padding: 48px 0 8px; position: relative; }
.crumb {
  font-family: var(--mono); font-size: 12.5px; color: var(--faint);
}
.crumb:hover { color: var(--text); text-decoration: none; }
.tp-num {
  position: absolute; right: 0; top: 18px;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(80px, 14vw, 150px); line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px var(--line2);
  pointer-events: none; user-select: none;
}
.tp-head h1 {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(36px, 5vw, 54px); line-height: 1.05;
  margin: 18px 0 6px; max-width: 18ch;
}
.tp-head .tag { color: var(--dim); font-family: var(--serif); font-style: italic; font-size: 18px; }
.docrow { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; }
.docrow .dlbl { font-family: var(--mono); font-size: 11px; color: var(--faint); align-self: center; margin-right: 4px; text-transform: uppercase; letter-spacing: .1em; }
.doc {
  font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--line2); border-radius: 6px;
  padding: 5px 10px; color: var(--accent2);
  transition: transform .15s ease-out;
}
.doc:hover { transform: translateY(-1px); text-decoration: none; border-color: var(--accent); }

.note {
  border: 1px dashed var(--line2); border-radius: 10px;
  background: var(--bg2);
  padding: 14px 18px; margin-top: 24px;
  color: var(--dim); font-size: 14.5px;
}

.sections { padding: 26px 0 30px; max-width: 720px; }
.sec { padding: 26px 0; border-bottom: 1px solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h2 {
  font-family: var(--serif); font-weight: 400;
  font-size: 29px; line-height: 1.15; margin-bottom: 14px;
}
.sec h2 .ix {
  font-family: var(--mono); font-size: 12px; font-weight: 500;
  color: var(--accent); vertical-align: 10px; margin-right: 10px;
}
.sec p { color: var(--dim); margin: 10px 0; }
.sec p strong, .sec li strong { color: var(--text); font-weight: 600; }
.sec ul { margin: 12px 0 12px 2px; list-style: none; }
.sec li {
  color: var(--dim);
  padding: 5px 0 5px 22px; position: relative;
}
.sec li::before {
  content: "·"; position: absolute; left: 4px;
  color: var(--accent); font-weight: 700;
}
code {
  font-family: var(--mono); font-size: .88em;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 4px; padding: 1.5px 6px;
  color: var(--accent2);
}
pre {
  background: var(--bg2);
  border: 1px solid var(--line); border-left: 2px solid var(--accent);
  border-radius: 8px;
  padding: 16px 18px; margin: 14px 0;
  overflow-x: auto;
}
pre code {
  background: none; border: 0; padding: 0;
  color: var(--text); font-size: 13px; line-height: 1.7;
}

/* ── Flashcards ───────────────────────────────────────────────── */
.deck { max-width: 720px; padding: 10px 0 80px; }
.deck-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; }
.deck-head h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; }
.deck-head .cnt { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.deck-head .hint { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin-left: auto; }

.fc-stage { perspective: 1100px; }
.fc {
  position: relative; width: 100%; min-height: 230px;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .2s ease-out;   /* flip: 200ms, transform-only */
}
.fc.flip { transform: rotateY(180deg); }
.fc-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  border: 1px solid var(--line2); border-radius: 14px;
  padding: 26px 30px;
  display: flex; flex-direction: column; gap: 12px;
  background: linear-gradient(180deg, var(--panel2) 0%, var(--panel) 100%);
}
.fc-face.back { transform: rotateY(180deg); border-color: color-mix(in srgb, var(--ok) 35%, var(--line2)); }
.fc-face .side {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  color: var(--accent);
}
.fc-face.back .side { color: var(--ok); }
.fc-face .txt {
  font-family: var(--serif); font-size: 26px; line-height: 1.25;
  margin: auto 0;
}
.fc-face.back .txt { font-family: var(--sans); font-size: 18px; color: var(--text); }
.fc-face .txt code { font-size: .8em; }

.fc-controls { display: flex; gap: 10px; margin-top: 18px; min-height: 44px; }
.btn {
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  border-radius: 8px; padding: 11px 20px; cursor: pointer;
  border: 1px solid var(--line2); background: transparent; color: var(--dim);
  transition: transform .12s ease-out;
}
.btn:hover { transform: translateY(-1px); color: var(--text); }
.btn:active { transform: translateY(0); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #14100B; font-weight: 700; }
.btn.pri:hover { color: #14100B; }
.btn.ok { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: var(--ok); }

.dots { display: flex; gap: 6px; margin-top: 18px; }
.dots i {
  width: 22px; height: 3px; border-radius: 2px; background: var(--line2);
}
.dots i.seen { background: var(--faint); }
.dots i.yes { background: var(--ok); }
.dots i.no { background: var(--accent); }

.deck-done {
  border: 1px solid var(--line2); border-radius: 14px;
  background: var(--panel);
  padding: 34px; text-align: center;
}
.deck-done .big {
  font-family: var(--mono); font-size: 52px; font-weight: 700; color: var(--ok);
  line-height: 1.1;
}
.deck-done h3 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 8px 0 4px; }
.deck-done p { color: var(--faint); font-size: 14px; margin-bottom: 18px; }

/* ── News ─────────────────────────────────────────────────────── */
.news-head { padding: 56px 0 10px; }
.news-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(38px, 5vw, 54px); margin: 12px 0 8px; }
.news-head .sub { color: var(--dim); max-width: 54ch; }
.news-list { padding: 20px 0 80px; max-width: 760px; }
.nitem {
  display: grid; grid-template-columns: 110px 1fr; gap: 20px;
  padding: 22px 0; border-bottom: 1px solid var(--line);
}
.nitem .when { font-family: var(--mono); font-size: 12px; color: var(--faint); padding-top: 6px; }
.nitem .ntag {
  display: inline-block;
  font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: 99px; padding: 2px 8px; margin-bottom: 8px;
}
.nitem h3 { font-family: var(--serif); font-weight: 400; font-size: 25px; margin-bottom: 6px; }
.nitem p { color: var(--dim); font-size: 15px; margin-bottom: 8px; }
.nitem .src { font-family: var(--mono); font-size: 12px; }

/* ── Dashboard body: module grid + sticky rail ────────────────── */
.dash-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 26px; align-items: start;
  padding: 26px 0 70px;
}
.dash-body .grid { padding: 0; }
.rail {
  position: sticky; top: 76px;
  display: flex; flex-direction: column; gap: 14px;
}
.panel {
  border: 1px solid var(--line); border-radius: 12px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg2) 100%);
  padding: 4px 14px 6px;
}
.panel-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--text);
  text-transform: uppercase; letter-spacing: .08em;
  padding: 14px 2px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.panel-h .panel-meta {
  font-size: 9.5px; color: var(--faint); letter-spacing: .03em; text-transform: none;
  white-space: nowrap;
}
a.panel-meta { color: var(--accent2); }
a.panel-meta:hover { color: var(--accent); text-decoration: none; }

.prow { padding: 9px 2px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.prow:last-of-type { border-bottom: 0; }
.pr-top { display: flex; align-items: center; gap: 7px; }
.pr-name { font-family: var(--mono); font-size: 13.5px; font-weight: 700; color: var(--text); }
.pr-price { margin-left: auto; font-family: var(--mono); font-size: 12.5px; color: var(--accent2); white-space: nowrap; }
.pbadge {
  font-family: var(--mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase;
  border-radius: 99px; padding: 2px 6px; border: 1px solid var(--line2); color: var(--dim);
}
.pbadge.new { color: #14100B; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.pbadge.flagship { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pbadge.value { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pr-sub {
  display: flex; justify-content: space-between; gap: 8px; margin-top: 3px;
  font-size: 11.5px; color: var(--faint);
}
.pr-sub .pr-ctx { font-family: var(--mono); }
.panel-foot {
  display: block; text-align: center;
  font-family: var(--mono); font-size: 11px; color: var(--accent2);
  padding: 11px 0 9px; margin-top: 2px; border-top: 1px solid var(--line);
  transition: transform .12s ease-out;
}
.panel-foot:hover { text-decoration: none; color: var(--accent); transform: translateY(-1px); }

.urow { display: block; padding: 10px 2px; border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent); }
.urow:last-of-type { border-bottom: 0; }
.urow:hover { text-decoration: none; }
.urow:hover .u-title { color: var(--accent2); }
.u-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.u-tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-radius: 99px; padding: 1px 7px;
}
.u-date { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.u-title { font-family: var(--serif); font-size: 16px; line-height: 1.25; color: var(--text); transition: color .15s ease-out; }

/* ── Footer ───────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--line);
  padding: 26px 0 40px;
  font-family: var(--mono); font-size: 11.5px; color: var(--faint);
}
.footer .wrap { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.footer a { color: var(--dim); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 920px) {
  .dash-body { grid-template-columns: 1fr; gap: 18px; }
  .rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .rail .panel { flex: 1 1 280px; }
}
@media (max-width: 640px) {
  .hero { padding: 40px 0 28px; }
  .stats { flex-direction: column; }
  .nitem { grid-template-columns: 1fr; gap: 4px; }
  .tp-num { display: none; }
  .nav { gap: 12px; }
  .rail { flex-direction: column; }
}

/* ── Reduced motion: kill it all ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
