/* ============================================================
   MATERIAL DESIGN 3 – CUSTOM THEME
   Unified visual identity for the entire web application.
   Uses MD3 color tokens, type-scale, and elevation system.
   ============================================================ */

/* ---------- MD3 Color Tokens (Light Theme) ---------- */
:root {
  /* Primary - Neon Cyan */
  --md-sys-color-primary: #00e5ff;
  --md-sys-color-on-primary: #00232a;
  --md-sys-color-primary-container: #003844;
  --md-sys-color-on-primary-container: #80f0ff;

  /* Secondary - Neon Magenta */
  --md-sys-color-secondary: #ff2d95;
  --md-sys-color-on-secondary: #3a0020;
  --md-sys-color-secondary-container: #520035;
  --md-sys-color-on-secondary-container: #ffa8d0;

  /* Tertiary - Neon Lime */
  --md-sys-color-tertiary: #b8ff00;
  --md-sys-color-on-tertiary: #1a2800;
  --md-sys-color-tertiary-container: #2a3d00;
  --md-sys-color-on-tertiary-container: #d4ff66;

  /* Error - Neon Red */
  --md-sys-color-error: #ff4455;
  --md-sys-color-on-error: #400008;
  --md-sys-color-error-container: #5c0010;
  --md-sys-color-on-error-container: #ffa0a8;

  /* Surface & Background - Charcoal */
  --md-sys-color-surface: #121218;
  --md-sys-color-on-surface: #e0e4ec;
  --md-sys-color-surface-variant: #2a2a36;
  --md-sys-color-on-surface-variant: #b0b4c0;
  --md-sys-color-surface-container-lowest: #0d0d14;
  --md-sys-color-surface-container-low: #181820;
  --md-sys-color-surface-container: #1e1e28;
  --md-sys-color-surface-container-high: #262630;
  --md-sys-color-surface-container-highest: #30303c;
  --md-sys-color-inverse-surface: #e0e4ec;
  --md-sys-color-inverse-on-surface: #121218;

  /* Outline */
  --md-sys-color-outline: #6a6a7a;
  --md-sys-color-outline-variant: #3a3a4a;

  /* Elevation - neon glow tints */
  --md-sys-elevation-1: 0 1px 4px rgba(0,229,255,.06), 0 1px 2px rgba(0,0,0,.20);
  --md-sys-elevation-2: 0 2px 8px rgba(0,229,255,.08), 0 1px 3px rgba(0,0,0,.24);
  --md-sys-elevation-3: 0 4px 12px rgba(0,229,255,.10), 0 2px 4px rgba(0,0,0,.28);

  /* Type scale */
  --md-sys-typescale-display-font: 'Outfit', sans-serif;
  --md-sys-typescale-body-font: 'Outfit', sans-serif;
  --md-sys-typescale-code-font: 'Source Code Pro', monospace;

  /* Shape - sharper corners for cyberpunk */
  --md-sys-shape-corner-xs: 2px;
  --md-sys-shape-corner-sm: 4px;
  --md-sys-shape-corner-md: 6px;
  --md-sys-shape-corner-lg: 8px;
  --md-sys-shape-corner-xl: 12px;

  /* Motion */
  --md-sys-motion-duration-short: 200ms;
  --md-sys-motion-duration-medium: 400ms;
  --md-sys-motion-easing-standard: cubic-bezier(0.2, 0, 0, 1);
  --md-sys-motion-easing-emphasized: cubic-bezier(0.2, 0, 0, 1);

  /* Cyberpunk extras */
  --cp-glow-cyan: 0 0 12px rgba(0,229,255,.3);
  --cp-glow-magenta: 0 0 12px rgba(255,45,149,.3);
  --cp-glow-lime: 0 0 12px rgba(184,255,0,.3);
}

/* ---------- Deep Dark (Midnight) ---------- */
/* Even deeper cyberpunk void for system dark preference */
@media (prefers-color-scheme: dark) {
  :root:not(.light):not(.dark) {
    --md-sys-color-surface: #06060c;
    --md-sys-color-surface-container-lowest: #04040a;
    --md-sys-color-surface-container-low: #0c0c16;
    --md-sys-color-surface-container: #12121e;
    --md-sys-color-surface-container-high: #1a1a28;
    --md-sys-color-surface-container-highest: #242434;
    --md-sys-color-outline-variant: #2a2a3c;
    --cp-glow-cyan: 0 0 16px rgba(0,229,255,.35);
    --cp-glow-magenta: 0 0 16px rgba(255,45,149,.35);
  }
}

