/* =========================================================
   Basic Coding Concepts — main.css (v2: premium redesign)
   ========================================================= */

:root {
  /* Brand — refined, more distinctive */
  --color-primary: #6D28D9;          /* deep violet */
  --color-primary-dark: #5B21B6;
  --color-primary-light: #C4B5FD;
  --color-primary-soft: #F5F3FF;

  --color-accent: #06B6D4;           /* cyan */
  --color-accent-dark: #0891B2;
  --color-accent-soft: #ECFEFF;

  --color-pink: #EC4899;
  --color-amber: #F59E0B;

  --color-success: #059669;
  --color-info: #0284C7;
  --color-danger: #DC2626;
  --color-warning: #D97706;

  /* Neutrals — warmer, less flat */
  --color-bg: #FAFAF9;
  --color-bg-soft: #F5F5F4;
  --color-surface: #FFFFFF;
  --color-surface-2: #F5F3FF;
  --color-text: #1C1917;
  --color-text-muted: #57534E;
  --color-text-soft: #78716C;
  --color-border: #E7E5E4;
  --color-border-strong: #D6D3D1;

  /* Code */
  --color-code-bg: #1E1B4B;
  --color-code-text: #F1F5F9;
  --color-code-keyword: #C4B5FD;
  --color-code-string: #6EE7B7;
  --color-code-number: #FDE68A;
  --color-code-comment: #94A3B8;
  --color-code-fn: #67E8F9;

  /* Premium gradients */
  --gradient-hero: linear-gradient(135deg, #22D3EE 0%, #A78BFA 50%, #F472B6 100%);
  --gradient-accent: linear-gradient(135deg, #F59E0B 0%, #DC2626 100%);
  --gradient-soft: linear-gradient(135deg, #F5F3FF 0%, #ECFEFF 50%, #FDF2F8 100%);
  --gradient-mesh: radial-gradient(at 0% 0%, #C4B5FD80 0px, transparent 50%),
                   radial-gradient(at 100% 0%, #67E8F980 0px, transparent 50%),
                   radial-gradient(at 50% 100%, #F472B680 0px, transparent 50%);
  --gradient-card: linear-gradient(180deg, #FFFFFF 0%, #FAFAF9 100%);

  /* Typography */
  --font-display: 'Bricolage Grotesque', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

  /* Spacing scale */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem; --space-20: 5rem; --space-24: 6rem; --space-32: 8rem;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
  --radius-pill: 9999px;

  /* Shadows — premium, layered */
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.04), 0 1px 3px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 8px -2px rgba(28, 25, 23, 0.06), 0 2px 4px -2px rgba(28, 25, 23, 0.04);
  --shadow-lg: 0 10px 20px -4px rgba(28, 25, 23, 0.08), 0 4px 8px -4px rgba(28, 25, 23, 0.06);
  --shadow-xl: 0 20px 40px -8px rgba(28, 25, 23, 0.12), 0 10px 20px -8px rgba(28, 25, 23, 0.08);
  --shadow-glow: 0 0 0 4px rgba(109, 40, 217, 0.18);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 0 0 1px rgba(0,0,0,0.04), 0 4px 12px -2px rgba(28,25,23,0.06);

  /* Layout */
  --container-max: 1200px;
  --article-max: 780px;
  --header-height: 76px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Z-index */
  --z-header: 100;
  --z-modal: 200;
  --z-toast: 300;
}

/* =========================================================
   DARK MODE — fixed contrast, better hierarchy
   ========================================================= */
[data-theme="dark"] {
  --color-bg: #09090B;
  --color-bg-soft: #18181B;
  --color-surface: #18181B;
  --color-surface-2: #27272A;
  --color-text: #FAFAFA;
  --color-text-muted: #D4D4D8;
  --color-text-soft: #A1A1AA;
  --color-border: #3F3F46;
  --color-border-strong: #52525B;

  --color-primary: #A78BFA;
  --color-primary-dark: #C4B5FD;
  --color-primary-light: #C4B5FD;
  --color-primary-soft: #2E1065;

  --color-accent: #67E8F9;
  --color-accent-soft: #164E63;

  --color-success: #34D399;
  --color-danger: #F87171;
  --color-warning: #FBBF24;
  --color-info: #38BDF8;

  --color-code-bg: #0B0B14;
  --color-code-text: #E4E4E7;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
  --shadow-xl: 0 20px 50px rgba(0,0,0,0.7);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.05) inset, 0 0 0 1px rgba(255,255,255,0.06), 0 4px 12px rgba(0,0,0,0.5);

  --gradient-soft: linear-gradient(135deg, #1E1B4B 0%, #0E7490 50%, #831843 100%);
  --gradient-card: linear-gradient(180deg, #18181B 0%, #1F1F23 100%);
}

/* =========================================================
   Reset & base
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-height) + 1rem);
  /* Force light as the site default — even when the OS prefers dark. */
  color-scheme: light;
  background: #FAFAF9;
}
html[data-theme="dark"] {
  color-scheme: dark;
  background: #09090B;
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(109, 40, 217, 0.12);
  overflow-x: hidden;
  transition: background-color var(--transition-base), color var(--transition-base);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Prevent iOS auto-zoom on input focus (font-size must be ≥16px) */
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  font-size: max(16px, 1rem);
}

/* Better tap behavior on all interactive elements */
a, button, [role="button"], summary, .quiz__option, .helpful__btn, .spot-bug__line {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; padding: 0; }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-dark); text-decoration: underline; text-underline-offset: 3px; }
[data-theme="dark"] a { color: var(--color-primary-light); }
[data-theme="dark"] a:hover { color: #DDD6FE; }

ul, ol { padding-left: 1.5rem; }

/* =========================================================
   Typography — Title Case via JS-friendly selectors,
   and stronger hierarchy
   ========================================================= */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--color-text);
}
h1 { font-size: clamp(2.25rem, 5.5vw, 3.75rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.05; }
h2 { font-size: clamp(1.625rem, 3.5vw, 2.375rem); margin-top: var(--space-12); margin-bottom: var(--space-4); letter-spacing: -0.025em; }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.5rem); margin-top: var(--space-8); margin-bottom: var(--space-3); }
h4 { font-size: 1.15rem; margin-top: var(--space-6); margin-bottom: var(--space-2); }

p { margin-bottom: 1em; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 700; color: var(--color-text); }
em { font-style: italic; }
small { font-size: 0.875rem; color: var(--color-text-muted); }

code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.15em 0.45em;
  background: var(--color-primary-soft);
  border-radius: var(--radius-sm);
  color: var(--color-primary-dark);
  border: 1px solid var(--color-border);
}
[data-theme="dark"] code:not(pre code) {
  color: #DDD6FE;
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.25);
}

