/* ============================================================
   MedCoreX · Studyverse KIT — site/assets/studyverse.css
   THE design file of the site. Its visual language is the
   landing page's "Graphite and Ember": flat matte surfaces,
   hairline seams, square controls, Inter Tight headlines, and
   JetBrains Mono for labels and readings. Every page loads this
   file (the landing loads it too, before assets/home/home.css,
   which only holds landing-specific modules).

   Tokens (palette, type scale, rhythm) live in
   studyverse-tokens.css — never paste them here or in a page.
   Selector vocabulary: the landing's names (.site-head, .brand,
   .btn-primary, .sec-head, .site-foot …) and the legacy kit's
   names (.nav, .logo, .btn.alt, .section-head, .foot …) resolve
   to the SAME styles, so either markup renders one design.
   ============================================================ */
@import url('/assets/studyverse-tokens.css');

/* ── base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html[data-theme=dark] { color-scheme: dark; }
html[data-theme=light] { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--f-ui); font-size: var(--fs-body); line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}
body { background-image: none !important; }
html[data-theme] body { background-color: var(--bg); color: var(--ink); }
img, svg, canvas { display: block; max-width: 100%; }
a { color: inherit; }
h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
::selection { background: var(--c1); color: var(--on-accent); }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 10px 14px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 12px; }
.blobs { display: none !important; }
html[data-pattern=dots] body { background-image: radial-gradient(color-mix(in srgb, var(--ink) 14%, transparent) 1.4px, transparent 1.6px); background-size: 22px 22px; }
html[data-pattern=grid] body { background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px); background-size: 34px 34px; }
kbd { font-family: var(--f-mono); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 .4em; background: var(--surface); font-size: .85em; }
.hl { background: linear-gradient(transparent 62%, color-mix(in srgb, var(--c1) 45%, transparent) 62%); padding: 0 .1em; }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.grid12 { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.label { font-family: var(--f-mono); font-size: var(--fs-label); font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.study-note { font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .04em; color: var(--muted); }
.muted { color: var(--muted); }

/* ── type: the eight-step fluid scale ─────────────────────── */
h1, h2, h3, .display {
  font-family: var(--f-ui); font-weight: 600; text-transform: none;
  letter-spacing: -.035em; line-height: 1.04; text-wrap: balance;
}
h1, .h1 { font-size: var(--fs-h1); line-height: 1; letter-spacing: -.04em; }
h1 .soft, .h1 .soft, .h2 .soft, .quote .soft { color: var(--muted); }
h2, .h2 { font-size: var(--fs-h2); max-width: 24ch; }
h3, .h3 { font-size: var(--fs-h3); letter-spacing: -.02em; line-height: 1.15; }
h4, .h4 { font-size: var(--fs-h3); letter-spacing: -.01em; line-height: 1.2; }
.lede { margin-top: 24px; font-size: var(--fs-lead); line-height: 1.5; color: var(--muted); max-width: 46ch; text-wrap: pretty; }
.lede strong { color: var(--ink); font-weight: 600; }
.eyebrow { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; font-family: var(--f-mono); font-size: var(--fs-label); font-weight: 500; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.eyebrow::before { content: ""; width: 18px; height: 2px; background: var(--accent); flex: 0 0 auto; }
.idx { font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .1em; color: var(--accent); }
/* legacy display h1 (login/signup/404): same headline voice, no old strokes */
.mega { font-size: var(--fs-h1); font-weight: 600; line-height: 1; letter-spacing: -.04em; margin: 14px 0 20px; }
.mega .w2, .mega .w4 { color: var(--muted); -webkit-text-stroke: 0; }
.mega span { display: inline-block; }

/* ── sections ─────────────────────────────────────────────── */
.section { padding: clamp(60px, 8vw, 116px) 0; border-top: 1px solid var(--line); }
.sec-head, .section-head { display: grid; gap: 14px; margin-bottom: clamp(30px, 4vw, 52px); }
.section-head:first-child { margin-top: clamp(36px, 5vw, 64px); }
.sec-lead, .section-head p { color: var(--muted); max-width: 54ch; }
.hero-band { padding: clamp(44px, 7vw, 100px) 0 clamp(56px, 7vw, 96px); }

/* ── header: landing and legacy vocab, one look ───────────── */
.site-head, .nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.site-head .wrap, .nav .wrap {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; min-height: 58px;
}
.brand, .logo {
  display: inline-flex; align-items: center; gap: 10px; margin-right: auto;
  text-decoration: none; font-weight: 700; font-size: 1rem; letter-spacing: -.01em;
  text-transform: none; font-family: var(--f-ui);
}
.brand-mark, .logo-mark {
  width: 26px; height: 26px; display: grid; place-items: center;
  border: 1.5px solid var(--ink); border-radius: 2px; flex: 0 0 auto;
}
.brand-mark svg, .logo-mark svg { width: 18px; height: 18px; }
.nav-links, .links { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav-links a, .links a, .links .navdrop > a {
  font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .06em;
  text-transform: uppercase; text-decoration: none; color: var(--muted);
  padding: 8px 10px; border-radius: 2px; border: 1px solid transparent;
  font-weight: 500;
}
.nav-links a:hover, .nav-links a[aria-current="page"],
.links a:hover, .links a[aria-current="page"] {
  color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); background: transparent;
}
/* the Library link is wrapped by the shelves dropdown */
.links .navdrop { display: flex; padding-bottom: 0; margin-bottom: 0; }
.navdrop { position: relative; }
.navmenu {
  position: absolute; top: 100%; left: 0; min-width: 245px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: 8px; display: none; flex-direction: column;
  gap: 2px; z-index: 70;
}
.navdrop:hover .navmenu, .navdrop:focus-within .navmenu { display: flex; }
.navmenu a {
  text-decoration: none; font-weight: 500; padding: 8px 10px;
  border-radius: 2px; border: 1px solid transparent; white-space: nowrap;
  font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.navmenu a:hover { background: var(--leaf, var(--surface)); border-color: var(--line); color: var(--ink); }
.navmenu a.all { background: var(--ink); color: var(--bg); border-color: var(--ink); }
/* engine cluster + controls */
.engine { display: flex; align-items: center; gap: 6px; }
.theme-btn, .icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 36px; height: 36px; background: transparent; color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 2px; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.theme-btn:hover, .icon-btn:hover { border-color: var(--ink); }
.icon-btn::after, .nav-tog::after { content: ""; position: absolute; inset: -4px; border-radius: 4px; }
.theme-btn svg, .icon-btn svg { width: 17px; height: 17px; }
.theme-btn .i-sun { display: none; }
html[data-theme="light"] .theme-btn .i-sun { display: block; }
html[data-theme="light"] .theme-btn .i-moon { display: none; }
html[data-theme="dark"] .theme-btn .i-moon { display: block; }
html[data-theme="dark"] .theme-btn .i-sun { display: none; }
.icon-btn[aria-pressed="true"] { background: transparent; border-color: var(--ink); color: var(--ink); }
.nav-tog {
  position: relative; width: 30px; height: 30px; padding: 0;
  border-radius: 2px; border: 1px solid var(--line-strong); background: transparent;
  color: var(--ink); cursor: pointer; display: grid; place-items: center;
}
.nav-tog:hover, .nav-tog[aria-expanded="false"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.nav-show {
  position: fixed; right: 16px; top: 16px; z-index: 60; display: none;
  align-items: center; padding: 9px 12px; border: 1px solid var(--line-strong);
  border-radius: 2px; background: var(--surface); color: var(--ink); cursor: pointer;
  font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .06em; text-transform: uppercase;
}
.nav-show:hover { background: var(--ink); color: var(--bg); }
body.nav-off .nav, body.nav-off .site-head { display: none; }
body.nav-off .nav-show { display: inline-flex; }

/* ── buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 0 20px; border-radius: 2px; text-decoration: none; font-weight: 600;
  font-size: .98rem; letter-spacing: -.005em; border: 1px solid var(--line-strong);
  cursor: pointer; background: transparent; color: var(--ink);
  transition: transform .35s var(--spring), background-color .2s var(--ease),
              border-color .2s var(--ease), color .2s var(--ease);
}
.btn-primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost, .btn.ghost { border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover, .btn.ghost:hover { border-color: var(--ink); transform: translateY(-1px); }
.btn.alt { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn-small, .btn.sm { min-height: 38px; padding: 0 14px; font-size: var(--fs-small); }

/* ── chips, fields, tags ──────────────────────────────────── */
.chip {
  display: inline-block; cursor: pointer; border: 1px solid var(--line);
  border-radius: 4px; background: var(--surface); padding: .4em .9em;
  font-weight: 600; font-size: .85rem; font-family: var(--f-ui);
  text-transform: none; letter-spacing: 0;
  transition: border-color .2s var(--ease), background .3s, color .3s;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.field {
  border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface);
  padding: .7em 1.1em; outline: none; min-width: 0; min-height: 44px;
  font-size: var(--fs-small); transition: border-color .2s;
}
.field:focus { border-color: var(--accent); box-shadow: none; }
.tag {
  display: inline-block; font-family: var(--f-mono); font-size: var(--fs-label);
  font-weight: 500; text-transform: uppercase; letter-spacing: .08em;
  padding: .3em .7em; border: 1px solid transparent; border-radius: 4px;
  background: var(--accent); color: var(--on-accent);
}
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; box-shadow: none; padding: 26px; position: relative;
  transition: border-color .2s var(--ease), background-color .3s;
}
.card.hov:hover { transform: none; border-color: var(--line-strong); }

/* ── quote ────────────────────────────────────────────────── */
.quote-section { padding: clamp(72px, 10vw, 140px) 0; border-top: 1px solid var(--line); }
.quote { font-size: var(--fs-quote); font-weight: 600; line-height: 1.08; letter-spacing: -.04em; text-wrap: balance; max-width: 24ch; }
.quote-attr { margin-top: 28px; font-family: var(--f-mono); font-size: var(--fs-label); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }

/* ── footer: landing and legacy vocab, one look ───────────── */
.site-foot, footer.foot { border-top: 1px solid var(--line); padding: 40px 0 36px; transition: background-color .35s var(--ease); }
footer.foot { margin-top: 56px; background: transparent; }
.foot-grid, .foot-in { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .foot-grid, .foot-in { grid-template-columns: 2fr 3fr; } }
.foot-tag { color: var(--muted); max-width: 42ch; margin-top: 10px; font-size: var(--fs-small); }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 18px; align-content: start; }
.foot-links a { color: var(--muted); text-decoration: none; font-size: var(--fs-small); }
.foot-links a:hover { color: var(--ink); text-decoration: underline; }
.foot-legal {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 14px;
  color: var(--muted); font-family: var(--f-mono); font-size: var(--fs-label);
  letter-spacing: .03em; padding-top: 18px; border-top: 1px solid var(--line);
}

/* ── breadcrumb line (resource pages) ─────────────────────── */
nav.crumbline {
  display: flex; gap: 10px; align-items: center;
  max-width: var(--max); margin: 0 auto; padding: 12px var(--gutter);
  border-bottom: 1px solid var(--line);
  font-family: var(--f-mono); font-size: var(--fs-label); font-weight: 500;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
nav.crumbline a { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
nav.crumbline span[aria-current="page"] { color: var(--muted); }
@media print { nav.crumbline { display: none; } }

/* ── entry reveal (legacy pages: CSS animation; the landing
      additionally scopes to .js and drives it via home.js) ── */
.rv { animation: rise .7s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(28px) scale(.97); } }
.js .rv { opacity: 0; transform: translateY(14px); transition: opacity .55s var(--ease), transform .55s var(--ease); animation: none; }
.js .rv.in { opacity: 1; transform: none; }

/* ── question-practice furniture (bank/answer pages) ──────── */
.opts { display: grid; gap: 13px; }
.opt {
  display: flex; align-items: flex-start; gap: 13px; cursor: pointer; text-align: left;
  width: 100%; padding: 15px 17px; border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); font-weight: 500; font-size: .98em; line-height: 1.5;
  transition: border-color .2s var(--ease), background-color .25s;
}
.opt:hover:not(:disabled) { border-color: var(--ink); }
.opt .let {
  flex: 0 0 auto; display: grid; place-items: center; width: 28px; height: 28px;
  border: 1px solid var(--line-strong); border-radius: 4px; font-family: var(--f-mono);
  font-size: .85rem; background: var(--leaf, var(--surface)); color: var(--ink);
}
.opt .key { margin-left: auto; font-weight: 600; font-size: .78rem; color: var(--muted); }
.opt .mark { margin-left: auto; font-weight: 700; font-size: 1.15rem; }
.opt.correct { background: color-mix(in srgb, var(--ok) 18%, var(--surface)); color: var(--ink); border-color: var(--ok); }
.opt.correct .let { background: var(--ok); color: var(--on-accent); border-color: var(--ok); }
.opt.wrong { background: color-mix(in srgb, var(--bad) 16%, var(--surface)); color: var(--ink); border-color: var(--bad); }
.opt.wrong .let { background: var(--bad); color: var(--on-accent); border-color: var(--bad); }
.opt.dim { opacity: .6; }
.opt:disabled { cursor: default; }
.nextbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 20px; }
.nextbar .hint { font-size: .88rem; font-weight: 600; }
.prog { display: flex; height: 14px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--bg); }
.prog i { display: block; height: 100%; }
.prog i.g { background: var(--ok); }
.prog i.r { background: var(--bad); }
.bar { display: flex; height: 16px; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; background: var(--surface); }
.bar i { display: block; height: 100%; transition: width .5s var(--ease); }
.bar i.g { background: var(--ok); }
.bar i.r { background: var(--bad); }

