@import url('https://fonts.googleapis.com/css2?family=VT323&family=IBM+Plex+Mono:ital,wght@0,400;0,500;0,700;1,400&display=swap');

/* === TOKENS === */
:root {
  --bg:          #0C0B09;
  --bg-up:       #161410;
  --bg-code:     #1C1A16;
  --amber:       #FFB300;
  --amber-dim:   #CC8E00;
  --amber-ghost: rgba(255,179,0,0.06);
  --text:        #EDE0C0;
  --muted:       #7A6E58;
  --border:      #2A2520;
  --border-up:   #3A342C;
  --green:       #28C840;
  --yellow:      #FFBD2E;
  --red:         #FF5F57;
}

/* === RESET === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
  min-height: 100vh;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 3px
  );
}

a {
  color: var(--amber);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page-body p a {
  text-decoration: underline;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === ANIMATIONS === */
@keyframes flicker {
  0%,  89%, 91%, 93.5%, 97%, 100% { opacity: 1; }
  90%                              { opacity: 0.72; }
  92%                              { opacity: 0.88; }
  94%, 95%                         { opacity: 0.82; }
  96%                              { opacity: 0.95; }
}

/* === LAYOUT === */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

.page-body {
  padding-top: 64px;
  padding-bottom: 96px;
}

/* === NAV === */
nav {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  display: flex;
  align-items: center;
  height: 52px;
  gap: 16px;
  position: relative;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand:hover {
  text-decoration: none;
}

.nav-symbol {
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,179,0,0.5);
  line-height: 1;
}

.nav-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.nav-sep {
  color: var(--muted);
  font-size: 13px;
  flex: 1;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 0;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 14px;
  display: block;
  transition: color 0.12s;
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  color: var(--amber);
  border-color: var(--border);
  background: var(--bg-up);
}

.nav-link.nav-external {
  color: var(--amber-dim);
}

.nav-link.nav-external:hover {
  color: var(--amber);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
}

/* === TERMINAL CHROME === */
.terminal {
  background: var(--bg-code);
  border: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.09) 2px,
    rgba(0,0,0,0.09) 3px
  );
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-up);
}

.terminal-dots {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.dot {
  width: 10px;
  height: 10px;
  display: inline-block;
}

.dot-red    { background: var(--red);    }
.dot-yellow { background: var(--yellow); }
.dot-green  { background: var(--green);  }

.terminal-title {
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  text-align: center;
}

.terminal-body {
  padding: 24px;
  overflow-x: auto;
}

.code-block {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text);
  line-height: 1.65;
  white-space: pre;
}

.code-comment {
  color: var(--muted);
}

.code-keyword {
  color: var(--amber-dim);
}

.code-string {
  color: var(--amber);
}