mark {
  background: linear-gradient(180deg, transparent 60%, rgba(245, 158, 11, 0.4) 60%);
  color: inherit;
  padding: 0 0.1em;
}

blockquote {
  border-left: 4px solid var(--color-primary);
  padding-left: var(--space-5);
  margin: var(--space-6) 0;
  color: var(--color-text-muted);
  font-style: italic;
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-10) 0;
}

::selection { background: var(--color-primary); color: white; }

/* Focus ring */
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* =========================================================
   Layout
   ========================================================= */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--article-max);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

main { flex: 1; }

.section { padding: var(--space-16) 0; }
.section--sm { padding: var(--space-10) 0; }
.section--lg { padding: var(--space-24) 0; }
.section--bg { background: var(--color-bg-soft); }
.section--gradient { background: var(--gradient-soft); }

/* Skip link */
.skip-link {
  position: absolute;
  top: -100px; left: var(--space-4);
  background: var(--color-primary);
  color: white;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  z-index: 1000;
  font-weight: 600;
  transition: top var(--transition-base);
}
.skip-link:focus { top: var(--space-4); color: white; }

/* Reading progress */
.reading-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: var(--gradient-hero);
  width: 0%;
  z-index: calc(var(--z-header) + 1);
  transition: width 50ms linear;
}