/* Manual dark mode (Midnight) */
:root.dark {
  --md-sys-color-surface: #06060c;
  --md-sys-color-surface-container-lowest: #04040a;
  --md-sys-color-surface-container-low: #0c0c16;
  --md-sys-color-surface-container: #12121e;
  --md-sys-color-surface-container-high: #1a1a28;
  --md-sys-color-surface-container-highest: #242434;
  --md-sys-color-outline-variant: #2a2a3c;
  --cp-glow-cyan: 0 0 16px rgba(0,229,255,.35);
  --cp-glow-magenta: 0 0 16px rgba(255,45,149,.35);
}

/* Manual light mode (White Neon - light cyberpunk) */
:root.light {
  --md-sys-color-primary: #0097a7;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: #d6f7ff;
  --md-sys-color-on-primary-container: #003840;
  --md-sys-color-secondary: #c2185b;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-secondary-container: #ffe0ec;
  --md-sys-color-on-secondary-container: #3e0020;
  --md-sys-color-tertiary: #558b2f;
  --md-sys-color-on-tertiary: #ffffff;
  --md-sys-color-tertiary-container: #e4ffcc;
  --md-sys-color-on-tertiary-container: #1a2e00;
  --md-sys-color-error: #d32f2f;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-error-container: #ffdad6;
  --md-sys-color-on-error-container: #410002;
  --md-sys-color-surface: #fafcff;
  --md-sys-color-on-surface: #141420;
  --md-sys-color-surface-variant: #e8eaf0;
  --md-sys-color-on-surface-variant: #3a3c4a;
  --md-sys-color-surface-container-lowest: #ffffff;
  --md-sys-color-surface-container-low: #f2f4fa;
  --md-sys-color-surface-container: #eaecf4;
  --md-sys-color-surface-container-high: #e2e4ee;
  --md-sys-color-surface-container-highest: #dadce8;
  --md-sys-color-inverse-surface: #1a1a28;
  --md-sys-color-inverse-on-surface: #eceef6;
  --md-sys-color-outline: #6a6c80;
  --md-sys-color-outline-variant: #c4c6d4;
  --md-sys-elevation-1: 0 1px 3px 1px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.10);
  --md-sys-elevation-2: 0 2px 6px 2px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.10);
  --md-sys-elevation-3: 0 4px 8px 3px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.10);
  --cp-glow-cyan: 0 0 12px rgba(0,151,167,.2);
  --cp-glow-magenta: 0 0 12px rgba(194,24,91,.2);
  --cp-glow-lime: 0 0 12px rgba(85,139,47,.2);
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--md-sys-typescale-body-font);
  background-color: var(--md-sys-color-surface);
  background-image:
    linear-gradient(rgba(0,229,255,.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,.02) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--md-sys-color-on-surface);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Starfield canvas - sits behind all content */
#starfield {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ============================================================
   TYPOGRAPHY – MD3 TYPE SCALE
   ============================================================ */
.headline-medium { font-size: 1.75rem;   line-height: 2.25rem; font-weight: 500; }
.headline-small  { font-size: 1.5rem;    line-height: 2rem;    font-weight: 500; }

.title-large  { font-size: 1.375rem; line-height: 1.75rem; font-weight: 500; }
.title-medium { font-size: 1rem;     line-height: 1.5rem;  font-weight: 600; letter-spacing: 0.15px; }
.body-medium { font-size: 0.875rem; line-height: 1.5rem;  font-weight: 400; letter-spacing: 0.25px; }
.body-small  { font-size: 0.75rem;  line-height: 1.25rem; font-weight: 400; letter-spacing: 0.4px; }

.label-large  { font-size: 0.875rem; line-height: 1.25rem; font-weight: 600; letter-spacing: 0.1px; }

/* ============================================================
   NAVIGATION BAR (Top App Bar – MD3)
   ============================================================ */
