/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --bg:         #09090b;
  --surface:    #111113;
  --surface2:   #18181b;
  --border:     rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);

  --text:       #f4f4f5;
  --text-muted: #71717a;
  --text-soft:  #a1a1aa;

  --primary:    #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow:  rgba(99,102,241,0.18);

  --html:  #f97316;
  --css:   #3b82f6;
  --js:    #eab308;

  --green:  #22c55e;
  --blue:   #3b82f6;
  --orange: #f97316;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
}

/* ============================================================
   RESET
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  /* space for Google Auto Ads anchor (sticky bottom) ad */
  padding-bottom: 80px;
}

/* ── AdSense in-content ad units ── */
.ad-unit {
  margin: 32px 0;
  text-align: center;
  min-height: 90px;
  overflow: hidden;
}
.ad-unit ins { display: block; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ============================================================
   NAVBAR
   ============================================================ */
.site-header {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(9,9,11,0.85);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.navbar {
  max-width: 1200px; margin: 0 auto;
  padding: 0 1.5rem;
  display: flex; align-items: center;
  height: 60px; gap: 1rem;
}
.logo {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.05rem; color: var(--text);
  letter-spacing: -0.01em; flex-shrink: 0;
}
.logo-icon {
  color: var(--primary); font-family: var(--mono);
  font-size: 1.1rem; font-weight: 600;
}
.nav-links {
  display: flex; gap: 0.125rem;
  margin-left: auto; align-items: center;
}
.nav-links li { position: relative; }
.nav-links > li > a {
  color: var(--text-soft); padding: 0.45rem 0.875rem;
  border-radius: var(--radius-sm); font-size: 0.9rem;
  display: block; transition: color 0.15s, background 0.15s;
}
.nav-links > li > a:hover { color: var(--text); background: var(--surface2); }

/* Dropdown */
.has-dropdown .dropdown {
  display: none; position: absolute; top: calc(100% + 8px);
  left: 0; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 170px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  overflow: hidden; padding: 0.375rem;
}
.has-dropdown:hover .dropdown { display: block; }
.dropdown li a {
  display: block; padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 0.875rem; transition: color 0.15s, background 0.15s;
}
.dropdown li a:hover { color: var(--text); background: var(--border); }

.nav-toggle {
  display: none; background: none; border: none;
  color: var(--text-soft); font-size: 1.25rem; margin-left: auto;
  padding: 0.25rem;
}

/* ============================================================
   HERO
   ============================================================ */
.hero {
  padding: 6rem 1.5rem 5rem;
  text-align: center;
  position: relative; overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(99,102,241,0.22) 0%, transparent 70%);
}
.hero::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}
.hero-content { position: relative; max-width: 680px; margin: 0 auto; }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  border: 1px solid var(--border); border-radius: 50px;
  padding: 0.3rem 0.875rem; font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 1.75rem; background: var(--surface);
}
.hero-eyebrow span { color: var(--primary); }

.hero h1 {
  font-size: clamp(2.2rem, 5vw, 3.6rem);
  font-weight: 800; line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 1.25rem;
}
.hero h1 .grad {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero p {
  font-size: 1.1rem; color: var(--text-muted);
  margin-bottom: 2.25rem; line-height: 1.7;
  max-width: 520px; margin-left: auto; margin-right: auto;
}
.hero-btns { display: flex; gap: 0.875rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.7rem 1.5rem; border-radius: var(--radius);
  font-weight: 600; font-size: 0.9rem; border: none;
  transition: all 0.18s; cursor: pointer; letter-spacing: -0.005em;
}
.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 0 0 0 var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 0 0 4px var(--primary-glow);
  transform: translateY(-1px);
}
.btn-ghost {
  background: var(--surface2); color: var(--text-soft);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); transform: translateY(-1px); }

/* ============================================================
   STATS BAR
   ============================================================ */
.stats-bar {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 1.5rem;
}
.stats-bar .inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; justify-content: center;
  gap: 4rem; flex-wrap: wrap; text-align: center;
}
.stat-num {
  font-size: 2rem; font-weight: 800;
  color: var(--primary); letter-spacing: -0.03em;
}
.stat-label { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.125rem; }