/* =========================================================
   Header — premium glassmorphism
   ========================================================= */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid rgba(231, 229, 228, 0.6);
  transition: background-color var(--transition-base);
}
[data-theme="dark"] .site-header {
  background: rgba(9, 9, 11, 0.78);
  border-bottom-color: rgba(63, 63, 70, 0.6);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  height: var(--header-height);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.125rem;
  letter-spacing: -0.025em;
  color: var(--color-text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { color: var(--color-text); text-decoration: none; }
.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: var(--gradient-hero);
  border-radius: var(--radius-md);
  color: white;
  font-weight: 800;
  font-size: 1rem;
  font-family: var(--font-mono);
  box-shadow: 0 4px 12px -2px rgba(167, 139, 250, 0.45);
}

.primary-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.primary-nav__link {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.primary-nav__link:hover,
.primary-nav__link[aria-current="page"] {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  text-decoration: none;
}
[data-theme="dark"] .primary-nav__link {
  color: var(--color-text-muted);
}
[data-theme="dark"] .primary-nav__link:hover,
[data-theme="dark"] .primary-nav__link[aria-current="page"] {
  background: rgba(167, 139, 250, 0.18);
  color: #DDD6FE;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.icon-btn:hover {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}
.icon-btn svg { width: 20px; height: 20px; }

.menu-toggle { display: none; }

@media (max-width: 1000px) {
  .primary-nav { display: none; }
  .menu-toggle { display: inline-flex; }
}

/* ==========================================================
   MOBILE DRAWER MENU — Secondary pages (different from bottom nav)
   Bottom nav has Home/Concepts/TryIt/Quizzes/Glossary
   Drawer has Basics, For Kids, Blog, Projects, Interview Q&A,
   Cheatsheets, Roadmap, About, Contact, Disclaimer, Sitemap.
   ========================================================== */
.mobile-drawer {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.55);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: none;
  justify-content: flex-end;
}
.mobile-drawer.is-open { display: flex; animation: fadeIn 200ms ease; }
.mobile-drawer__panel {
  width: min(380px, 88vw);
  height: 100%;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  box-shadow: -16px 0 40px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
  padding: var(--space-6);
  animation: slideInRight 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideInRight {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.mobile-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.mobile-drawer__title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  margin: 0;
}
.mobile-drawer__close {
  width: 44px; height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text);
}
.mobile-drawer__group { margin-bottom: var(--space-6); }
.mobile-drawer__group h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
  margin-bottom: var(--space-3);
  font-weight: 700;
  font-family: var(--font-body);
}
.mobile-drawer__list { list-style: none; padding: 0; margin: 0; }
.mobile-drawer__list li { margin-bottom: 4px; }
.mobile-drawer__list a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px 14px;
  min-height: 48px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.95rem;
  transition: background-color var(--transition-fast);
}
.mobile-drawer__list a:hover,
.mobile-drawer__list a:focus { background: var(--color-primary-soft); color: var(--color-primary-dark); }
[data-theme="dark"] .mobile-drawer__list a:hover,
[data-theme="dark"] .mobile-drawer__list a:focus { background: rgba(167,139,250,0.18); color: var(--color-primary-light); }
.mobile-drawer__list a .emoji { font-size: 1.15rem; flex-shrink: 0; width: 22px; text-align: center; }
.mobile-drawer__cta {
  display: block;
  margin-top: var(--space-5);
  padding: var(--space-4);
  background: var(--gradient-hero);
  color: white !important;
  border-radius: var(--radius-md);
  text-align: center;
  font-weight: 700;
  text-decoration: none;
  box-shadow: var(--shadow-md);
}
body.is-drawer-open { overflow: hidden; }

/* =========================================================
   Footer — proper info architecture
   ========================================================= */