/* === HERO === */
.hero {
  padding: 72px 0 56px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-symbol {
  font-family: 'VT323', monospace;
  font-size: 40px;
  color: var(--amber-dim);
  text-shadow: 0 0 10px rgba(255,179,0,0.25);
  display: block;
  margin-bottom: 8px;
  line-height: 1;
}

.hero-title {
  font-family: 'VT323', monospace;
  font-size: 104px;
  color: var(--amber);
  text-shadow: 0 0 24px rgba(255,179,0,0.55), 0 0 48px rgba(255,179,0,0.18);
  line-height: 1;
  animation: flicker 9s infinite;
  margin-bottom: 16px;
}

.hero-tagline {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.14em;
  margin-bottom: 52px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 56px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-number {
  font-family: 'VT323', monospace;
  font-size: 52px;
  color: var(--amber);
  text-shadow: 0 0 12px rgba(255,179,0,0.4);
  line-height: 1;
  display: block;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: block;
  margin-top: 4px;
}

/* === SECTION === */
.section {
  margin-top: 56px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.section-label {
  font-size: 11px;
  color: var(--amber);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* === ABOUT STRIP === */
.about-strip {
  display: grid;
  grid-template-columns: 3px 1fr;
}

.about-bar {
  background: var(--amber);
}

.about-content {
  background: var(--bg-up);
  border: 1px solid var(--border);
  border-left: none;
  padding: 28px 32px;
}

.about-heading {
  font-family: 'VT323', monospace;
  font-size: 30px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,179,0,0.28);
  margin-bottom: 10px;
  line-height: 1;
}

.about-text {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text);
  max-width: 700px;
}

.about-text + .about-text {
  margin-top: 12px;
}

/* === EPISODE GRID === */
.episode-grid {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.episode-card {
  background: var(--bg-up);
  padding: 20px 24px;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 20px;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.episode-card:hover {
  text-decoration: none;
}

a.episode-card:hover {
  background: var(--bg-code);
}

.episode-card.done {
  cursor: pointer;
}

.episode-card.wip,
.episode-card.next {
  opacity: 0.6;
  cursor: default;
}

.episode-number {
  font-family: 'VT323', monospace;
  font-size: 30px;
  color: var(--amber-dim);
  text-shadow: 0 0 6px rgba(255,179,0,0.18);
  line-height: 1;
}

.episode-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.episode-tool {
  font-size: 15px;
  color: var(--text);
  font-weight: 500;
}

.episode-desc {
  font-size: 12px;
  color: var(--muted);
}

.episode-badge {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 8px;
  border: 1px solid;
  white-space: nowrap;
}

.badge-done   { color: var(--green);      border-color: var(--green);      }
.badge-wip    { color: var(--yellow);     border-color: var(--yellow);     }
.badge-next   { color: var(--muted);      border-color: var(--border-up);  }
.badge-custom { color: var(--amber-dim);  border-color: var(--amber-dim);  }

/* === CORNER BRACKETS === */
.bracket-tl,
.bracket-br {
  position: absolute;
  width: 14px;
  height: 14px;
  pointer-events: none;
}

.bracket-tl { top: -1px;    left: -1px;   }
.bracket-br { bottom: -1px; right: -1px;  }

/* === SERIES SECTIONS === */
.series-group {
  margin-bottom: 32px;
}

.series-group-title {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}

/* === PAGE HEADINGS === */
.page-heading {
  font-family: 'VT323', monospace;
  font-size: 64px;
  color: var(--amber);
  text-shadow: 0 0 16px rgba(255,179,0,0.38);
  line-height: 1;
  margin-bottom: 8px;
}

.page-sub {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 48px;
  line-height: 1.6;
}

/* === VIDEO GRID === */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
}

.video-card {
  background: var(--bg-up);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background 0.12s;
}

.video-card:hover {
  background: var(--bg-code);
  text-decoration: none;
}

.video-thumb {
  aspect-ratio: 16 / 9;
  background: var(--bg-code);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.09) 2px,
    rgba(0,0,0,0.09) 3px
  );
}

.video-thumb-symbol {
  font-family: 'VT323', monospace;
  font-size: 44px;
  color: var(--amber-dim);
  text-shadow: 0 0 10px rgba(255,179,0,0.28);
}

.video-ep {
  font-size: 11px;
  color: var(--amber-dim);
  letter-spacing: 0.1em;
}

.video-title {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
}

.video-meta {
  font-size: 12px;
  color: var(--muted);
}

/* === EMPTY STATE === */
.empty-state {
  text-align: center;
  padding: 96px 24px;
  color: var(--muted);
  border: 1px solid var(--border);
  background: var(--bg-up);
}

.empty-symbol {
  font-family: 'VT323', monospace;
  font-size: 72px;
  color: var(--amber-dim);
  text-shadow: 0 0 12px rgba(255,179,0,0.2);
  display: block;
  margin-bottom: 16px;
  line-height: 1;
}

.empty-text {
  font-size: 14px;
  margin-bottom: 6px;
  color: var(--text);
}

.empty-sub {
  font-size: 12px;
  color: var(--muted);
}

.empty-sub a {
  color: var(--amber-dim);
}

.empty-sub a:hover {
  color: var(--amber);
}

/* === FOOTER === */
footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 96px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: var(--amber-dim);
  text-shadow: 0 0 6px rgba(255,179,0,0.25);
}

.footer-copy {
  font-size: 12px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}

.footer-link:hover {
  color: var(--text);
  text-decoration: none;
}

/* === ARTICLE PAGES === */
.article-ep {
  font-family: 'VT323', monospace;
  font-size: 13px;
  color: var(--amber-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.article-ep::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--amber-dim);
}

