/* ============================
   jayproject — Stylesheet
   ============================ */

/* --- Custom Properties (Light) --- */
:root {
  --bg: #f7f6f2;
  --card: #fff;
  --tx: #1c1b18;
  --mu: #625f57;
  --bd: #d8d5cc;
  --ac: #2f5d50;
  --acbg: #e4efeb;
  --ok: #17663f;
  --okbg: #dff0e6;
  --practice: #7a5000;
  --practicebg: #fff0cc;
  --ready: #7a5000;
  --readybg: #fbefd5;
  --lock: #4e4b45;
  --lockbg: #e9e7e1;
  --focus: #1f6feb;
  color-scheme: light;
}

/* --- Custom Properties (Dark) --- */
:root[data-theme="dark"] {
  --bg: #171815;
  --card: #20211d;
  --tx: #ecebe5;
  --mu: #aaa69c;
  --bd: #3a3b35;
  --ac: #7cc2ab;
  --acbg: #23332d;
  --ok: #77d69a;
  --okbg: #1f3a2a;
  --practice: #efbe60;
  --practicebg: #3b3019;
  --ready: #efbe60;
  --readybg: #3d3118;
  --lock: #b5b0a4;
  --lockbg: #2b2c27;
  --focus: #79b8ff;
  color-scheme: dark;
}

/* --- Reset & Base --- */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 20px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

button, input { font: inherit; }

/* --- Layout --- */
.wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 18px 56px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ac);
  font-weight: 800;
  text-decoration: none;
}

.tag {
  color: var(--mu);
  font-size: 13px;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --- Buttons --- */
.icon-btn,
.menu-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--bd);
  background: var(--card);
  color: var(--tx);
  border-radius: 10px;
  cursor: pointer;
}

.icon-btn:focus-visible,
.menu-btn:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.opt:focus-visible,
.topic-btn:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(31, 111, 235, 0.55);
  outline-offset: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid var(--ac);
  background: var(--ac);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.btn.secondary {
  background: transparent;
  color: var(--tx);
  border-color: var(--bd);
}

.btn.small {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 14px;
}

/* --- Typography --- */
.hero { padding: 8px 0 20px; }

.eyebrow {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ac);
}

h1 {
  font-size: clamp(32px, 6vw, 58px);
  line-height: 1.08;
  letter-spacing: -0.04em;
  margin: 8px 0 14px;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  margin: 0 0 8px;
}

h3 {
  font-size: 17px;
  margin: 0 0 4px;
}

p { margin: 0 0 12px; }
.muted { color: var(--mu); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* --- Cards --- */
.card {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 16px;
}

.cards { display: grid; gap: 14px; }

@media (min-width: 720px) {
  .cards.three { grid-template-columns: repeat(3, 1fr); }
  .cards.two  { grid-template-columns: repeat(2, 1fr); }
}

/* --- Sections --- */
.section { margin-top: 36px; }

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section > .card + .card { margin-top: 10px; }

/* --- Legend --- */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
  color: var(--mu);
  margin: 6px 0 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1.5px solid;
}

.swatch-mastered  { background: var(--okbg);       border-color: var(--ok); }
.swatch-practice  { background: var(--practicebg); border-color: var(--practice); }
.swatch-ready     { background: var(--readybg);    border-color: var(--ready); }
.swatch-locked    { background: var(--lockbg);     border-color: var(--lock); }
.swatch-unseen    { background: transparent;       border-color: var(--bd); }

/* --- Graph / Map --- */
.gwrap {
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 10px;
  overflow: auto;
}

.gwrap svg {
  display: block;
  min-width: 760px;
  width: 100%;
  height: auto;
}

.n { cursor: pointer; }
.n rect { stroke-width: 1.5; }

.n text {
  fill: var(--tx);
  font-size: 12px;
  text-anchor: middle;
  pointer-events: none;
  font-weight: 700;
}

.n-mastered rect { fill: var(--okbg);       stroke: var(--ok); }
.n-practice rect { fill: var(--practicebg); stroke: var(--practice); }
.n-ready    rect { fill: var(--readybg);    stroke: var(--ready); }
.n-locked   rect { fill: var(--lockbg);     stroke: var(--lock); }
.n-unseen   rect { fill: transparent;       stroke: var(--bd); stroke-dasharray: 4 3; }
.n.selected rect { stroke-width: 3; }

.edge {
  fill: none;
  stroke: var(--lock);
  stroke-width: 1.3;
  opacity: 0.45;
}

.edge.active {
  stroke: var(--ok);
  opacity: 0.85;
}

#detail {
  margin-top: 12px;
  min-height: 80px;
}

