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

:root {
  --bg:       #0a0a0f;
  --bg2:      #0f0f1a;
  --bg3:      #13131f;
  --border:   rgba(255,255,255,0.08);
  --yellow:   #f7df1e;
  --yellow-d: #c9b200;
  --purple:   #a855f7;
  --blue:     #3b82f6;
  --text:     #e2e8f0;
  --text-2:   #94a3b8;
  --text-3:   #64748b;
  --radius:   12px;
  --radius-lg:20px;
  --shadow:   0 4px 32px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
img { display: block; max-width: 100%; }

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

.section { padding: 96px 0; }

.section-header {
  text-align: center;
  margin-bottom: 56px;
}

.section-tag {
  display: inline-block;
  background: rgba(247,223,30,0.12);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(247,223,30,0.2);
  margin-bottom: 16px;
}

.section-title {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 16px;
}

.section-desc {
  color: var(--text-2);
  font-size: 1.1rem;
  max-width: 560px;
  margin: 0 auto;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--yellow);
  color: #111;
}
.btn-primary:hover {
  background: #ffe94d;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(247,223,30,0.3);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.05);
  transform: translateY(-2px);
}

.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.14);
  transform: translateY(-2px);
}

.btn-nav {
  background: var(--yellow);
  color: #111;
  padding: 8px 16px;
  font-size: 0.875rem;
  border-radius: 8px;
}
.btn-nav:hover { background: #ffe94d; }

.btn-lg { padding: 15px 32px; font-size: 1rem; }

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 0 24px;
  transition: background 0.3s, backdrop-filter 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}
.navbar.scrolled {
  background: rgba(10,10,15,0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 68px;
  gap: 32px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.logo-icon {
  font-family: 'Fira Code', monospace;
  font-weight: 500;
  font-size: 1rem;
  background: var(--yellow);
  color: #111;
  padding: 4px 8px;
  border-radius: 6px;
}

.logo-text {
  font-weight: 700;
  font-size: 1rem;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.nav-links a {
  color: var(--text-2);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
}
.nav-links a:hover { color: var(--text); background: rgba(255,255,255,0.06); }

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ===== HERO ===== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding-top: 68px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 64px 64px;
}

.glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
}
.glow-1 {
  width: 600px; height: 600px;
  background: var(--yellow);
  top: -100px; right: -100px;
}
.glow-2 {
  width: 400px; height: 400px;
  background: var(--purple);
  bottom: 0; left: -80px;
}

.hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 64px;
  align-items: center;
  width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(247,223,30,0.1);
  border: 1px solid rgba(247,223,30,0.25);
  color: var(--yellow);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 24px;
  letter-spacing: 0.05em;
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

.highlight {
  color: var(--yellow);
  position: relative;
}

.hero-desc {
  font-size: 1.125rem;
  color: var(--text-2);
  max-width: 520px;
  margin-bottom: 40px;
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 56px;
}

.hero-stats {
  display: flex;
  align-items: center;
  gap: 24px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-num {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--yellow);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.stat-suffix {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--yellow);
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-3);
  font-weight: 500;
  margin-top: 4px;
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
}

/* ===== BOOK ===== */
.hero-book { display: flex; align-items: center; justify-content: center; }

.book-wrapper {
  position: relative;
  perspective: 1000px;
}

.book {
  display: flex;
  transform: rotateY(-15deg);
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
  cursor: pointer;
}
.book:hover { transform: rotateY(-5deg) rotateX(2deg); }

.book-cover {
  width: 220px;
  min-height: 300px;
  background: linear-gradient(145deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 4px 12px 12px 4px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow:
    4px 4px 0 rgba(0,0,0,0.3),
    8px 8px 0 rgba(0,0,0,0.2),
    0 20px 60px rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.1);
}

.book-spine {
  width: 28px;
  min-height: 300px;
  background: linear-gradient(to right, #0a0a14, #16213e);
  border-radius: 0 0 0 0;
  border-left: 1px solid rgba(255,255,255,0.05);
  transform: rotateY(90deg) translateZ(14px) translateX(14px);
  transform-origin: left center;
}

.book-cover-top {
  display: flex;
  justify-content: flex-end;
}

.book-tag {
  background: var(--yellow);
  color: #111;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.1em;
}

.book-title-wrap {
  text-align: center;
  padding: 16px 0;
}

.book-js-icon {
  font-family: 'Fira Code', monospace;
  font-size: 2rem;
  font-weight: 500;
  background: var(--yellow);
  color: #111;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  margin: 0 auto 12px;
}

.book-cover-title {
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: #fff;
}
.book-cover-title span { color: var(--yellow); }

.book-cover-code {
  background: rgba(0,0,0,0.4);
  border-radius: 8px;
  padding: 12px;
  font-family: 'Fira Code', monospace;
  font-size: 0.7rem;
  line-height: 1.8;
  border: 1px solid rgba(255,255,255,0.08);
}

.code-line { display: block; }
.book-cover-code .kw  { color: #c792ea; }
.book-cover-code .fn  { color: #82aaff; }
.book-cover-code .str { color: #c3e88d; }

.book-author {
  text-align: right;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

.book-shadow {
  position: absolute;
  bottom: -24px;
  left: 14px;
  right: -10px;
  height: 40px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.5) 0%, transparent 70%);
  filter: blur(8px);
}

/* ===== TOPICS ===== */
.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.topic-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  opacity: 0;
  transform: translateY(20px);
}
.topic-card.visible {
  opacity: 1;
  transform: translateY(0);
}
.topic-card:hover {
  border-color: rgba(247,223,30,0.3);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(247,223,30,0.08);
}

.topic-icon {
  font-size: 2rem;
  margin-bottom: 16px;
}

.topic-card h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.topic-card p {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.6;
}

/* ===== TOC ===== */
.toc-section { background: var(--bg2); }

.toc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.toc-chapter {
  display: flex;
  gap: 16px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}
.toc-chapter:hover { border-color: rgba(247,223,30,0.25); }

.chapter-num {
  font-family: 'Fira Code', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: rgba(247,223,30,0.3);
  flex-shrink: 0;
  width: 36px;
  line-height: 1;
  padding-top: 2px;
}

.chapter-body h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.chapter-body ul { display: flex; flex-direction: column; gap: 4px; }

.chapter-body li {
  font-size: 0.8125rem;
  color: var(--text-2);
  padding-left: 12px;
  position: relative;
}
.chapter-body li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--text-3);
}

