/* ============================================================
   Codepath — design tokens
   Palette is deliberately restrained to black / white / grey,
   with brightness (not hue) doing the work of hierarchy.
   ============================================================ */

:root {
  --black: #08080a;
  --panel: #131317;
  --panel-raised: #1b1b20;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.18);
  --white: #f3f3f1;
  --grey-1: #c6c6cb;
  --grey-2: #8d8d95;
  --grey-3: #5c5c64;
  --glow: rgba(255, 255, 255, 0.55);
  --success: #f3f3f1;
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 6px;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-display);
  min-height: 100vh;
}

body {
  background:
    radial-gradient(ellipse 60% 40% at 20% -10%, rgba(255,255,255,0.06), transparent),
    radial-gradient(ellipse 50% 40% at 100% 10%, rgba(255,255,255,0.045), transparent),
    var(--black);
}

.noise-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; }
button { font-family: inherit; }

::selection { background: rgba(255,255,255,0.25); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------- glass primitives ---------- */

.glass {
  background: linear-gradient(180deg, rgba(255,255,255,0.055), rgba(255,255,255,0.02));
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.glass-raised {
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.03));
  border: 1px solid var(--line-strong);
}

/* ============================================================
   Shell layout
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 40; }
}

.sidebar {
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand .mark {
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 30% 20%, rgba(255,255,255,0.25), rgba(255,255,255,0.02));
  font-size: 14px;
}

.track-nav { display: flex; flex-direction: column; gap: 6px; }

.track-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--grey-1);
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.track-btn:hover { background: rgba(255,255,255,0.04); color: var(--white); }

.track-btn.active {
  background: rgba(255,255,255,0.07);
  border-color: var(--line-strong);
  color: var(--white);
}

.track-btn .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--grey-3);
  flex-shrink: 0;
}
.track-btn.active .dot { background: var(--white); box-shadow: 0 0 8px var(--glow); }

.sidebar-stats {
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-family: var(--font-mono);
}

.stat-row { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--grey-2); }
.stat-row b { color: var(--white); font-weight: 500; }

.main { padding: 36px 40px 80px; max-width: 1180px; }
@media (max-width: 640px) { .main { padding: 22px 16px 60px; } }

/* ============================================================
   Track header
   ============================================================ */

.track-header { margin-bottom: 40px; }
.track-header .eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--grey-2);
  margin: 0 0 6px;
}
.track-header h1 {
  font-size: 34px;
  margin: 0 0 10px;
  letter-spacing: -0.015em;
  font-weight: 600;
}
.track-header p {
  color: var(--grey-1);
  max-width: 60ch;
  line-height: 1.55;
  font-size: 15px;
  margin: 0;
}

.progress-strip {
  margin-top: 20px;
  height: 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
  max-width: 340px;
}
.progress-strip > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--grey-2), var(--white));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ============================================================
   Game path (the bespoke centerpiece)
   ============================================================ */

.path-wrap { position: relative; padding: 10px 0 40px; }

.path-svg-line { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.path-svg-line path {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 2;
  stroke-dasharray: 3 10;
  stroke-linecap: round;
}
.path-svg-line path.done { stroke: rgba(255,255,255,0.55); stroke-dasharray: none; }

.path-nodes {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 46px;
}

.path-row { display: flex; align-items: center; }
.path-row.align-left { justify-content: flex-start; }
.path-row.align-right { justify-content: flex-end; }
.path-row.align-center { justify-content: center; }

.node {
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  color: inherit;
  max-width: 380px;
}

.node[disabled] { cursor: not-allowed; }

.node-orb {
  width: 62px; height: 62px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 21px;
  position: relative;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.01));
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.node:not([disabled]):hover .node-orb {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 0 1px var(--line-strong);
}

.node-orb.locked { opacity: 0.35; }
.node-orb.locked::after {
  content: "";
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-linear-gradient(135deg, rgba(255,255,255,0.05) 0 2px, transparent 2px 7px);
}