.top-app-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  padding: 0 16px;
  background-color: var(--md-sys-color-surface-container-low);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: 0 1px 0 rgba(0,229,255,.08), var(--md-sys-elevation-2);
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.top-app-bar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.top-app-bar__brand .material-symbols-outlined {
  font-size: 28px;
}

/* Desktop navigation links */
.top-app-bar__nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--md-sys-shape-corner-xl);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.1px;
  color: var(--md-sys-color-on-surface-variant);
  transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.nav-link:hover {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.nav-link.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.nav-link .material-symbols-outlined {
  font-size: 20px;
}

/* Desktop: three columns (brand | nav | theme toggle). The two side
   columns share the leftover space equally, so the nav sits in the
   true centre of the bar. Below 769px the flex layout above is used. */
@media (min-width: 769px) {
  .top-app-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }

  .top-app-bar__brand {
    justify-self: start;
  }

  .theme-toggle {
    justify-self: end;
  }
}

/* Hamburger menu button (mobile) */
.menu-toggle {
  display: none;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface);
  padding: 8px;
  border-radius: 50%;
}

.menu-toggle:hover {
  background-color: var(--md-sys-color-surface-container-high);
}

.menu-toggle .material-symbols-outlined {
  font-size: 24px;
}

/* Mobile drawer */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1100;
  opacity: 0;
  transition: opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

.mobile-drawer-overlay.open {
  opacity: 1;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background-color: var(--md-sys-color-surface-container-low);
  z-index: 1200;
  transform: translateX(-100%);
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
  border-radius: 0 var(--md-sys-shape-corner-lg) var(--md-sys-shape-corner-lg) 0;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-drawer__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin-bottom: 8px;
  color: var(--md-sys-color-primary);
  font-weight: 700;
  font-size: 1.25rem;
}

.mobile-drawer .nav-link {
  width: 100%;
  padding: 14px 20px;
  border-radius: var(--md-sys-shape-corner-xl);
  font-size: 0.9375rem;
}

/* ============================================================
   MAIN CONTENT LAYOUT
   ============================================================ */
.main-content {
  margin-top: 64px;
  min-height: calc(100vh - 64px);
}

.page-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ============================================================
   MD3 CARDS
   ============================================================ */
.card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-lg);
  border: 1px solid var(--md-sys-color-outline-variant);
  padding: 24px;
  margin-bottom: 24px;
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.card--elevated {
  border: none;
  box-shadow: var(--md-sys-elevation-1);
}

.card--elevated:hover {
  box-shadow: var(--md-sys-elevation-2);
}

.card--filled {
  background-color: var(--md-sys-color-surface-container-high);
  border: none;
}

.card__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--md-sys-shape-corner-md);
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

.card__icon .material-symbols-outlined {
  font-size: 24px;
}

/* ============================================================
   MD3 BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: none;
  border-radius: var(--md-sys-shape-corner-xl);
  font-family: var(--md-sys-typescale-body-font);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.1px;
  cursor: pointer;
  text-decoration: none;
  transition: box-shadow var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
              background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.btn--filled {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn--filled:hover {
  box-shadow: var(--md-sys-elevation-1);
}

.btn--tonal {
  background-color: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
}

.btn--tonal:hover {
  box-shadow: var(--md-sys-elevation-1);
}

.btn--outlined {
  background-color: transparent;
  color: var(--md-sys-color-primary);
  border: 1px solid var(--md-sys-color-outline);
}

.btn--outlined:hover {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.btn--text {
  background: none;
  color: var(--md-sys-color-primary);
  padding: 10px 12px;
}

.btn--text:hover {
  background-color: var(--md-sys-color-primary-container);
}

.btn .material-symbols-outlined {
  font-size: 18px;
}

/* ============================================================
   CODE BLOCKS & SNIPPETS
   ============================================================ */
pre, code {
  font-family: var(--md-sys-typescale-code-font);
}

code {
  background-color: var(--md-sys-color-surface-container-high);
  padding: 2px 6px;
  border-radius: var(--md-sys-shape-corner-xs);
  font-size: 0.875em;
  color: var(--md-sys-color-primary);
}

pre {
  background-color: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-md);
  padding: 20px;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.65;
  border: 1px solid var(--md-sys-color-outline-variant);
}