.site-footer {
  background: var(--color-bg-soft);
  border-top: 1px solid var(--color-border);
  padding: var(--space-16) 0 var(--space-8);
  margin-top: var(--space-20);
  position: relative;
  overflow: hidden;
}
.site-footer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-hero);
  opacity: 0.9;
}
.site-footer .brand { gap: var(--space-3); margin-bottom: var(--space-3); }
.site-footer .brand__mark { width: 36px; height: 36px; box-shadow: 0 4px 12px -2px rgba(167, 139, 250, 0.4); }
.site-footer__col:first-child > p { color: var(--color-text-muted); margin-bottom: 0; }
/* ============================================================
   Footer layout v3 - clean and consistent across all viewports.
   Spotlight ALWAYS sits BEFORE the link grid so the empty
   right-side never appears.
   ============================================================ */

/* ============================================================
   Footer v4 — clean, professional, consistent across viewports
   ============================================================ */

/* Spotlight: 3 equal cards, always visually balanced */
.footer-spotlight {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
  padding: var(--space-6) var(--space-8);
  background: linear-gradient(135deg, rgba(167,139,250,0.12), rgba(244,114,182,0.10));
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-12);
  width: 100%;
  box-sizing: border-box;
  align-items: start;
}
[data-theme="dark"] .footer-spotlight {
  background: linear-gradient(135deg, rgba(167,139,250,0.18), rgba(244,114,182,0.14));
  border-color: rgba(167, 139, 250, 0.25);
}
.footer-spotlight__item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  padding-left: var(--space-3);
  border-left: 3px solid var(--color-primary);
}
[data-theme="dark"] .footer-spotlight__item { border-left-color: var(--color-primary-light); }
.footer-spotlight__item h5 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-text);
  line-height: 1.3;
}
.footer-spotlight__item p {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin: 0;
  line-height: 1.55;
}
.footer-spotlight__item a {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: auto;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: gap var(--transition-fast);
}
.footer-spotlight__item a:hover { gap: 8px; }
[data-theme="dark"] .footer-spotlight__item a { color: var(--color-primary-light); }
@media (max-width: 900px) {
  .footer-spotlight { grid-template-columns: 1fr; gap: var(--space-4); padding: var(--space-5); }
}

/* ============================================================
   Footer v6 — clean 4-column layout
   Col 1: Brand + about + contact + social  (1.6fr - widest)
   Col 2: Company links                     (1fr)
   Col 3: Practice links                    (1fr)
   Col 4: Latest blog posts                 (1.4fr - room for titles)
   ============================================================ */
.site-footer__grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.4fr;
  gap: var(--space-10);
  margin-bottom: var(--space-12);
  align-items: start;
}
.site-footer__col h4 { white-space: nowrap; }
.site-footer__col li a { line-height: 1.5; word-break: normal; overflow-wrap: break-word; }

/* Latest blog posts column */
.footer-posts li {
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.footer-posts li a {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.4;
}
.footer-posts li a:hover { color: var(--color-primary); transform: translateX(2px); }
[data-theme="dark"] .footer-posts li a:hover { color: var(--color-primary-light); }
.footer-posts li span {
  font-size: 0.78rem;
  color: var(--color-text-soft);
  font-weight: 400;
}
.footer-posts__more a {
  font-weight: 700 !important;
  color: var(--color-primary) !important;
  font-size: 0.88rem !important;
}
[data-theme="dark"] .footer-posts__more a { color: var(--color-primary-light) !important; }

@media (max-width: 1000px) {
  .site-footer__grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); }
  .site-footer__col--brand { grid-column: span 2; padding-bottom: var(--space-6); border-bottom: 1px solid var(--color-border); }
}
@media (max-width: 540px) {
  .site-footer__grid { grid-template-columns: 1fr; }
  .site-footer__col--brand { grid-column: span 1; }
}
.site-footer__col h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text);
  margin-bottom: var(--space-4);
  font-family: var(--font-body);
  font-weight: 700;
  position: relative;
  padding-bottom: 10px;
}
.site-footer__col h4::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 28px;
  height: 2px;
  background: var(--gradient-hero);
  border-radius: 2px;
}
.site-footer__col ul { list-style: none; padding: 0; margin: 0; }
.site-footer__col li { margin-bottom: 10px; }
.site-footer__col li:last-child { margin-bottom: 0; }
.site-footer__col a {
  color: var(--color-text-muted);
  font-size: 0.92rem;
  text-decoration: none;
  transition: all var(--transition-fast);
  display: inline-block;
  position: relative;
}
.site-footer__col a:hover {
  color: var(--color-primary);
  transform: translateX(2px);
}
[data-theme="dark"] .site-footer__col a:hover { color: var(--color-primary-light); }
.site-footer__col p { font-size: 0.92rem; line-height: 1.6; }