.node-orb.done {
  background: radial-gradient(circle at 35% 25%, rgba(255,255,255,0.85), rgba(255,255,255,0.15));
  color: #0b0b0d;
  box-shadow: 0 0 22px rgba(255,255,255,0.35);
}

.node-orb.placeholder { border-style: dashed; }

.node-info { text-align: left; }
.node-info .n-title { font-size: 15px; font-weight: 500; margin: 0 0 3px; }
.node-info .n-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--grey-2); margin: 0; }
.node[disabled] .node-info .n-title { color: var(--grey-2); }

/* ============================================================
   Lesson view
   ============================================================ */

.lesson-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--grey-2); text-decoration: none;
  margin-bottom: 14px; cursor: pointer; background: none; border: none; padding: 0;
  font-family: var(--font-display);
}
.back-link:hover { color: var(--white); }

.lesson-brief {
  padding: 22px 24px;
  margin-bottom: 22px;
  line-height: 1.6;
  font-size: 14.5px;
  color: var(--grey-1);
}
.lesson-brief strong { color: var(--white); }
.lesson-brief h1 { font-size: 24px; margin: 0 0 10px; color: var(--white); font-weight: 600; }
.lesson-brief .goal-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--grey-2);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 12px;
}

.workbench {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  min-height: 420px;
}
@media (max-width: 900px) { .workbench { grid-template-columns: 1fr; } }

.pane { display: flex; flex-direction: column; overflow: hidden; }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--grey-2);
}
.pane-head .dots { display: flex; gap: 5px; }
.pane-head .dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--grey-3); }

textarea.code-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding: 16px;
  min-height: 260px;
  tab-size: 2;
}

.preview-frame { flex: 1; background: #fff; border: none; min-height: 260px; }

.console-out {
  flex: 1;
  background: transparent;
  color: var(--grey-1);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  min-height: 260px;
}
.console-out .err { color: #ff8a8a; }
.console-out .ok-line { color: var(--white); }

.run-row {
  display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap;
}

.btn {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255,255,255,0.04);
  color: var(--white);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn:hover { background: rgba(255,255,255,0.1); }
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--white); color: #0b0b0d; border-color: var(--white); }
.btn.primary:hover { background: #dcdcdc; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.hint-toggle { font-size: 13px; color: var(--grey-2); background: none; border: none; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.hint-box { margin-top: 12px; padding: 14px 16px; font-size: 13.5px; color: var(--grey-1); line-height: 1.5; }

.result-banner {
  margin-top: 18px;
  padding: 14px 18px;
  display: flex; align-items: center; gap: 10px;
  font-size: 14px;
}
.result-banner.success { color: var(--white); }
.result-banner.fail { color: var(--grey-2); }

/* ============================================================
   Placeholder / locked lesson view
   ============================================================ */

.placeholder-card {
  padding: 60px 30px;
  text-align: center;
  color: var(--grey-2);
}
.placeholder-card .glyph { font-size: 30px; margin-bottom: 14px; }
.placeholder-card h2 { color: var(--white); font-weight: 500; font-size: 19px; margin: 0 0 8px; }
.placeholder-card p { font-size: 13.5px; max-width: 42ch; margin: 0 auto; line-height: 1.6; }

/* ============================================================
   Track select (home)
   ============================================================ */

.home-hero { margin-bottom: 46px; }
.home-hero h1 { font-size: 40px; margin: 0 0 12px; letter-spacing: -0.02em; max-width: 16ch; line-height: 1.15; }
.home-hero p { color: var(--grey-1); font-size: 15.5px; max-width: 56ch; line-height: 1.6; }

.track-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 800px) { .track-grid { grid-template-columns: 1fr; } }

.track-card {
  padding: 26px 24px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}
.track-card:hover { transform: translateY(-4px); border-color: var(--line-strong); }
.track-card .icon { font-size: 26px; }
.track-card h3 { margin: 0; font-size: 18px; font-weight: 600; }
.track-card p { margin: 0; color: var(--grey-2); font-size: 13.5px; line-height: 1.55; }
.track-card .prog { font-family: var(--font-mono); font-size: 11.5px; color: var(--grey-2); margin-top: auto; }
