/* ================================================
   ByteSizeNotes — Terminal Academy Design System
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=Fira+Code:wght@300;400;500&family=Karla:ital,wght@0,300;0,400;0,500;0,600;1,400&display=swap');

/* === CSS Variables === */
:root {
  --bg:        #080C14;
  --bg-2:      #0D1320;
  --surface:   #111827;
  --card:      #141d2e;
  --card-hover:#1a2540;
  --border:    rgba(0, 212, 255, 0.12);
  --border-2:  rgba(255,255,255,0.06);

  --cyan:      #00D4FF;
  --cyan-dim:  rgba(0, 212, 255, 0.15);
  --green:     #4ADE80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --amber:     #FBBF24;
  --pink:      #F472B6;

  --text:      #E2EAF4;
  --text-2:    #94A3B8;
  --text-3:    #4B5A6E;

  --font-display: 'Syne', sans-serif;
  --font-body:    'Karla', sans-serif;
  --font-code:    'Fira Code', monospace;

  --radius:    12px;
  --radius-lg: 20px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* === Background Grid === */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.025) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
  z-index: 0;
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-dim); }

/* ================================================
   NAVIGATION
   ================================================ */
nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 0 2rem;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(8, 12, 20, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-2);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.nav-logo span {
  color: var(--cyan);
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--cyan-dim);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--cyan);
}

/* Desktop Nav Menu */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  list-style: none;
}
.nav-menu > li { position: relative; }
.nav-menu > li > a {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 8px;
  transition: color var(--transition), background var(--transition);
}
.nav-menu > li > a:hover,
.nav-menu > li > a.active {
  color: var(--text);
  background: var(--surface);
}
.nav-menu > li > a .chevron {
  font-size: 0.6rem;
  transition: transform var(--transition);
  opacity: 0.6;
}
.nav-menu > li:hover > a .chevron { transform: rotate(180deg); }

/* Dropdown */
.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 220px;
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.18s ease;
  backdrop-filter: blur(20px);
  box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}
.nav-menu > li:hover .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.dropdown-section {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-2);
  margin-bottom: 4px;
}
.dropdown-section:last-child { border: none; margin: 0; }
.dropdown-label {
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-code);
}
.dropdown a {
  display: block;
  padding: 6px 10px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.825rem;
  border-radius: 6px;
  transition: all var(--transition);
}
.dropdown a:hover {
  color: var(--cyan);
  background: var(--cyan-dim);
  padding-left: 14px;
}

/* Mobile hamburger */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: 6px;
  background: none;
  border: none;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-2);
  border-radius: 2px;
  transition: all 0.25s ease;
}
.nav-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* Mobile menu */
.mobile-menu {
  display: none;
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(8, 12, 20, 0.98);
  backdrop-filter: blur(20px);
  z-index: 99;
  overflow-y: auto;
  padding: 1.5rem;
  flex-direction: column;
  gap: 0.5rem;
}
.mobile-menu.open { display: flex; }
.mobile-chapter {
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  overflow: hidden;
}
.mobile-chapter-title {
  padding: 12px 16px;
  font-family: var(--font-code);
  font-size: 0.8rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
}
.mobile-chapter a {
  display: block;
  padding: 10px 16px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.9rem;
  border-top: 1px solid var(--border-2);
  transition: all var(--transition);
}
.mobile-chapter a:hover { color: var(--cyan); background: var(--cyan-dim); }

/* ================================================
   HOME PAGE — HERO
   ================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 100px 2rem 4rem;
  position: relative;
  overflow: hidden;
}
.hero-glow {
  position: absolute;
  top: -20%;
  right: -10%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(0,212,255,0.1) 0%, transparent 70%);
  pointer-events: none;
}
.hero-glow-2 {
  position: absolute;
  bottom: 0;
  left: -5%;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(74,222,128,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-inner {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 1;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--cyan-dim);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--cyan);
  margin-bottom: 2rem;
  animation: fadeUp 0.6s ease both;
}
.hero-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 7vw, 5.5rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 1.5rem;
  animation: fadeUp 0.6s 0.1s ease both;
}
.hero h1 .accent { color: var(--cyan); }
.hero h1 .accent-2 { color: var(--green); }

.hero-sub {
  font-size: 1.15rem;
  color: var(--text-2);
  max-width: 520px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
  animation: fadeUp 0.6s 0.2s ease both;
}

.hero-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  animation: fadeUp 0.6s 0.3s ease both;
}

/* ================================================
   BUTTONS
   ================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--cyan);
  color: var(--bg);
}
.btn-primary:hover {
  background: #1BE0FF;
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.35);
}
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-2);
}
.btn-ghost:hover {
  background: var(--card);
  border-color: var(--border);
  transform: translateY(-2px);
}

/* ================================================
   STATS BAR
   ================================================ */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 3rem;
  padding: 2rem;
  margin-top: 4rem;
  border-top: 1px solid var(--border-2);
  animation: fadeUp 0.6s 0.4s ease both;
}
.stat {
  text-align: center;
}
.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  color: var(--cyan);
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-3);
  font-family: var(--font-code);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ================================================
   CHAPTERS SECTION
   ================================================ */