pre code {
  background: none;
  padding: 0;
  color: var(--md-sys-color-on-surface);
  font-size: 0.8125rem;
}

/* ============================================================
   TUTORIAL PAGE STYLES
   ============================================================ */

/* Hero banner */
.tutorial-hero {
  background: linear-gradient(135deg, var(--md-sys-color-primary-container) 0%, var(--md-sys-color-secondary-container) 100%);
  border-radius: var(--md-sys-shape-corner-xl);
  padding: 48px 40px;
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(0,229,255,.15);
}

.tutorial-hero::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 320px;
  height: 320px;
  background: var(--md-sys-color-primary);
  opacity: 0.06;
  border-radius: 50%;
}

.tutorial-hero h1 {
  font-family: var(--md-sys-typescale-display-font);
  color: var(--md-sys-color-on-primary-container);
  margin-bottom: 12px;
}

.tutorial-hero p {
  color: var(--md-sys-color-on-primary-container);
  opacity: 0.85;
  max-width: 560px;
}

/* Section chips / tabs */
.section-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--md-sys-shape-corner-sm);
  border: 1px solid var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}

.section-tab:hover,
.section-tab.active {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: var(--md-sys-color-primary-container);
}

/* Tutorial section */
.tutorial-section {
  display: none;
  animation: fadeSlideIn var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized);
}

.tutorial-section.visible {
  display: block;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Concept list */
.concept-list {
  list-style: none;
  padding: 0;
}

.concept-list li {
  position: relative;
  padding: 8px 0 8px 28px;
  color: var(--md-sys-color-on-surface-variant);
}

.concept-list li::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 16px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--md-sys-color-primary);
}

/* Interactive demo area */
.demo-area {
  background-color: var(--md-sys-color-surface-container);
  border-radius: var(--md-sys-shape-corner-md);
  padding: 20px;
  margin-top: 16px;
  border: 1px solid var(--md-sys-color-outline-variant);
}

.demo-area__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--md-sys-color-primary);
  margin-bottom: 12px;
}

.demo-area__preview {
  background-color: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-sm);
  padding: 20px;
  min-height: 60px;
  border: 1px solid var(--md-sys-color-outline-variant);
}

/* Info chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: var(--md-sys-shape-corner-sm);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.chip--html { background-color: #2a1520; color: #ff2d95; border: 1px solid rgba(255,45,149,.2); }
.chip--css  { background-color: #0a1a2a; color: #00e5ff; border: 1px solid rgba(0,229,255,.2); }
.chip--js   { background-color: #1a2000; color: #b8ff00; border: 1px solid rgba(184,255,0,.2); }

:root.light .chip--html { background-color: #ffe0ec; color: #c2185b; border-color: rgba(194,24,91,.2); }
:root.light .chip--css  { background-color: #d6f7ff; color: #0097a7; border-color: rgba(0,151,167,.2); }
:root.light .chip--js   { background-color: #e4ffcc; color: #558b2f; border-color: rgba(85,139,47,.2); }

@media (prefers-color-scheme: dark) {
  :root:not(.light) .chip--html { background-color: #2a1520; color: #ff2d95; }
  :root:not(.light) .chip--css  { background-color: #0a1a2a; color: #00e5ff; }
  :root:not(.light) .chip--js   { background-color: #1a2000; color: #b8ff00; }
}
:root.dark .chip--html { background-color: #2a1520; color: #ff2d95; }
:root.dark .chip--css  { background-color: #0a1a2a; color: #00e5ff; }
:root.dark .chip--js   { background-color: #1a2000; color: #b8ff00; }

/* CTA banner */
.cta-banner {
  background: linear-gradient(135deg, #003844 0%, #520035 100%);
  border-radius: var(--md-sys-shape-corner-xl);
  padding: 40px;
  text-align: center;
  margin-top: 48px;
  color: #e0e4ec;
  border: 1px solid rgba(0,229,255,.15);
}

.cta-banner h2 { margin-bottom: 12px; }

.cta-banner p {
  opacity: 0.9;
  margin-bottom: 24px;
}

.cta-banner .btn {
  background-color: var(--md-sys-color-on-primary);
  color: var(--md-sys-color-primary);
}

.cta-banner .btn:hover {
  box-shadow: var(--md-sys-elevation-3);
}

/* ============================================================
   DIVIDER
   ============================================================ */
/* ============================================================
   SNACKBAR (Toast feedback)
   ============================================================ */
.snackbar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: var(--md-sys-color-inverse-surface);
  color: var(--md-sys-color-inverse-on-surface);
  padding: 14px 24px;
  border-radius: var(--md-sys-shape-corner-sm);
  font-size: 0.875rem;
  box-shadow: var(--md-sys-elevation-3);
  z-index: 2000;
  opacity: 0;
  transition: transform var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized),
              opacity var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
  pointer-events: none;
}