/* ===== CODE PREVIEW ===== */
.code-preview { background: var(--bg); }

.code-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  font-family: inherit;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active {
  color: var(--yellow);
  border-bottom-color: var(--yellow);
}

.code-blocks { position: relative; }

.code-block {
  display: none;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 28px 32px;
  font-family: 'Fira Code', monospace;
  font-size: 0.875rem;
  line-height: 1.9;
  overflow-x: auto;
  color: #e2e8f0;
}
.code-block.active { display: block; }

/* code syntax colors */
.code-block .kw  { color: #c792ea; }
.code-block .fn  { color: #82aaff; }
.code-block .str { color: #c3e88d; }
.code-block .num { color: #f78c6c; }
.code-block .c   { color: #546e7a; font-style: italic; }
.code-block .tmpl { color: #89ddff; }

/* ===== ABOUT ===== */
.about { background: var(--bg2); }

.about-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 56px;
  display: flex;
  gap: 56px;
  align-items: center;
  max-width: 860px;
  margin: 0 auto;
}

.about-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-circle {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--yellow), var(--yellow-d));
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.profile-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  animation: float 3s ease-in-out infinite, glowPulse 2s ease-in-out infinite alternate;
  transition: transform 0.3s ease;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

@keyframes glowPulse {
  0% { filter: drop-shadow(0 0 8px rgba(247, 201, 72, 0.5)); }
  100% { filter: drop-shadow(0 0 16px rgba(247, 201, 72, 0.8)); }
}

.avatar-circle:hover .profile-img {
  animation-play-state: paused;
  transform: scale(1.05);
}

.avatar-glow {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  background: var(--yellow);
  opacity: 0.15;
  filter: blur(16px);
}

.about-content .section-tag { display: inline-block; margin-bottom: 12px; }

.about-content h2 {
  font-size: 1.75rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.about-content p {
  color: var(--text-2);
  line-height: 1.7;
  margin-bottom: 32px;
}

.about-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== CTA BANNER ===== */
.cta-banner {
  background: linear-gradient(135deg, rgba(247,223,30,0.07) 0%, rgba(168,85,247,0.07) 100%);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 96px 0;
}

.cta-inner {
  text-align: center;
  max-width: 640px;
  margin: 0 auto;
}

.cta-inner h2 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 800;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.cta-inner p {
  color: var(--text-2);
  font-size: 1.125rem;
  margin-bottom: 40px;
}

.cta-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== FOOTER ===== */
.footer {
  background: var(--bg);
  padding: 40px 0;
  border-top: 1px solid var(--border);
}

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

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.footer-copy {
  font-size: 0.85rem;
  color: var(--text-3);
}

.footer-copy a { color: var(--text-2); }
.footer-copy a:hover { color: var(--yellow); }

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

.footer-links a {
  font-size: 0.85rem;
  color: var(--text-3);
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--yellow); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .hero-inner {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 60px 24px;
    gap: 48px;
  }
  .hero-content { order: 1; }
  .hero-book { order: 0; }
  .hero-desc { margin-left: auto; margin-right: auto; }
  .hero-actions { justify-content: center; }
  .hero-stats { justify-content: center; }

  .about-card {
    flex-direction: column;
    text-align: center;
    padding: 40px 32px;
    gap: 32px;
  }
  .about-actions { justify-content: center; }
}

@media (max-width: 640px) {
  .nav-links { display: none; flex-direction: column; width: 100%; }
  .nav-links.open {
    display: flex;
    position: absolute;
    top: 68px; left: 0; right: 0;
    background: rgba(10,10,15,0.97);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    gap: 4px;
  }
  .nav-toggle { display: flex; }

  .hero-title { font-size: 2.2rem; }
  .section { padding: 64px 0; }

  .toc-grid { grid-template-columns: 1fr; }
  .topics-grid { grid-template-columns: 1fr 1fr; }

  .footer-inner { flex-direction: column; text-align: center; }

  .about-card { padding: 32px 20px; }

  .cta-actions { flex-direction: column; align-items: center; }
}

@media (max-width: 440px) {
  .topics-grid { grid-template-columns: 1fr; }
  .hero-stats { flex-direction: column; gap: 16px; }
  .stat-divider { width: 60px; height: 1px; }
}
