/* ===== 2FACO — Design System (v4) ===== */
/* Fonts loaded via HTML <link rel="preload"> for non-blocking performance */
/* Inter + JetBrains Mono — consistent site-wide */

:root {
  --bg: #0a0a0a;
  --surface: #111;
  --surface2: #1a1a1a;
  --border: rgba(255,255,255,0.08);
  --text: #e8e8e8;
  --text-soft: #ccc;
  --muted: #8a8a8a; /* bumped from #777 for WCAG AA contrast on dark bg */
  --accent: #4ade80;
  --accent-dim: rgba(74,222,128,0.08);
  --accent-glow: rgba(74,222,128,0.18);
  --danger: #f87171;
  --success: #4ade80;
  --radius: 8px;
  --radius-lg: 12px;
  --header-h: 56px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --warning: #f59e0b;
  --info: #38bdf8;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Light mode — target <html> so the inline <head> script works flash-free */
html[data-theme="light"] {
  --bg: #f8f8f7;
  --surface: #fff;
  --surface2: #f0f0ef;
  --border: rgba(0,0,0,0.09);
  --text: #1a1a1a;
  --text-soft: #333;
  --muted: #555; /* bumped for WCAG AA contrast on light bg */
  --accent: #16a34a;
  --accent-dim: rgba(22,163,74,0.07);
  --accent-glow: rgba(22,163,74,0.18);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 0.25s, color 0.25s;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── HEADER ─────────────────────────────────── */
/* Scoped to body > header so article <header class="article-header"> is unaffected */
body > header {
  position: fixed;
  top: 0;
  width: 100%;
  height: var(--header-h);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  background: rgba(10,10,10,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

html[data-theme="light"] body > header {
  background: rgba(248,248,247,0.94);
}

/* Article header — reset any inherited positioning */
.article-header {
  /* Fully cancel any inherited header{} rules — works with both
     body > header and bare header selectors in the CSS cascade */
  position: static !important;
  width: auto !important;
  height: auto !important;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: auto !important;
  display: block !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  transform: none !important;
  flex-direction: unset !important;
  justify-content: unset !important;
  align-items: unset !important;
  gap: unset !important;
  overflow: visible !important;
}

.logo {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.3px;
}

.logo span { color: var(--muted); }

nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s;
}

nav a:hover, nav a.active { color: var(--text); }

.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover { border-color: var(--accent); }

/* ── LAYOUT ──────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 20px;
}

.container--narrow {
  max-width: 740px;
  margin: 0 auto;
  padding: 0 20px;
}

.page-body {
  padding-top: calc(var(--header-h) + 48px);
  padding-bottom: 80px;
}

/* ── ARTICLE HEADER ──────────────────────────── */
/* Note: position/layout reset is handled in the HEADER section above */
.article-header {
  margin-bottom: 36px;
}

.article-header .tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--accent-glow);
  padding: 3px 8px;
  border-radius: 4px;
  margin-bottom: 14px;
}

.article-header h1 {
  font-size: clamp(26px, 3.5vw, 38px);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 14px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  flex-wrap: wrap;
}

.article-meta .separator { opacity: 0.3; }

/* ── ARTICLE CONTENT ─────────────────────────── */
.article-content h2 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 10px;
  letter-spacing: -0.3px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.article-content h3 {
  font-size: 15px;
  font-weight: 600;
  margin-top: 22px;
  margin-bottom: 8px;
}

.article-content p {
  color: var(--text-soft);
  margin-bottom: 13px;
  font-size: 14px;
  line-height: 1.7;
}

.article-content ul, .article-content ol {
  margin-left: 20px;
  margin-bottom: 13px;
  color: var(--text-soft);
  font-size: 14px;
}

.article-content li { margin-bottom: 5px; }

.article-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.callout {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  padding: 14px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 22px 0;
  font-size: 13px;
  color: var(--text-soft);
}

.callout strong { color: var(--accent); }

.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 24px 0;
}

.toc h4 {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 10px;
}

.toc ol {
  margin-left: 16px;
  color: var(--muted);
  font-size: 13px;
}

.toc ol li { margin-bottom: 4px; }