.section {
  padding: 5rem 2rem;
  position: relative;
  z-index: 1;
}
.section-inner { max-width: 1100px; margin: 0 auto; }

.section-header {
  margin-bottom: 3rem;
}
.section-tag {
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-tag::before {
  content: '//';
  opacity: 0.5;
}
.section-header h2 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.section-header p {
  color: var(--text-2);
  font-size: 1rem;
  margin-top: 0.75rem;
  max-width: 500px;
}

/* Chapter Group */
.chapter-group { margin-bottom: 3.5rem; }
.chapter-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.25rem;
}
.chapter-num {
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--bg);
  background: var(--cyan);
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}
.chapter-num.green { background: var(--green); }
.chapter-num.amber { background: var(--amber); }
.chapter-num.pink  { background: var(--pink); }
.chapter-group-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-2);
  letter-spacing: -0.02em;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Topic Card — full background image */
.card {
  display: block;
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  cursor: pointer;
  height: 220px;
  background-size: cover;
  background-position: center;
  background-color: var(--card);
  border: 1px solid var(--border-2);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              border-color 0.3s ease;
}
.card:hover {
  transform: translateY(-5px) scale(1.01);
  box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,212,255,0.15);
  border-color: rgba(0,212,255,0.25);
}

/* Dark gradient overlay */
.card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(8,12,20,0.3) 0%,
    rgba(8,12,20,0.65) 50%,
    rgba(8,12,20,0.92) 100%
  );
  transition: background 0.3s ease;
}
.card:hover .card-overlay {
  background: linear-gradient(
    160deg,
    rgba(8,12,20,0.2) 0%,
    rgba(8,12,20,0.55) 50%,
    rgba(8,12,20,0.88) 100%
  );
}

/* Cyan top accent line on hover */
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--green));
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 2;
}
.card:hover::before { opacity: 1; }

/* Text content sits above overlay */
.card-content {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 1.25rem;
  z-index: 1;
}
.card-topic {
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
  opacity: 0.85;
}
.card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
  line-height: 1.25;
  text-shadow: 0 1px 8px rgba(0,0,0,0.6);
}
.card-desc {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.65);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-arrow {
  position: absolute;
  top: 1rem;
  right: 1rem;
  color: rgba(255,255,255,0.3);
  font-size: 1rem;
  z-index: 1;
  transition: all 0.25s ease;
}
.card:hover .card-arrow {
  color: var(--cyan);
  transform: translate(2px, -2px);
}

/* ================================================
   ABOUT SECTION
   ================================================ */
.about-section {
  padding: 5rem 2rem;
  background: var(--bg-2);
  border-top: 1px solid var(--border-2);
  position: relative;
  z-index: 1;
}
.about-inner {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3rem;
  align-items: start;
}
.about-icon {
  width: 80px; height: 80px;
  background: var(--cyan-dim);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  flex-shrink: 0;
}
.about-content .section-tag { margin-bottom: 0.5rem; }
.about-content h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
}
.about-content p {
  color: var(--text-2);
  line-height: 1.8;
  font-size: 0.95rem;
}

/* ================================================
   FOOTER
   ================================================ */
footer {
  padding: 2rem;
  border-top: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: gap;
  position: relative;
  z-index: 1;
}
.footer-logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-3);
}
.footer-logo span { color: var(--cyan); }
.footer-text {
  font-size: 0.8rem;
  color: var(--text-3);
  font-family: var(--font-code);
}

/* ================================================
   CHAPTER PAGE
   ================================================ */
.chapter-page {
  padding-top: 64px;
  min-height: 100vh;
}
.chapter-hero {
  padding: 4rem 2rem 3rem;
  border-bottom: 1px solid var(--border-2);
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  position: relative;
  overflow: hidden;
}
.chapter-hero::after {
  content: '';
  position: absolute;
  right: 5%;
  top: 50%;
  transform: translateY(-50%);
  width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.chapter-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: var(--text-3);
  margin-bottom: 1.5rem;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.chapter-breadcrumb a { color: var(--text-3); text-decoration: none; transition: color var(--transition); }
.chapter-breadcrumb a:hover { color: var(--cyan); }
.chapter-breadcrumb .sep { opacity: 0.4; }

.chapter-hero-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}
.chapter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px; height: 60px;
  background: var(--cyan-dim);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-family: var(--font-code);
  font-size: 0.85rem;
  color: var(--cyan);
  font-weight: 500;
  flex-shrink: 0;
}
.chapter-hero-text h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 0.75rem;
}
.chapter-hero-text p {
  color: var(--text-2);
  font-size: 1rem;
  max-width: 550px;
}