.snackbar.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer {
  background-color: var(--md-sys-color-surface-container);
  border-top: 1px solid var(--md-sys-color-outline-variant);
  padding: 24px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.8125rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .top-app-bar__nav { display: none; }
  .menu-toggle { display: flex; order: -2; }
  .top-app-bar__brand { order: -1; }
  .theme-toggle { margin-left: auto; }

  .tutorial-hero {
    padding: 32px 24px;
  }

  .tutorial-hero h1 {
    font-size: 1.75rem;
    line-height: 2.25rem;
  }

  .page-container {
    padding: 24px 16px 64px;
  }

  .cta-banner {
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .section-tabs { gap: 6px; }

  .section-tab {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
}

/* ============================================================
   UTILITY – ANIMATION ENTRANCE
   ============================================================ */

/*
 * CSS-only fallback: elements auto-reveal via keyframe animation
 * even if jQuery fails to load (e.g. no network / CDN blocked).
 * When JS IS available, it adds .js-loaded to <html> which
 * disables the auto-animation and uses scroll-based .in-view instead.
 */
.fade-in {
  opacity: 0;
  transform: translateY(16px);
  animation: fadeInFallback 0.6s ease forwards;
  animation-delay: 0.15s;
}

/* Stagger children slightly */
.fade-in:nth-child(2) { animation-delay: 0.25s; }
.fade-in:nth-child(3) { animation-delay: 0.35s; }
.fade-in:nth-child(n+4) { animation-delay: 0.45s; }

@keyframes fadeInFallback {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* When JS loads, it adds .js-loaded to <html>.
   This disables the CSS-only fallback animation and lets
   the scroll-based .in-view transition take over. */
html.js-loaded .fade-in {
  animation: none;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s var(--md-sys-motion-easing-emphasized),
              transform 0.5s var(--md-sys-motion-easing-emphasized);
}

html.js-loaded .fade-in.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   SKIP-TO-CONTENT LINK (Accessibility)
   Hidden by default, visible on keyboard focus.
   ============================================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  z-index: 9999;
  padding: 12px 24px;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  font-weight: 600;
  font-size: 0.875rem;
  border-radius: 0 0 var(--md-sys-shape-corner-sm) var(--md-sys-shape-corner-sm);
  text-decoration: none;
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 0;
}

/* ============================================================
   BACK-TO-TOP BUTTON
   ============================================================ */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  cursor: pointer;
  box-shadow: var(--md-sys-elevation-2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background-color: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  box-shadow: var(--md-sys-elevation-3);
}

.back-to-top .material-symbols-outlined {
  font-size: 24px;
}

/* ============================================================
   DARK MODE TOGGLE BUTTON (in top app bar)
   ============================================================ */
.theme-toggle {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--md-sys-color-on-surface-variant);
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
  background-color: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.theme-toggle .material-symbols-outlined {
  font-size: 22px;
}

/* ============================================================
   QUIZ TIMER
   ============================================================ */
.quiz-timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--md-sys-typescale-code-font);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface-variant);
  padding: 6px 14px;
  border-radius: 20px;
  background-color: var(--md-sys-color-surface-container);
  border: 1px solid var(--md-sys-color-outline-variant);
}

.quiz-timer .material-symbols-outlined {
  font-size: 18px;
  color: var(--md-sys-color-primary);
}