/* ============================================================
   SECTION WRAPPER
   ============================================================ */
.section { max-width: 1200px; margin: 0 auto; padding: 5rem 1.5rem; }
.section-label {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 0.75rem;
}
.section-title {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 800; letter-spacing: -0.02em;
  margin-bottom: 0.625rem;
}
.section-sub { color: var(--text-muted); margin-bottom: 3rem; font-size: 1rem; }

/* ============================================================
   COURSE CARDS
   ============================================================ */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.25rem;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.course-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.course-card.html::before { background: var(--html); }
.course-card.css::before  { background: var(--css); }
.course-card.js::before   { background: var(--js); }

.course-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
}
.course-card.html:hover { box-shadow: 0 16px 48px rgba(249,115,22,0.1); }
.course-card.css:hover  { box-shadow: 0 16px 48px rgba(59,130,246,0.1); }
.course-card.js:hover   { box-shadow: 0 16px 48px rgba(234,179,8,0.1); }

.course-icon {
  font-family: var(--mono); font-size: 1.5rem; font-weight: 700;
  margin-bottom: 1.25rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  border-radius: var(--radius);
}
.course-card.html .course-icon { background: rgba(249,115,22,0.12); color: var(--html); }
.course-card.css  .course-icon { background: rgba(59,130,246,0.12); color: var(--css); }
.course-card.js   .course-icon { background: rgba(234,179,8,0.12); color: var(--js); }

.course-card h3 {
  font-size: 1.1rem; font-weight: 700;
  letter-spacing: -0.01em; margin-bottom: 0.5rem;
}
.course-card > p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem; line-height: 1.6; }

.course-meta {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--text-muted);
  margin-bottom: 1.25rem; align-items: center;
}
.badge {
  padding: 0.2rem 0.625rem; border-radius: 50px;
  font-size: 0.73rem; font-weight: 600;
}
.badge-green  { background: rgba(34,197,94,0.12);  color: #4ade80; }
.badge-blue   { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.badge-yellow { background: rgba(234,179,8,0.12);   color: #facc15; }
.badge-orange { background: rgba(249,115,22,0.12);  color: #fb923c; }

.course-topics { margin-bottom: 1.75rem; flex: 1; }
.course-topics li {
  display: flex; align-items: center; gap: 0.625rem;
  color: var(--text-muted); font-size: 0.875rem;
  padding: 0.3rem 0; border-bottom: 1px solid var(--border);
}
.course-topics li:last-child { border-bottom: none; }
.course-topics li::before {
  content: '✓'; flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700;
}
.course-card.html .course-topics li::before { background: rgba(249,115,22,0.15); color: var(--html); }
.course-card.css  .course-topics li::before { background: rgba(59,130,246,0.15);  color: var(--css); }
.course-card.js   .course-topics li::before { background: rgba(234,179,8,0.15);   color: var(--js); }

.btn-course {
  display: flex; align-items: center; justify-content: center; gap: 0.375rem;
  padding: 0.65rem; border-radius: var(--radius);
  font-weight: 600; font-size: 0.875rem;
  transition: opacity 0.2s, transform 0.2s;
}
.course-card.html .btn-course { background: rgba(249,115,22,0.12); color: var(--html); }
.course-card.css  .btn-course { background: rgba(59,130,246,0.12);  color: #60a5fa; }
.course-card.js   .btn-course { background: rgba(234,179,8,0.12);   color: var(--js); }
.btn-course:hover { opacity: 0.85; transform: translateX(2px); }

/* ============================================================
   WHY SECTION
   ============================================================ */
.why-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1px; background: var(--border);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden;
}
.why-card {
  background: var(--surface); padding: 1.75rem 1.5rem;
  transition: background 0.2s;
}
.why-card:hover { background: var(--surface2); }
.why-icon { font-size: 1.75rem; margin-bottom: 0.875rem; }
.why-card h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.375rem; }
.why-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* ============================================================
   RESOURCE CARDS
   ============================================================ */
.resource-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.resource-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  display: flex; gap: 1rem; align-items: flex-start;
  transition: border-color 0.2s;
}
.resource-card:hover { border-color: var(--border-hover); }
.resource-icon { font-size: 1.75rem; flex-shrink: 0; }
.resource-card h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.25rem; }
.resource-card p { font-size: 0.83rem; color: var(--text-muted); margin-bottom: 0.625rem; line-height: 1.5; }
.resource-card a { font-size: 0.82rem; color: var(--primary); font-weight: 500; }
.resource-card a:hover { text-decoration: underline; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 3.5rem 1.5rem 1.5rem;
  margin-top: auto;
}
.footer-grid {
  max-width: 1200px; margin: 0 auto;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 3rem; margin-bottom: 2.5rem;
}
.footer-brand .logo { margin-bottom: 0.875rem; }
.footer-brand p { color: var(--text-muted); font-size: 0.875rem; line-height: 1.6; max-width: 240px; }
.footer-col h4 { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-soft); margin-bottom: 1rem; }
.footer-col ul li { margin-bottom: 0.5rem; }
.footer-col ul li a { color: var(--text-muted); font-size: 0.875rem; transition: color 0.15s; }
.footer-col ul li a:hover { color: var(--text); }
.footer-bottom {
  max-width: 1200px; margin: 0 auto;
  border-top: 1px solid var(--border); padding-top: 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem;
  color: var(--text-muted); font-size: 0.8rem;
}