.site-footer__bottom {
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
  font-size: 0.85rem;
  color: var(--color-text-soft);
}
.site-footer__bottom span:first-child { font-weight: 500; }

.footer-contact {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}
.footer-contact strong {
  color: var(--color-text);
  display: block;
  margin-bottom: var(--space-3);
  font-family: var(--font-display);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.footer-contact a { color: var(--color-text-muted); transition: color var(--transition-fast); }
.footer-contact a:hover { color: var(--color-primary); }
[data-theme="dark"] .footer-contact a:hover { color: var(--color-primary-light); }
.footer-contact div {
  margin-bottom: var(--space-3);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}
.footer-contact div:last-child { margin-bottom: 0; }
.footer-contact svg {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  flex-shrink: 0;
  opacity: 0.85;
  color: var(--color-primary);
}
[data-theme="dark"] .footer-contact svg { color: var(--color-primary-light); }

/* Social icons — compact pill row that always fits and never clips */
.social-icons {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 8px;
  margin-top: var(--space-4);
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  overflow: visible;
}
.social-icons a {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px;
  border-radius: 50%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  transition: all var(--transition-fast);
}
[data-theme="dark"] .social-icons a {
  background: var(--color-surface-2);
  border-color: var(--color-border-strong);
}
.social-icons a:hover {
  background: var(--gradient-hero);
  color: white;
  border-color: transparent;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.social-icons svg { width: 18px; height: 18px; flex-shrink: 0; }

/* Newsletter */
.newsletter-form {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}
.newsletter-form input {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.95rem;
}
.newsletter-form input:focus { border-color: var(--color-primary); box-shadow: var(--shadow-glow); }

/* =========================================================
   Mobile bottom nav
   ========================================================= */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-header);
  padding: var(--space-2) 0 calc(var(--space-2) + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}
[data-theme="dark"] .mobile-bottom-nav { background: rgba(9, 9, 11, 0.92); }
.mobile-bottom-nav__inner { display: flex; justify-content: space-around; }
.mobile-bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--space-2);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  text-decoration: none;
  flex: 1;
  border-radius: var(--radius-sm);
}
.mobile-bottom-nav a svg { width: 22px; height: 22px; }
.mobile-bottom-nav a:hover, .mobile-bottom-nav a[aria-current="page"] { color: var(--color-primary); }

@media (max-width: 640px) {
  .mobile-bottom-nav { display: block; }
  body { padding-bottom: 70px; }
}

/* =========================================================
   Search overlay
   ========================================================= */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 25, 23, 0.5);
  backdrop-filter: blur(8px);
  z-index: var(--z-modal);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
}
.search-overlay.is-open { display: flex; animation: fadeIn 200ms ease; }
.search-modal {
  width: 100%;
  max-width: 600px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  margin: 0 var(--space-4);
}
.search-modal__input {
  width: 100%;
  padding: var(--space-5) var(--space-6);
  border: none;
  font-size: 1.125rem;
  background: var(--color-surface);
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}
.search-modal__results { max-height: 60vh; overflow-y: auto; }
.search-modal__result {
  display: block;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
  transition: background-color var(--transition-fast);
}
.search-modal__result:hover { background: var(--color-surface-2); text-decoration: none; }
.search-modal__result-title { font-weight: 600; margin-bottom: 4px; color: var(--color-primary); }
.search-modal__result-snippet { font-size: 0.875rem; color: var(--color-text-muted); }
.search-modal__empty { padding: var(--space-8); text-align: center; color: var(--color-text-muted); }