/* Chapter Layout */
.chapter-layout {
  max-width: 900px;
  margin: 0 auto;
  padding: 3rem 2rem;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 3rem;
  align-items: start;
}

/* Sidebar TOC */
.chapter-toc {
  position: sticky;
  top: 80px;
}
.toc-title {
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-2);
}
.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-list a {
  display: block;
  padding: 6px 10px;
  font-size: 0.8rem;
  color: var(--text-3);
  text-decoration: none;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: 1.4;
}
.toc-list a:hover,
.toc-list a.active {
  color: var(--cyan);
  background: var(--cyan-dim);
  border-left-color: var(--cyan);
  padding-left: 14px;
}

/* Chapter Content */
.chapter-content { min-width: 0; }

.content-section {
  margin-bottom: 3rem;
  animation: fadeUp 0.5s ease both;
}
.content-section h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.content-section h2 .h-num {
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 2px 7px;
  border-radius: 4px;
}

/* Key-Value bullets */
.content-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.content-section ul li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--text-2);
  line-height: 1.6;
  transition: border-color var(--transition);
}
.content-section ul li:hover { border-color: var(--border); }
.content-section ul li::before {
  content: '▸';
  color: var(--cyan);
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 0.75rem;
}
.content-section ul li strong {
  color: var(--text);
  font-weight: 600;
}

/* Note callout */
.note {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(251, 191, 36, 0.06);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 10px;
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.6;
}
.note-icon {
  color: var(--amber);
  flex-shrink: 0;
  margin-top: 1px;
}

/* Example block */
.example {
  padding: 1.25rem;
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--green);
  border-radius: 0 10px 10px 0;
  margin-top: 1rem;
  font-size: 0.875rem;
}
.example-label {
  font-family: var(--font-code);
  font-size: 0.7rem;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
  font-weight: 500;
}
.example p { color: var(--text-2); line-height: 1.7; margin-bottom: 0.5rem; }
.example p:last-child { margin: 0; }
.code-inline {
  font-family: var(--font-code);
  font-size: 0.875em;
  color: var(--cyan);
  background: var(--cyan-dim);
  padding: 1px 6px;
  border-radius: 4px;
}
.highlight { color: var(--text); font-weight: 600; }

/* Chapter nav */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border-2);
  margin-top: 2rem;
}
.chapter-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-2);
  font-size: 0.875rem;
  transition: all var(--transition);
  flex: 1;
  max-width: 240px;
}
.chapter-nav-btn:hover {
  background: var(--card-hover);
  border-color: var(--border);
  color: var(--text);
}
.chapter-nav-btn.next { margin-left: auto; text-align: right; flex-direction: row-reverse; }
.chapter-nav-label {
  display: block;
  font-family: var(--font-code);
  font-size: 0.65rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.chapter-nav-title { font-weight: 600; line-height: 1.3; }

/* ================================================
   ANIMATIONS
   ================================================ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 768px) {
  .nav-menu { display: none; }
  .nav-toggle { display: flex; }

  .hero { padding: 100px 1.25rem 3rem; }
  .stats-bar { gap: 1.5rem; flex-wrap: wrap; }

  .section { padding: 3.5rem 1.25rem; }
  .cards-grid { grid-template-columns: 1fr; }

  .about-inner { grid-template-columns: 1fr; gap: 1.5rem; }

  .chapter-layout { grid-template-columns: 1fr; }
  .chapter-toc { display: none; }
  .chapter-hero { padding: 3rem 1.25rem 2rem; }
  .chapter-hero-inner { flex-direction: column; gap: 1rem; }

  footer {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    text-align: center;
  }
}

/* ================================================
   CHAPTER HERO — image background overlay
   ================================================ */
.chapter-hero {
  position: relative;
}
.chapter-hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(8,12,20,0.88) 0%,
    rgba(8,12,20,0.75) 60%,
    rgba(8,12,20,0.92) 100%
  );
  z-index: 0;
}
.chapter-hero-inner-wrap {
  position: relative;
  z-index: 1;
  padding: 4rem 2rem 3rem;
  max-width: 960px;
  margin: 0 auto;
}
.chapter-hero .chapter-breadcrumb {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

/* ── Click-to-open dropdown (overrides hover-only) ─────────────────────── */
.nav-menu > li.open .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ── Chapter Drawer ──────────────────────────────────────────────────────── */
#drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
  backdrop-filter: blur(4px);
}
#drawer-overlay.open { display: block; }