/* ============================================================
   TUTORIAL LAYOUT
   ============================================================ */
.tutorial-layout {
  max-width: 1200px; margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 2.5rem; align-items: start;
}

/* ---- Sidebar ---- */
.sidebar-nav {
  position: sticky; top: 76px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-nav h3 {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-muted); margin-bottom: 0.875rem; padding: 0 0.5rem;
}
.sidebar-nav .chapter {
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-soft); padding: 0 0.5rem;
  margin-top: 1.25rem; margin-bottom: 0.25rem;
}
.sidebar-nav a {
  display: block; padding: 0.45rem 0.625rem;
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: 0.855rem; transition: color 0.15s, background 0.15s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-nav a:hover { color: var(--text); background: var(--surface2); }
.sidebar-nav a.active { color: var(--primary); background: var(--primary-glow); }

/* ---- Lesson Content ---- */
.lesson-content { min-width: 0; }

.lesson-content h1 {
  font-size: 2rem; font-weight: 800;
  letter-spacing: -0.03em; margin-bottom: 0.5rem;
}
.lesson-meta {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  color: var(--text-muted); font-size: 0.83rem;
  margin-bottom: 2.5rem; padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.lesson-content h2 {
  font-size: 1.3rem; font-weight: 700;
  letter-spacing: -0.02em;
  margin: 2.5rem 0 1rem; color: var(--text);
}
.lesson-content h3 { font-size: 1.05rem; font-weight: 600; margin: 1.75rem 0 0.75rem; }
.lesson-content p  { color: var(--text-soft); margin-bottom: 1rem; line-height: 1.75; }
.lesson-content ul { margin: 0.75rem 0 1.25rem 0; }
.lesson-content ul li {
  color: var(--text-soft); margin-bottom: 0.375rem;
  padding-left: 1.25rem; position: relative; font-size: 0.95rem;
}
.lesson-content ul li::before {
  content: '–'; position: absolute; left: 0; color: var(--text-muted);
}
.lesson-content code {
  font-family: var(--mono); font-size: 0.85em;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.1em 0.4em; color: #a78bfa;
}

/* ---- Code Block ---- */
.code-block {
  background: #0d0d10;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin: 1.25rem 0;
  overflow-x: auto;
  position: relative;
}
.code-block pre {
  font-family: var(--mono); font-size: 0.875rem;
  color: #c9d1d9; line-height: 1.75; tab-size: 2;
}
.code-lang {
  position: absolute; top: 0.75rem; right: 0.875rem;
  font-size: 0.7rem; color: var(--text-muted);
  font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 0.06em;
}
.copy-btn {
  position: absolute; top: 0.65rem; right: 4rem;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-muted); padding: 0.2rem 0.6rem;
  border-radius: 4px; font-size: 0.72rem; font-weight: 500;
  transition: all 0.15s;
}
.copy-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.copy-btn.copied { background: #22c55e; color: #fff; border-color: #22c55e; }

/* Syntax highlighting */
.kw  { color: #c084fc; } /* keyword — purple */
.tag { color: #4ade80; } /* html tag — green */
.attr{ color: #60a5fa; } /* attribute — blue */
.str { color: #a5f3fc; } /* string — cyan */
.com { color: #52525b; font-style: italic; } /* comment — dark gray */
.num { color: #fb923c; } /* number — orange */
.fn  { color: #f0abfc; } /* function — pink */

/* ---- Lesson Nav ---- */
.lesson-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 3.5rem; padding-top: 1.75rem;
  border-top: 1px solid var(--border); gap: 1rem;
}
.lesson-nav a {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.6rem 1.125rem; border-radius: var(--radius);
  border: 1px solid var(--border); color: var(--text-soft);
  font-size: 0.875rem; font-weight: 500;
  transition: all 0.15s;
}
.lesson-nav a:hover {
  color: var(--text); border-color: var(--border-hover);
  background: var(--surface2);
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.8rem; color: var(--text-muted);
  padding: 1rem 1.5rem; max-width: 1200px; margin: 0 auto;
}
.breadcrumb a { color: var(--text-muted); transition: color 0.15s; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb span { color: var(--border-hover); }

/* ============================================================
   404 PAGE
   ============================================================ */
.error-page {
  min-height: 70vh; display: flex; align-items: center;
  justify-content: center; text-align: center; padding: 4rem 1.5rem;
}
.error-page h1 { font-size: 6rem; font-weight: 900; color: var(--primary); opacity: 0.3; line-height: 1; }
.error-page h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; }
.error-page p { color: var(--text-muted); margin-bottom: 2rem; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* ── Mobile sidebar toggle button ── */
.sidebar-toggle-btn {
  display: none;
}

@media (max-width: 960px) {
  .tutorial-layout { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
  /* Sidebar toggle button visible on tablet/mobile */
  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-soft);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 12px 16px;
    cursor: pointer;
    margin-bottom: 0;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar-toggle-btn:hover { background: var(--border); color: var(--text); }
  .sidebar-toggle-btn.open {
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom-color: transparent;
  }
  .sidebar-toggle-btn .toggle-arrow {
    margin-left: auto;
    transition: transform 0.2s;
    font-style: normal;
  }
  .sidebar-toggle-btn.open .toggle-arrow { transform: rotate(180deg); }

  /* Sidebar: hidden with no border/padding when collapsed */
  .sidebar-nav {
    overflow: hidden;
    max-height: 0;
    padding: 0;
    border: none;
    background: var(--surface2);
    border-radius: 0 0 var(--radius) var(--radius);
    position: static !important;
    transition: max-height 0.35s ease, padding 0.35s ease;
  }
  .sidebar-nav.open {
    max-height: 2000px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-top: none;
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none; flex-direction: column;
    position: fixed; top: 60px; left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem; gap: 0.125rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1000;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
  }
  .nav-links.open { display: flex; z-index: 1001; }
  .nav-links > li > a { font-size: 0.95rem; padding: 0.65rem 0.875rem; }
  .nav-toggle { display: block; }

  /* Mobile: courses dropdown inline (not absolute) */
  .has-dropdown .dropdown,
  .has-dropdown:hover .dropdown {
    display: none !important;
    position: static !important;
    box-shadow: none !important;
    border: none !important;
    background: var(--surface2) !important;
    border-radius: var(--radius-sm) !important;
    margin: 2px 0 4px 12px !important;
    padding: 0.25rem !important;
    min-width: unset !important;
  }
  .has-dropdown.open .dropdown { display: block !important; }

  .hero { padding: 4rem 1.25rem 3.5rem; }
  .stats-bar .inner { gap: 2rem; }
  .lesson-nav { flex-direction: column; }
  .lesson-nav a { width: 100%; justify-content: center; }
  .footer-grid { grid-template-columns: 1fr; gap: 2rem; }
  .footer-bottom { flex-direction: column; text-align: center; }
  .why-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .why-grid { grid-template-columns: 1fr; }
}