/* --- Pills --- */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 800;
  margin-left: 7px;
}

.pill.mastered { background: var(--okbg);       color: var(--ok); }
.pill.practice { background: var(--practicebg); color: var(--practice); }
.pill.ready    { background: var(--readybg);    color: var(--ready); }

.pill.locked,
.pill.unseen   { background: var(--lockbg);     color: var(--lock); }

/* --- Results --- */
.result {
  margin-top: 14px;
  background: var(--acbg);
  border: 1px solid var(--bd);
  border-radius: 14px;
  padding: 16px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.metric {
  padding: 10px;
  background: var(--card);
  border: 1px solid var(--bd);
  border-radius: 10px;
}

.metric strong { display: block; font-size: 24px; }
.metric span   { font-size: 12px; color: var(--mu); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* --- Test UI --- */
.hidden { display: none !important; }

.test-shell {
  max-width: 720px;
  margin: 0 auto;
}

.progress-track {
  height: 8px;
  background: var(--bd);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 18px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--ac);
  transition: width 0.2s;
}

.question {
  font-size: 25px;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 18px;
}

.opt {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--bd);
  border-radius: 11px;
  background: var(--card);
  color: var(--tx);
  cursor: pointer;
}

.opt:hover { border-color: var(--ac); }

.test-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--mu);
  font-size: 13px;
}

/* --- Topic List --- */
.topic-list { display: grid; gap: 10px; }

.topic-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--bd);
  border-radius: 12px;
  background: var(--card);
  text-decoration: none;
  color: var(--tx);
}

.topic-link:hover { border-color: var(--ac); }
.topic-link small { color: var(--mu); }

.topic-btn {
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  color: var(--tx);
  cursor: pointer;
  font-weight: 800;
}

/* --- Content Prose --- */
.content-prose { max-width: 760px; }

.formula {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  padding: 10px 12px;
  border: 1px solid var(--bd);
  background: var(--bg);
  border-radius: 10px;
  margin: 8px 0;
}

/* --- Navigation Drawer --- */
.site-nav {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.46);
  opacity: 0;
  transition: opacity 0.2s;
}

.drawer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(320px, 88vw);
  background: var(--card);
  border-left: 1px solid var(--bd);
  padding: 82px 16px 20px;
  transform: translateX(100%);
  transition: transform 0.22s;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.site-nav.open { pointer-events: auto; }
.site-nav.open .scrim { opacity: 1; }
.site-nav.open .drawer { transform: none; }

.nav-link {
  display: block;
  padding: 13px 14px;
  border-radius: 10px;
  color: var(--tx);
  text-decoration: none;
  font-weight: 750;
}

.nav-link:hover {
  background: var(--acbg);
  color: var(--ac);
}

/* --- Footer --- */
.footer {
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid var(--bd);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
  color: var(--mu);
}

.footer a { color: inherit; }

/* --- Notices & Misc --- */
.notice {
  border-left: 4px solid var(--ac);
  padding: 10px 12px;
  background: var(--acbg);
  border-radius: 8px;
}

.skip-link {
  position: absolute;
  left: 8px;
  top: 8px;
  transform: translateY(-140%);
  z-index: 100;
  padding: 10px 14px;
  background: var(--card);
  color: var(--tx);
  border: 2px solid var(--focus);
  border-radius: 8px;
}

.skip-link:focus { transform: none; }

.canvas-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.landing {
  position: fixed;
  inset: 0;
  background: #0a0c10;
  color: #eef2f6;
  z-index: 50;
}

.landing-inner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px;
}

.landing-title {
  font-size: clamp(52px, 12vw, 108px);
  font-weight: 900;
  letter-spacing: -0.06em;
  margin: 0;
  text-shadow: 0 0 28px #0a0c10;
}

.landing .btn {
  background: rgba(10, 12, 16, 0.55);
  border-color: rgba(255, 255, 255, 0.4);
  border-radius: 999px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.topic-hero { padding-bottom: 8px; }

.breadcrumb {
  font-size: 14px;
  color: var(--mu);
  margin-bottom: 14px;
}

.breadcrumb a { color: inherit; }

.error-code {
  font-size: clamp(68px, 14vw, 140px);
  font-weight: 900;
  letter-spacing: -0.07em;
  margin: 0;
}

.error-main {
  padding-top: 15vh;
  text-align: center;
}

.center-actions { justify-content: center; }

.danger {
  background: #fff0f0;
  border-color: #edb7b7;
  color: #641b1b;
}

.dark-only  { display: none; }
.light-only { display: inline; }
.help-box   { margin-top: 14px; }

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .progress-fill,
  .drawer,
  .scrim { transition: none; }
}
