/* gacrux-edu front door — mobile-first, light/dark, no framework, no external font.
   People revise on phones, often on a train with bad signal, so the whole thing is three static
   files and everything above the fold renders before the API answers. */

:root {
  --bg: #fbfbfc; --panel: #ffffff; --ink: #16181d; --muted: #5d6470; --line: #e3e6ec;
  --accent: #2b5cd9; --accent-soft: #eaf0ff;
  --ok: #1a7f52; --warn: #a8620a; --bad: #b3243a;
  --t1: #1a7f52; --t2: #a8620a; --t3: #6b7280;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 8px 24px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1014; --panel: #15181e; --ink: #e9ecf1; --muted: #99a2b0; --line: #262b34;
    --accent: #7fa0ff; --accent-soft: #1a2135;
    --ok: #4ec08b; --warn: #e0a355; --bad: #ff7a90;
    --t1: #4ec08b; --t2: #e0a355; --t3: #8b93a1;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 16px/1.6 ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
h1, h2, h3 { line-height: 1.25; letter-spacing: -.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.25rem, 3.5vw, 1.6rem); }
h3 { font-size: 1.02rem; }
p { margin: 0 0 1em; }
b { font-weight: 650; }
.muted { color: var(--muted); font-size: .93rem; }

/* ── chrome ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; justify-content: space-between;
  padding: .7rem clamp(.8rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .5rem; font-size: 1.02rem; }
.mark { color: var(--accent); font-size: 1.3rem; }
.wordmark b { font-weight: 700; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: .45rem .8rem; border-radius: 999px; font: inherit; font-size: .95rem; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab.is-on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.banner {
  margin: 0; padding: .55rem clamp(.8rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--warn) 12%, var(--bg));
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line));
  font-size: .84rem; color: color-mix(in srgb, var(--warn) 75%, var(--ink));
}

main { max-width: 1080px; margin: 0 auto; padding: clamp(1rem, 4vw, 2.5rem) clamp(.8rem, 3vw, 2rem) 4rem; }
.view { display: none; }
.view.is-on { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

footer {
  border-top: 1px solid var(--line); padding: 1.5rem clamp(.8rem, 3vw, 2rem) 3rem;
  max-width: 1080px; margin: 0 auto; font-size: .85rem; color: var(--muted);
}

/* ── blocks ─────────────────────────────────────────────────────────────── */
.hero { max-width: 62ch; margin-bottom: 2rem; }
.lede { font-size: 1.06rem; color: var(--muted); }
.cta-row { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.2rem; }

.btn {
  font: inherit; font-size: .95rem; cursor: pointer; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: .6rem 1.1rem; transition: transform .06s ease, border-color .12s ease;
}
.btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0d1017; } }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
}
.grid-3 { display: grid; gap: .9rem; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.card p { margin: 0; font-size: .93rem; color: var(--muted); }

.stats { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.5rem; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: .35rem .85rem; font-size: .83rem; color: var(--muted);
}
.stat b { color: var(--ink); }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.chip {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 999px; padding: .42rem .9rem; font: inherit; font-size: .89rem; cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip small { color: var(--muted); font-size: .8em; }

/* ── quiz ───────────────────────────────────────────────────────────────── */
.quiz { margin-top: 1.2rem; }
.qhead { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .8rem; }
.pill {
  font-size: .74rem; letter-spacing: .02em; text-transform: uppercase;
  border-radius: 999px; padding: .18rem .6rem; border: 1px solid var(--line); color: var(--muted);
}
.pill.t1 { color: var(--t1); border-color: color-mix(in srgb, var(--t1) 40%, var(--line)); }
.pill.t2 { color: var(--t2); border-color: color-mix(in srgb, var(--t2) 40%, var(--line)); }
.pill.t3 { color: var(--t3); }

.stem { font-size: 1.08rem; margin: .3rem 0 1.1rem; }
.options { display: grid; gap: .5rem; }
.opt {
  text-align: left; font: inherit; cursor: pointer; padding: .8rem 1rem;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 12px; display: flex; gap: .7rem; align-items: flex-start;
}
.opt:hover:not([disabled]) { border-color: var(--accent); }
.opt .letter {
  flex: 0 0 1.55rem; height: 1.55rem; border-radius: 7px; background: var(--accent-soft);
  color: var(--accent); font-size: .8rem; font-weight: 700; display: grid; place-items: center;
}
.opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--panel)); }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, var(--panel)); }
.opt[disabled] { cursor: default; }

.verdict { margin: 1.2rem 0 .6rem; font-weight: 650; }
.verdict.ok { color: var(--ok); } .verdict.no { color: var(--bad); }