/* ── dialog, toast, confetti ──────────────────────────────── */
.dialog { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); box-shadow: none; padding: 0; width: min(980px, calc(100vw - 24px)); max-width: none; max-height: 90vh; }
.toast {
  position: fixed; left: 50%; bottom: 70px; transform: translate(-50%, calc(100% + 90px));
  background: var(--ink); color: var(--bg); padding: 12px 22px; border-radius: 4px;
  font-weight: 600; z-index: 99; transition: transform .5s var(--ease); box-shadow: none;
}
.toast.show { transform: translate(-50%, 0); }
.toast.theme-toast {
  max-width: calc(100vw - 28px); padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 4px; background: var(--surface); color: var(--ink);
  font-family: var(--f-mono); font-size: .8rem; line-height: 1.2; text-align: center;
  white-space: normal; letter-spacing: .01em;
}
.confetti { position: fixed; width: 10px; height: 14px; z-index: 98; pointer-events: none; border: 1.5px solid var(--ink); }

/* ── legacy hero leftovers: rest into the shared voice ────── */
/* The landing hero owns a nested .grid12 (home.css) and must span the
   full wrap; only the legacy two-up .hero keeps the grid. */
.hero:not(:has(.grid12)) { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 30px; align-items: center; padding: clamp(44px, 7vw, 100px) 0 clamp(26px, 4vw, 40px); }
.hero-art { position: relative; width: min(100%, 568px); aspect-ratio: 16 / 9; }
.sticker, .shape, .marquee { animation: none; }
.sticker { position: absolute; right: 6%; top: 4%; width: 34%; max-width: 160px; aspect-ratio: 1; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; display: grid; place-items: center; text-align: center; font-family: var(--f-mono); font-size: var(--fs-label); line-height: 1.3; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.shape { position: absolute; border: 1px solid var(--line-strong); }
.s1 { width: 22%; height: 30%; background: color-mix(in srgb, var(--c1) 24%, transparent); left: 6%; top: 20%; border-radius: 4px; }
.s2 { width: 18%; height: 25%; background: color-mix(in srgb, var(--c3) 24%, transparent); border-radius: 50%; left: 36%; bottom: 4%; }
.s3 { width: 25%; height: 30%; background: color-mix(in srgb, var(--c4) 24%, transparent); right: 2%; bottom: 8%; border: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.marquee { overflow: hidden; border-block: 1px solid var(--line); background: var(--ink); color: var(--bg); padding: 12px 0; margin: 10px 0 34px; transform: none; }
.track { display: flex; width: max-content; animation: scroll 40s linear infinite; font-family: var(--f-ui); font-weight: 600; font-size: 1rem; }
.track span { padding: 0 22px; white-space: nowrap; }
.track span::after { content: "·"; margin-left: 44px; color: var(--accent); }
.marquee:hover .track { animation-play-state: paused; }
@keyframes scroll { to { transform: translateX(-50%); } }

/* ── text on accent fills ─────────────────────────────────── */
.btn-primary, .tag, .opt.sel { color: var(--on-accent); }
.btn:not(.btn-primary), .btn-ghost, .btn.ghost, .btn.alt { color: var(--ink); }
.navmenu a.all { color: var(--bg); }
.opt .let { color: var(--ink); }

/* ── responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { width: min(100%, 420px); aspect-ratio: 16 / 9; }
  .links { order: 3; width: 100%; }
}
@media (max-width: 640px) {
  .nav-links a[data-hide-sm], .links a[data-hide-sm] { display: none; }
}
@media (max-width: 480px) {
  .site-head .wrap, .nav .wrap { padding: 0 4px; }
  .brand, .logo { font-size: .95rem; }
  .engine { gap: 5px; padding: 3px; }
  .theme-btn, .icon-btn { width: 32px; height: 32px; }
  .nav-tog { width: 28px; height: 28px; }
  .nav-links a, .links a { padding: 7px 8px; }
}

/* No burger panel: every page shows its links and wraps them the
   same way the landing does (the engine may inject a burger
   button; it stays hidden). */
.burger { display: none; }
.nav .wrap { position: relative; }
@media (max-width: 640px) {
  .nav .links { flex: 1 1 100%; justify-content: center; order: 3; }
}

/* ── reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ── print ────────────────────────────────────────────────── */
@media print {
  .site-head, .nav, .foot, .site-foot, .blobs, .toast, .btn, .icon-btn,
  .nav-show, .nav-tog, .marquee, .hero-art, .game-slot, .try-row { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
  .rv { animation: none !important; }
  .js .rv { opacity: 1 !important; transform: none !important; }
}