.toc ol a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.toc ol a:hover { color: var(--accent); }

/* ── BLOG GRID ───────────────────────────────── */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.blog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}

.blog-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.blog-card .card-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.blog-card h2 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
}

.blog-card p {
  font-size: 12px;
  color: var(--muted);
  flex-grow: 1;
  line-height: 1.55;
  margin-bottom: 14px;
}

.blog-card .card-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.blog-card .read-more {
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
}

/* ── FOOTER ──────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 28px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}

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

.footer-links a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.footer-links a:hover { color: var(--accent); }

/* ── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}

.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ── MOBILE NAV ──────────────────────────────── */
.nav-toggle { display: none; }

/* ── BREADCRUMB ──────────────────────────────── */
.breadcrumb {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 20px;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { opacity: 0.35; }

/* ── SECTION HEADER ──────────────────────────── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.section-header a {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
}

.section-header a:hover { text-decoration: underline; }

/* ── RESPONSIVE ──────────────────────────────── */


/* ── UTILITY ─────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* ── Skip to main content (accessibility) ─────────── */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.15s;
}
.skip-link:focus { top: 16px; }

/* ── Reduced motion preference ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Tools showcase (homepage) ─────────────────────── */
.tools-showcase {
  padding: 40px 0 48px;
  border-top: 1px solid var(--border);
}
.tools-showcase__title {
  font-size: 13px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 16px;
}
.tools-showcase__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tool-chip {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.tool-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim, rgba(99,102,241,0.08));
}
.tool-chip--all {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── AdSense: collapse empty fluid slots ───────────────────── */
ins.adsbygoogle {
  min-height: 0 !important;
}
ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
  height: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
}

/* ── Nav overflow gradient hint (mobile) ──────────────────── */


/* ── Touch targets: copy + toggle buttons (WCAG 2.5.5) ─────── */


/* ── Blog card animation: visible by default, animated by JS ── */
.blog-card.will-animate {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.blog-card.will-animate.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ═══════════════════════════════════════════════════════
   MOBILE NAV — Hamburger menu + header controls
   ══════════════════════════════════════════════════════ */

/* ── Header controls container (theme toggle + hamburger) ── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Hamburger button — hidden on desktop ── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 10px;
  transition: border-color 0.15s;
}
.nav-hamburger:hover { border-color: var(--accent); }
.nav-hamburger .ham-bar {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
/* Animated X when open */
.nav-hamburger[aria-expanded="true"] .ham-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.nav-hamburger[aria-expanded="true"] .ham-bar:nth-child(2) {
  opacity: 0;
}
.nav-hamburger[aria-expanded="true"] .ham-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 768px) {
  /* Header: logo left, controls right — single row */
  body > header {
    padding: 0 16px;
    height: 56px;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    position: relative;
  }

  /* Nav: hidden by default, drops down below header */
  nav#navMenu {
    display: none;
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    background: rgba(10,10,10,0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 8px 0;
    z-index: 999;
    mask-image: none;
    -webkit-mask-image: none;
    animation: navSlideDown 0.2s ease;
  }
  nav#navMenu.nav-open {
    display: flex;
  }
  @keyframes navSlideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }
  nav#navMenu a {
    font-size: 15px;
    padding: 14px 20px;
    width: 100%;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
  }
  nav#navMenu a:last-child { border-bottom: none; }
  nav#navMenu a.active {
    color: var(--accent);
    background: var(--accent-dim);
  }

  /* Hamburger visible on mobile */
  .nav-hamburger { display: flex; }

  /* Theme toggle sizing */
  .theme-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  footer { padding: 24px 16px; flex-direction: column; align-items: flex-start; }
  .blog-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .code-copy {
    padding: 10px 12px;
    font-size: 12px;
    min-height: 44px;
  }
  .code-toggle {
    padding: 10px 10px;
    min-height: 44px;
    min-width: 44px;
  }
  .code-line {
    height: auto;
    min-height: 44px;
    padding: 6px 10px;
  }
  .key-right { width: 160px; }
  .code-val  { font-size: 14px; letter-spacing: 2px; }
  .theme-toggle { width: 44px; height: 44px; }
}