/* ============================================================
   SKELETON LOADING PLACEHOLDERS
   ============================================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-container-high) 25%,
    var(--md-sys-color-surface-container) 50%,
    var(--md-sys-color-surface-container-high) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--md-sys-shape-corner-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton-card {
  background-color: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.skeleton-line {
  height: 14px;
  margin-bottom: 10px;
  border-radius: 4px;
}

.skeleton-line--short { width: 40%; }
.skeleton-line--medium { width: 70%; }
.skeleton-line--long { width: 100%; }
.skeleton-line--title { height: 20px; width: 55%; margin-bottom: 16px; }

/* ============================================================
   UTILITY CLASSES (extracted from inline styles)
   ============================================================ */

/* --- Icons --- */
.icon-sm { font-size: 16px; }

/* --- Demo area components --- */
.demo-desc {
  color: var(--md-sys-color-on-surface-variant);
  margin-bottom: 12px;
}

.demo-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.demo-code-block {
  margin-top: 12px;
  margin-bottom: 0;
}
/* --- Form controls in demos --- */
.demo-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-sm);
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  outline: none;
}

.demo-input--code {
  font-family: var(--md-sys-typescale-code-font);
}

.demo-input--lg {
  padding: 10px 14px;
}

.demo-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-sm);
  font-family: var(--md-sys-typescale-code-font);
  font-size: 0.8125rem;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}

/* --- Layout helpers --- */
.flex-control {
  flex: 1;
  min-width: 140px;
}

.flex-control--sm {
  min-width: 100px;
}

.flex-control--lg {
  min-width: 180px;
}

.flex-wrap-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.mb-md { margin-bottom: 12px; }
.mb-lg { margin-bottom: 16px; }
.w-full { width: 100%; }

.self-end { align-self: flex-end; }

/* --- Cheatsheet tables --- */
.cheatsheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  margin-top: 8px;
}

.cheatsheet-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--md-sys-color-on-surface-variant);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--md-sys-color-outline-variant);
}

.cheatsheet-table td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  color: var(--md-sys-color-on-surface);
}
/* --- Pill tags row --- */
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.pill-row--lg {
  gap: 8px;
}

/* --- Section subtitle in cheatsheets --- */
.section-subtitle {
  margin-top: 20px;
  color: var(--md-sys-color-primary);
}

.section-subtitle--first {
  margin-top: 4px;
}

/* --- Overflow wrapper --- */
.overflow-x {
  overflow-x: auto;
}

/* --- Pill code tags (inside pill-row / cheatsheet) --- */
.pill-row code,
.pill-row--lg code {
  padding: 4px 10px;
}

/* --- Demo area label with block display --- */
.demo-area .label-large {
  display: block;
  margin-bottom: 4px;
}

/* ============================================================
   SYNTAX HIGHLIGHTING (highlight.js custom theme)
   Uses our CSS variables so it adapts to light/dark mode.
   ============================================================ */