.article-title {
  font-family: 'VT323', monospace;
  font-size: 72px;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255,179,0,0.45);
  line-height: 1;
  margin-bottom: 12px;
}

.article-tagline {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 48px;
  letter-spacing: 0.05em;
}

.article-tagline code {
  color: var(--text);
  font-family: 'IBM Plex Mono', monospace;
}

/* prose body */
.prose {
  max-width: 740px;
}

.prose h2 {
  font-family: 'VT323', monospace;
  font-size: 36px;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255,179,0,0.25);
  line-height: 1;
  margin-top: 56px;
  margin-bottom: 20px;
}

.prose h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-top: 36px;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}

.prose p {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 16px;
}

.prose p + .terminal {
  margin-top: 8px;
  margin-bottom: 24px;
}

.prose ul,
.prose ol {
  margin-bottom: 16px;
  padding-left: 0;
  list-style: none;
}

.prose li {
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  padding-left: 20px;
  position: relative;
  margin-bottom: 4px;
}

.prose ul > li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--amber-dim);
}

.prose ol {
  counter-reset: prose-counter;
}

.prose ol > li {
  counter-increment: prose-counter;
}

.prose ol > li::before {
  content: counter(prose-counter) '.';
  position: absolute;
  left: 0;
  color: var(--amber-dim);
  font-size: 13px;
}

.prose code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--amber);
  background: var(--bg-code);
  padding: 1px 5px;
  border: 1px solid var(--border);
}

.prose strong {
  font-weight: 700;
  color: var(--text);
}

.prose em {
  font-style: italic;
  color: var(--muted);
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* callout / concept box */
.callout {
  display: grid;
  grid-template-columns: 3px 1fr;
  margin: 32px 0;
}

.callout-bar {
  background: var(--amber);
}

.callout-body {
  background: var(--amber-ghost);
  border: 1px solid var(--border-up);
  border-left: none;
  padding: 20px 24px;
}

.callout-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber-dim);
  display: block;
  margin-bottom: 8px;
}

.callout-body p {
  margin-bottom: 0;
  font-size: 14px;
}

/* visual blocks (SVG / P5.js) */
.visual-block {
  margin: 40px 0;
  background: var(--bg-code);
  border: 1px solid var(--border);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.09) 2px,
    rgba(0,0,0,0.09) 3px
  );
}

.visual-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-up);
}

.visual-body {
  padding: 32px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
}

.visual-caption {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 12px 24px;
  border-top: 1px solid var(--border);
  font-style: italic;
}

/* p5 sketch container */
.p5-wrap {
  display: flex;
  justify-content: center;
}

.p5-wrap canvas {
  display: block;
  max-width: 100%;
}

/* comparison table */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 24px 0;
}

.compare-table th {
  color: var(--amber);
  font-weight: 700;
  text-align: left;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border-up);
  border-right: 1px solid var(--border);
  background: var(--bg-up);
}

.compare-table th:last-child {
  border-right: none;
}

.compare-table td {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
}

.compare-table td:last-child {
  border-right: none;
}

.compare-table tr:last-child td {
  border-bottom: none;
}

.compare-table .yes { color: var(--green);  }
.compare-table .no  { color: var(--red);    }
.compare-table .mid { color: var(--yellow); }

/* article navigation */
.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.article-nav-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 280px;
}

.article-nav-link:hover {
  color: var(--text);
  text-decoration: none;
}

.article-nav-link.next {
  text-align: right;
  margin-left: auto;
}

.nav-link-label {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber-dim);
}

.nav-link-title {
  font-family: 'VT323', monospace;
  font-size: 22px;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255,179,0,0.2);
  line-height: 1;
}

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .hero-title {
    font-size: 72px;
  }

  .hero-stats {
    gap: 36px;
  }

  .episode-card {
    grid-template-columns: 56px 1fr;
    padding: 16px 18px;
  }

  .episode-badge {
    display: none;
  }

  .about-content {
    padding: 20px 20px;
  }

  .nav-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 52px;
    left: -24px;
    right: -24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    z-index: 99;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-sep {
    display: none;
  }

  .page-heading {
    font-size: 48px;
  }
}

@media (max-width: 768px) {
  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .footer-links {
    justify-content: center;
  }
}