#chapter-drawer {
  position: fixed;
  top: 0;
  right: -420px;
  width: 400px;
  max-width: 92vw;
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border-2);
  z-index: 200;
  overflow-y: auto;
  padding: 1.5rem;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
#chapter-drawer.open { right: 0; }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-2);
}
.drawer-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--cyan);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#drawer-close {
  background: none;
  border: 1px solid var(--border-2);
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#drawer-close:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.drawer-group { margin-bottom: 1.25rem; }
.drawer-group-title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
  padding-left: 0.25rem;
}
.drawer-links { display: flex; flex-direction: column; gap: 2px; }
.drawer-links a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.drawer-links a:hover {
  background: rgba(0, 212, 255, 0.06);
  border-color: rgba(0, 212, 255, 0.2);
  color: var(--text);
}
.drawer-links a.current {
  background: rgba(0, 212, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.3);
  color: var(--cyan);
}
.drawer-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--cyan);
  opacity: 0.7;
  min-width: 28px;
}

/* ── All Chapters button in sidebar ──────────────────────────────────────── */
#all-chapters-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.65rem 0.75rem;
  margin-bottom: 1.25rem;
  background: rgba(0, 212, 255, 0.07);
  border: 1px solid rgba(0, 212, 255, 0.25);
  border-radius: 8px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.2s;
  text-align: left;
}
#all-chapters-btn:hover {
  background: rgba(0, 212, 255, 0.13);
  border-color: var(--cyan);
}
#all-chapters-btn svg {
  flex-shrink: 0;
  opacity: 0.8;
}

/* ── Flashcard hero button ─────────────────────────────────────────────── */
.btn-flash {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, #4ade80, #22d3ee);
  color: #080c14;
  border-radius: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}
.btn-flash:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(74,222,128,0.35); opacity: 0.95; }
.btn-flash-big { padding: 0.95rem 2rem; font-size: 1rem; }

/* ── Flashcard Feature Banner Section ─────────────────────────────────── */
.fc-banner-section {
  padding: 3rem 0;
  border-top: 1px solid var(--border-2);
  border-bottom: 1px solid var(--border-2);
  background: linear-gradient(180deg, transparent, rgba(74,222,128,0.03) 50%, transparent);
}
.fc-banner {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: 20px;
  padding: 2.5rem 3rem;
  position: relative;
  overflow: hidden;
}
.fc-banner::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(74,222,128,0.08), transparent 70%);
  pointer-events: none;
}
.fc-banner-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #4ade80;
  letter-spacing: 0.1em;
  margin-bottom: 0.75rem;
}
.fc-banner-h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 0.75rem;
  line-height: 1.1;
}
.fc-banner-h2 span { color: #4ade80; }
.fc-banner-p { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; margin-bottom: 1.25rem; }
.fc-banner-perks { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1.5rem; }
.fc-perk {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.fc-perk-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
  flex-shrink: 0;
}

/* Preview card */
.fc-banner-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.fc-preview-card {
  width: 100%;
  background: linear-gradient(135deg, rgba(0,212,255,0.06), rgba(74,222,128,0.04));
  border: 1px solid rgba(0,212,255,0.2);
  border-radius: 14px;
  padding: 1.5rem;
}
.fc-preview-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--cyan);
  letter-spacing: 0.08em;
  margin-bottom: 0.8rem;
}
.fc-preview-q {
  font-size: 1rem;
  color: var(--text);
  font-weight: 600;
  margin-bottom: 1rem;
}
.fc-preview-divider {
  height: 1px;
  background: var(--border-2);
  margin-bottom: 1rem;
}
.fc-preview-a { display: flex; flex-direction: column; gap: 0.4rem; }
.fc-preview-a div { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; }
.fc-preview-stats {
  display: flex;
  gap: 0.6rem;
}
.fc-ps {
  padding: 0.4rem 1rem;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
}
.fc-ps.correct { background: rgba(74,222,128,0.12); color: #4ade80; border: 1px solid rgba(74,222,128,0.25); }
.fc-ps.wrong { background: rgba(248,113,113,0.12); color: #f87171; border: 1px solid rgba(248,113,113,0.25); }
.fc-ps.skip { background: rgba(251,191,36,0.12); color: #fbbf24; border: 1px solid rgba(251,191,36,0.25); }

@media (max-width: 768px) {
  .fc-banner { grid-template-columns: 1fr; padding: 1.75rem; gap: 2rem; }
  .fc-banner::before { display: none; }
}