.chain { border-left: 2px solid var(--line); margin: .8rem 0; padding-left: .9rem; }
.step { margin-bottom: .7rem; }
.step .txt { font-size: .95rem; }
.quote {
  font-size: .85rem; color: var(--muted); border-left: 2px solid var(--accent-soft);
  padding-left: .6rem; margin-top: .3rem; font-style: italic;
}
.cite { font-size: .78rem; color: var(--accent); }
.why-wrong { margin-top: .5rem; font-size: .9rem; }
.why-wrong .o { font-weight: 600; }
.gap {
  background: color-mix(in srgb, var(--warn) 9%, var(--panel));
  border: 1px solid color-mix(in srgb, var(--warn) 28%, var(--line));
  border-radius: 10px; padding: .6rem .8rem; font-size: .87rem; margin: .5rem 0;
}
.selection {
  font-size: .8rem; color: var(--muted); margin-top: .9rem; padding-top: .7rem;
  border-top: 1px dashed var(--line);
}

/* ── lesson ─────────────────────────────────────────────────────────────── */
#learn-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
#learn-q {
  flex: 1 1 16rem; font: inherit; padding: .65rem .9rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
}
#lesson { margin-top: 1.3rem; display: grid; gap: 1rem; }
.lesson-sec h3 { margin-bottom: .4rem; }
.mgmt { display: grid; gap: .35rem; }
.mgmt div { font-size: .93rem; }

/* ── mastery graph ──────────────────────────────────────────────────────── */
.mastery-wrap { display: grid; gap: 1rem; grid-template-columns: 1fr; margin-top: 1rem; }
@media (min-width: 900px) { .mastery-wrap { grid-template-columns: 1.6fr 1fr; } }
#graph {
  width: 100%; height: auto; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); touch-action: manipulation;
}
#graph .edge { stroke: var(--line); stroke-width: 1; }
#graph .edge.t3 { stroke-dasharray: 3 3; opacity: .55; }
#graph .node { cursor: pointer; }
#graph .node text { font-size: 9px; fill: var(--muted); pointer-events: none; }
#graph .ring-inferred { fill: none; stroke-dasharray: 3 2.5; }
#graph-side { display: grid; gap: .6rem; align-content: start; }
.legend { font-size: .82rem; color: var(--muted); display: grid; gap: .35rem; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; margin-right: .4rem; vertical-align: -1px; }

.bar { background: var(--line); border-radius: 999px; height: .5rem; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.prow { display: grid; grid-template-columns: 1fr auto; gap: .5rem .8rem; align-items: center;
        font-size: .88rem; padding: .35rem 0; border-bottom: 1px solid var(--line); }
.prow:last-child { border-bottom: 0; }
.prow .nm { display: flex; gap: .5rem; align-items: center; }

.spinner { color: var(--muted); font-size: .9rem; padding: 1rem 0; }
.err { color: var(--bad); font-size: .9rem; }


/* ── account ────────────────────────────────────────────────────────────── */
.account { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.account .who { color: var(--muted); max-width: 12rem; overflow: hidden; text-overflow: ellipsis;
                white-space: nowrap; }
.account button { font-size: .84rem; padding: .3rem .7rem; }

/* ── journey ────────────────────────────────────────────────────────────── */
#journey-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
#journey-q { flex: 1 1 16rem; font: inherit; padding: .65rem .9rem; border-radius: 10px;
             border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
#journey { margin-top: 1.2rem; display: grid; gap: 1rem; }
.card-teach { border-left: 3px solid var(--accent); }
.step-why { font-size: .82rem; color: var(--muted); margin-bottom: .7rem;
            display: flex; gap: .4rem; align-items: baseline; }
.step-kind { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700;
             color: var(--accent); }
.ask-box { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.ask-box input { flex: 1 1 14rem; font: inherit; padding: .55rem .8rem; border-radius: 10px;
                 border: 1px solid var(--line); background: var(--panel); color: var(--ink); }
.qa { margin-top: .8rem; }
.qa .q { font-weight: 600; font-size: .93rem; }
.qa .a { font-size: .93rem; margin-top: .2rem; }
.qa .refused { font-size: .9rem; color: var(--warn); margin-top: .2rem; }
.journey-log { display: grid; gap: .8rem; }

/* ── zoom breadcrumbs ───────────────────────────────────────────────────── */
.crumbs { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; font-size: .85rem;
          padding: .6rem .8rem; }
.crumbs .sep { color: var(--muted); }
.crumb { border: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit;
         font-size: .85rem; padding: 0; text-decoration: underline; }