/* =========================================================
   Back-to-top button
   ========================================================= */
.back-to-top {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--gradient-hero);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity var(--transition-base), transform var(--transition-base);
  z-index: 90;
}
.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-xl);
}
.back-to-top svg { width: 20px; height: 20px; }
@media (max-width: 640px) {
  .back-to-top { bottom: 88px; right: 16px; width: 44px; height: 44px; }
}

/* =========================================================
   Animations
   ========================================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.fade-in { animation: fadeIn 600ms ease forwards; opacity: 0; }
.fade-in-1 { animation-delay: 100ms; }
.fade-in-2 { animation-delay: 200ms; }
.fade-in-3 { animation-delay: 300ms; }
.fade-in-4 { animation-delay: 400ms; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   MOBILE IMPROVEMENTS
   ========================================================= */

/* Tablet & below */
@media (max-width: 1000px) {
  :root { --header-height: 68px; }
  h1 { letter-spacing: -0.025em; }
}

/* Phone */
@media (max-width: 640px) {
  :root {
    --header-height: 64px;
    --space-12: 2.5rem;
    --space-16: 3rem;
    --space-20: 3.5rem;
  }
  html, body { overflow-x: hidden !important; max-width: 100vw; }
  body { padding-bottom: 76px; font-size: 1rem; line-height: 1.65; }

  /* Generous breathing room on mobile — ~20px gutters left + right */
  .container, .container-narrow { padding: 0 var(--space-5); max-width: 100vw; }
  .hero, .section { max-width: 100vw; overflow-x: hidden; }
  .hero__inner > div, .hero__inner > div > * { max-width: 100%; min-width: 0; }
  .hero h1, .hero__lead { max-width: 100%; }
  .section { padding: var(--space-12) 0; }
  .section--lg { padding: var(--space-16) 0; }

  /* Inner block side-padding so cards/articles never touch the screen edge */
  .article-layout, .article-layout__main, .article-layout__sidebar { padding-left: 0; padding-right: 0; }
  article.prose { padding: 0; }
  .breadcrumbs { padding: 0 2px; }
  .hub-intro .container { padding-left: var(--space-5); padding-right: var(--space-5); }

  /* Section-internal cards: a touch of inset so they don't kiss the gutter */
  .grid { padding: 0 2px; }
  .card { margin-left: 2px; margin-right: 2px; }

  /* Footer: match container padding so brand/links aren't flush left */
  .site-footer .container { padding: 0 var(--space-5); }

  /* Hero gets matching inset and the visual code-card pulls in slightly */
  .hero .container { padding: 0 var(--space-5); }
  .hero__visual { padding: 0 2px; }

  /* Mobile bottom nav also needs comfortable side breathing room */
  .mobile-bottom-nav__inner { padding: 0 var(--space-3); }

  /* Search overlay: keep modal away from the edges */
  .search-modal { margin: 0 var(--space-5); }

  /* Headings: tighter for narrow screens */
  h1 { font-size: clamp(1.875rem, 8vw, 2.5rem); line-height: 1.1; }
  h2 { font-size: clamp(1.4rem, 6vw, 1.75rem); margin-top: var(--space-10); }
  h3 { font-size: 1.2rem; }

  /* Hero CTA buttons: full width and stacked, contained inside the viewport */
  .hero__inner > div:first-child { min-width: 0; max-width: 100%; }
  .hero__actions {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }
  .hero__actions .btn {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    word-break: keep-all;
  }
  .hero__lead {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    padding-right: 4px;
    font-size: 1.0625rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    hyphens: auto;
  }
  .hero__inner { width: 100%; max-width: 100%; box-sizing: border-box; }
  .hero__inner > div { width: 100%; max-width: 100%; min-width: 0; box-sizing: border-box; }
  .hero__eyebrow {
    max-width: 100%;
    align-items: center;
    box-sizing: border-box;
    font-size: 0.8rem;
    padding: 7px 14px;
    line-height: 1.25;
    text-align: left;
  }
  .hero__eyebrow > * { vertical-align: middle; }
  .hero__stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
    padding-top: var(--space-4);
    margin-top: var(--space-6);
    width: 100%;
  }
  .hero__stat { text-align: left; }
  .hero__stat strong { font-size: 1.5rem; }
  .hero__stat span { font-size: 0.78rem; line-height: 1.3; display: block; }
  .hero { padding: var(--space-16) 0 var(--space-12); }
  .hero h1 { word-break: keep-all; overflow-wrap: anywhere; }

  /* Header mobile: tighten brand label, drop secondary text */
  .brand span:not(.brand__mark) { font-size: 1rem; }
  .brand__mark { width: 34px; height: 34px; }

  /* Min 44x44 tap targets across mobile */
  .icon-btn { width: 44px; height: 44px; }
  .btn { min-height: 44px; padding: var(--space-3) var(--space-5); }
  .btn--sm { min-height: 44px; padding: 10px var(--space-4); }
  .helpful__btn { min-height: 44px; padding: 10px 16px; }
  .quiz__option { min-height: 48px; padding: var(--space-3) var(--space-4); }
  .faq-item summary { padding: var(--space-4); min-height: 56px; }
  .pager a { min-height: 64px; padding: var(--space-4); }
  .spot-bug__line { min-height: 44px; padding: 10px 12px; }
  .code-tabs__btn { min-height: 44px; }

  /* Newsletter and contact form stack */
  .newsletter-form { flex-direction: column; }
  .newsletter-form input, .newsletter-form button { width: 100%; min-height: 44px; }

  /* Mobile bottom nav touch targets */
  .mobile-bottom-nav a { min-height: 56px; padding: 6px 4px; }
  .mobile-bottom-nav a svg { width: 24px; height: 24px; }

  /* Footer compress nicely */
  .site-footer { padding: var(--space-12) 0 var(--space-6); }
  .site-footer__grid { gap: var(--space-6); }
  .site-footer__bottom { flex-direction: column; align-items: flex-start; gap: var(--space-2); text-align: left; }

  /* Footer contact: stack icons and text properly */
  .footer-contact div { font-size: 0.92rem; }
  .footer-contact span, .footer-contact a { word-break: break-word; }

  /* Code blocks smaller padding on mobile */
  .code-block pre { padding: var(--space-3) var(--space-4); font-size: 0.85rem; }
  .code-tabs__panel pre { padding: var(--space-3) var(--space-4); font-size: 0.85rem; }
  .code-tabs__btn { padding: var(--space-3) var(--space-4); font-size: 0.75rem; }

  /* Tables: keep real table; horizontal scroll inside wrapper */
  .table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    position: relative;
  }
  .table-scroll::after {
    content: "← swipe →";
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--color-text-soft);
    padding: 6px 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-top: 1px dashed var(--color-border);
  }
  .compare-table {
    display: table !important;
    min-width: 600px !important;
    width: 100% !important;
    margin: 0 !important;
    font-size: 0.85rem;
    border-radius: 0;
    border: 0;
  }
  .compare-table thead { display: table-header-group !important; }
  .compare-table tbody { display: table-row-group !important; }
  .compare-table tr { display: table-row !important; padding: 0; margin: 0; background: transparent !important; border: 0; }
  .compare-table th, .compare-table td {
    display: table-cell !important;
    padding: 10px 12px !important;
    border-bottom: 1px solid var(--color-border) !important;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    vertical-align: top;
  }
  .compare-table td:not(:first-child)::before { display: none !important; content: none !important; }
  .compare-table td:first-child {
    font-weight: 600;
    color: var(--color-text);
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: 0;
    border-bottom: 1px solid var(--color-border);
    padding: 10px 12px !important;
    margin: 0;
  }

  /* Cards / hero visual breathing room */
  .card { padding: var(--space-5); }
  .concept-card__icon { width: 44px; height: 44px; font-size: 1.4rem; }
  .stat-card__value { font-size: 1.8rem; }

  /* CTA banner — less padding on small screens */
  .cta-banner { padding: var(--space-8) var(--space-5); border-radius: var(--radius-lg); }

  /* Hero code-card: smaller font so it doesn't break out */
  .code-card { padding: var(--space-4); font-size: 0.78rem; line-height: 1.55; }
  .code-card pre { overflow-x: auto; }

  /* Author bio stacks on mobile */
  .author-bio { padding: var(--space-5); gap: var(--space-3); }
  .author-bio__avatar { width: 56px; height: 56px; font-size: 1.2rem; }

  /* Bee card stacks if it gets cramped */
  .bee-card { padding: var(--space-4); gap: var(--space-3); }
  .bee-card img { width: 48px; height: 48px; }

  /* Search modal: full width on phones */
  .search-modal { margin: 0 var(--space-3); }
  .search-modal__input { padding: var(--space-4); font-size: 16px; }

  /* Page meta: smaller, wrap nicely */
  .page-meta { gap: var(--space-3); font-size: 0.825rem; }

  /* Real-world grid stacks nicer */
  .real-world-grid { grid-template-columns: 1fr; gap: var(--space-3); }

  /* TL;DR and callouts */
  .tldr-card { padding: var(--space-4) var(--space-5); }
  .callout { padding: var(--space-4); }

  /* Visualizers stack */
  .viz__stage { grid-template-columns: 1fr; }
  .viz__code { border-right: none; border-bottom: 1px solid var(--color-border); }

  /* Playground stacks */
  .playground { grid-template-columns: 1fr; }
  .playground textarea, .playground__output-pane { min-height: 220px; }

  /* Article layout already collapses; compact TOC */
  .toc { padding: var(--space-4); }
  .related-reading { padding: var(--space-4); }

  /* Back-to-top above mobile nav */
  .back-to-top { bottom: 88px; right: 14px; width: 44px; height: 44px; }

  /* Site header — keep all icons visible, hide search label */
  .site-header__inner { gap: var(--space-3); padding: 0; }
  .header-actions { gap: 4px; }

  /* Breadcrumbs: smaller font */
  .breadcrumbs { font-size: 0.8rem; }

  /* Block long URLs/words from breaking layout */
  article.prose, .prose { word-break: break-word; overflow-wrap: anywhere; }

  /* Glossary terms */
  .glossary-term { padding: var(--space-4); }
  .glossary-term__name { font-size: 1.1rem; }

  /* Roadmap step circles */
  .roadmap { padding-left: 56px; }
  .roadmap__step::before { left: -50px; width: 40px; height: 40px; font-size: 0.95rem; }

  /* Path-visual nodes — touch friendly */
  .path-node { padding: var(--space-3); min-height: 80px; }
  .path-node__num { font-size: 1.25rem; }
  .path-node__title { font-size: 0.78rem; }
}

/* Very small phones (≤380px) */
@media (max-width: 380px) {
  /* Drop padding slightly so content gets room, but never below 16px */
  .container, .container-narrow,
  .hero .container, .site-footer .container { padding: 0 var(--space-4); }
  .hero__stats { gap: var(--space-4); }
  .hero__stat strong { font-size: 1.25rem; }
  .hero h1 { font-size: 1.7rem; }
  .hero__lead { font-size: 1rem; line-height: 1.55; }
  .hero__eyebrow { font-size: 0.78rem; padding: 6px 12px; }
  .brand span:not(.brand__mark) { display: none; }   /* logo only */
  .icon-btn { width: 40px; height: 40px; }            /* tighter on cramped screens */
  .header-actions { gap: 0; }
  .mobile-bottom-nav a span { font-size: 0.65rem; }
}

/* Landscape phones — keep header compact */
@media (max-width: 900px) and (orientation: landscape) and (max-height: 500px) {
  :root { --header-height: 56px; }
  .hero { padding: var(--space-10) 0; }
}

/* Utilities */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mb-0 { margin-bottom: 0; }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.flex { display: flex; }
.gap-4 { gap: var(--space-4); }
.flex-wrap { flex-wrap: wrap; }