.hljs {
  display: block;
  overflow-x: auto;
  background: transparent;
  color: var(--md-sys-color-on-surface);
}
.hljs-comment,
.hljs-quote {
  color: var(--md-sys-color-outline);
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section,
.hljs-link {
  color: var(--md-sys-color-primary);
  font-weight: 600;
}
.hljs-string,
.hljs-attr,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
  color: #689f38;
}
:root.dark .hljs-string,
:root.dark .hljs-attr,
:root.dark .hljs-symbol,
:root.dark .hljs-bullet,
:root.dark .hljs-addition {
  color: #a5d6a7;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .hljs-string,
  :root:not(.light) .hljs-attr,
  :root:not(.light) .hljs-symbol,
  :root:not(.light) .hljs-bullet,
  :root:not(.light) .hljs-addition {
    color: #a5d6a7;
  }
}
.hljs-number,
.hljs-meta,
.hljs-built_in,
.hljs-builtin-name,
.hljs-literal,
.hljs-type,
.hljs-params {
  color: #1565c0;
}
:root.dark .hljs-number,
:root.dark .hljs-meta,
:root.dark .hljs-built_in,
:root.dark .hljs-builtin-name,
:root.dark .hljs-type,
:root.dark .hljs-params {
  color: #82b4ff;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .hljs-number,
  :root:not(.light) .hljs-meta,
  :root:not(.light) .hljs-built_in,
  :root:not(.light) .hljs-builtin-name,
  :root:not(.light) .hljs-type,
  :root:not(.light) .hljs-params {
    color: #82b4ff;
  }
}
.hljs-name,
.hljs-tag,
.hljs-title,
.hljs-class .hljs-title,
.hljs-function .hljs-title {
  color: #c2185b;
}
:root.dark .hljs-name,
:root.dark .hljs-tag,
:root.dark .hljs-title,
:root.dark .hljs-class .hljs-title,
:root.dark .hljs-function .hljs-title {
  color: #f48fb1;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .hljs-name,
  :root:not(.light) .hljs-tag,
  :root:not(.light) .hljs-title,
  :root:not(.light) .hljs-class .hljs-title,
  :root:not(.light) .hljs-function .hljs-title {
    color: #f48fb1;
  }
}
.hljs-attribute,
.hljs-variable,
.hljs-template-variable {
  color: #e65100;
}
:root.dark .hljs-attribute,
:root.dark .hljs-variable,
:root.dark .hljs-template-variable {
  color: #ffb74d;
}
@media (prefers-color-scheme: dark) {
  :root:not(.light) .hljs-attribute,
  :root:not(.light) .hljs-variable,
  :root:not(.light) .hljs-template-variable {
    color: #ffb74d;
  }
}
.hljs-deletion { color: var(--md-sys-color-error); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ============================================================
   CYBERPUNK THEME ENHANCEMENTS
   ============================================================ */

.top-app-bar__brand {
  text-shadow: 0 0 20px rgba(0,229,255,.3);
}

/* Neon border glow on cards */
.card--elevated {
  border: 1px solid var(--md-sys-color-outline-variant);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.card--elevated:hover {
  border-color: rgba(0,229,255,.25);
  box-shadow: var(--cp-glow-cyan);
}

/* Active nav link - neon cyan */
.nav-link.active {
  background-color: rgba(0,229,255,.12);
  color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 12px rgba(0,229,255,.08);
}

/* Buttons - neon glow on hover */
.btn--filled:hover {
  box-shadow: var(--cp-glow-cyan);
}

/* Neon focus ring */
:focus-visible {
  outline: 2px solid var(--md-sys-color-primary);
  outline-offset: 2px;
  box-shadow: var(--cp-glow-cyan);
}

/* Back-to-top button glow */
.back-to-top.visible {
  box-shadow: var(--cp-glow-cyan);
}

/* Scanline overlay on heroes */
.tutorial-hero::after,
.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,229,255,.015) 2px,
    rgba(0,229,255,.015) 4px
  );
  border-radius: inherit;
}

/* ============================================================
   LIGHT MODE OVERRIDES
   ============================================================ */
:root.light .top-app-bar {
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  box-shadow: 0 1px 0 rgba(0,151,167,.08), var(--md-sys-elevation-2);
}

:root.light .top-app-bar__brand {
  text-shadow: none;
}

:root.light .card--elevated:hover {
  border-color: rgba(0,151,167,.3);
  box-shadow: var(--cp-glow-cyan);
}

:root.light .nav-link.active {
  background-color: rgba(0,151,167,.1);
  color: var(--md-sys-color-primary);
  box-shadow: inset 0 0 12px rgba(0,151,167,.06);
}

/* Softer scanlines on light backgrounds */
:root.light .tutorial-hero::after,
:root.light .hero::after {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,151,167,.03) 2px,
    rgba(0,151,167,.03) 4px
  );
}

/* Softer body grid on white */
:root.light body {
  background-image:
    linear-gradient(rgba(0,151,167,.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,151,167,.04) 1px, transparent 1px);
}

:root.light .tutorial-hero {
  background: linear-gradient(135deg, #d6f7ff 0%, #ffe0ec 100%);
  border-color: rgba(0,151,167,.15);
}

:root.light .tutorial-hero h1 {
  color: #141420;
}

:root.light .tutorial-hero p {
  color: #3a3c4a;
}

:root.light .cta-banner {
  background: linear-gradient(135deg, #0097a7 0%, #c2185b 100%);
  border-color: transparent;
  color: #ffffff;
}

:root.light .cta-banner .btn {
  background-color: #ffffff;
  color: #0097a7;
}
