/* ============================================================
   TECHAASVIK.COM — MASTER DESIGN SYSTEM v2.2.0
   Inspired by: Linear, Stripe, Vercel, Framer, Perplexity
   Philosophy: Dark-first, AI-native, authority-grade premium
   ============================================================ */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Sora:wght@400;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  /* Brand Colors */
  --brand-50:   #eef2ff;
  --brand-100:  #e0e7ff;
  --brand-200:  #c7d2fe;
  --brand-300:  #a5b4fc;
  --brand-400:  #818cf8;
  --brand-500:  #6366f1;
  --brand-600:  #4f46e5;
  --brand-700:  #4338ca;
  --brand-800:  #3730a3;
  --brand-900:  #312e81;

  /* Accent — Emerald */
  --accent-400: #34d399;
  --accent-500: #10b981;
  --accent-600: #059669;

  /* Gold — Authority signal */
  --gold-400:   #fbbf24;
  --gold-500:   #f59e0b;

  /* Neutrals (dark theme base) */
  --gray-0:     #ffffff;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-300:   #cbd5e1;
  --gray-400:   #94a3b8;
  --gray-500:   #64748b;
  --gray-600:   #475569;
  --gray-700:   #334155;
  --gray-800:   #1e293b;
  --gray-850:   #172033;
  --gray-900:   #0f172a;
  --gray-950:   #080d16;

  /* Semantic Colors */
  --color-success:  #22c55e;
  --color-warning:  #f59e0b;
  --color-error:    #ef4444;
  --color-info:     #3b82f6;

  /* ── Background System ─── */
  --bg-base:       #080d16;
  --bg-surface:    #0f172a;
  --bg-elevated:   #1e293b;
  --bg-overlay:    #263147;
  --bg-interactive:#2d3a50;

  /* ── Text System ─── */
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-disabled:  #334155;
  --text-inverse:   #080d16;
  --text-brand:     #818cf8;

  /* ── Border System ─── */
  --border-subtle:  rgba(255,255,255,0.06);
  --border-default: rgba(255,255,255,0.10);
  --border-strong:  rgba(255,255,255,0.16);
  --border-brand:   rgba(99,102,241,0.5);

  /* ── Typography ─── */
  --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display:'Sora', 'Inter', sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  --text-xs:    0.75rem;     /* 12px */
  --text-sm:    0.875rem;    /* 14px */
  --text-base:  1rem;        /* 16px */
  --text-lg:    1.125rem;    /* 18px */
  --text-xl:    1.25rem;     /* 20px */
  --text-2xl:   1.5rem;      /* 24px */
  --text-3xl:   1.875rem;    /* 30px */
  --text-4xl:   2.25rem;     /* 36px */
  --text-5xl:   3rem;        /* 48px */
  --text-6xl:   3.75rem;     /* 60px */
  --text-7xl:   4.5rem;      /* 72px */

  --fw-light:    300;
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;
  --fw-extrabold:800;
  --fw-black:    900;

  --leading-tight:  1.25;
  --leading-snug:   1.375;
  --leading-normal: 1.5;
  --leading-relaxed:1.625;
  --leading-loose:  2;

  /* ── Spacing (8px grid) ─── */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  --space-24: 6rem;      /* 96px */
  --space-32: 8rem;      /* 128px */

  /* ── Border Radius ─── */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* ── Shadows ─── */
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.6);
  --shadow-brand: 0 0 0 3px rgba(99,102,241,0.3);
  --shadow-glow:  0 0 40px rgba(99,102,241,0.15);

  /* ── Transitions ─── */
  --transition-fast:   150ms ease;
  --transition-base:   250ms ease;
  --transition-slow:   400ms ease;

  /* ── Z-Index ─── */
  --z-below:   -1;
  --z-base:     0;
  --z-raised:  10;
  --z-dropdown:100;
  --z-sticky:  200;
  --z-overlay: 300;
  --z-modal:   400;
  --z-toast:   500;

  /* ── Layout ─── */
  --container-sm:   640px;
  --container-md:   768px;
  --container-lg:   1024px;
  --container-xl:   1280px;
  --container-2xl:  1400px;
  --header-height:  64px;
  --sidebar-width:  280px;
}

/* ── Light Mode Override ───────────────────────────────────── */
[data-theme="light"] {
  --bg-base:        #ffffff;
  --bg-surface:     #f8fafc;
  --bg-elevated:    #f1f5f9;
  --bg-overlay:     #e2e8f0;
  --bg-interactive: #e9edf4;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-disabled:  #cbd5e1;
  --text-brand:     #4f46e5;
  --border-subtle:  rgba(0,0,0,0.07);
  --border-default: rgba(0,0,0,0.12);
  --border-strong:  rgba(0,0,0,0.18);
  --shadow-sm:  0 1px 2px rgba(0,0,0,0.06);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.12);
  --shadow-xl:  0 20px 60px rgba(0,0,0,0.14);
  --shadow-glow:0 0 40px rgba(99,102,241,0.1);
}

/* Light mode — header */
[data-theme="light"] .site-header {
  background: rgba(255,255,255,0.92);
  border-bottom-color: rgba(0,0,0,0.07);
}
[data-theme="light"] .site-logo-text {
  background: linear-gradient(135deg, #0f172a 30%, var(--brand-600));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
[data-theme="light"] .site-nav-link { color: #475569; }
[data-theme="light"] .site-nav-link:hover,
[data-theme="light"] .site-nav-link.active {
  color: #0f172a;
  background: var(--bg-elevated);
}
[data-theme="light"] .menu-toggle span { background: #475569; }

/* Light mode — search overlay */
[data-theme="light"] #searchOverlay { background: rgba(248,250,252,0.95); }
[data-theme="light"] .search-bar input {
  background: #ffffff;
  border-color: rgba(0,0,0,0.12);
  color: #0f172a;
}

/* Light mode — mobile nav */
[data-theme="light"] .site-nav.is-open { background: #ffffff; }

/* Light mode — footer */
[data-theme="light"] .site-footer { background: #f8fafc; }
[data-theme="light"] .social-link { background: #ffffff; }

/* Light mode — cards */
[data-theme="light"] .card { background: #ffffff; }
[data-theme="light"] .card-glass {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.1);
}
[data-theme="light"] .post-card { background: #ffffff; }

/* Light mode — code */
[data-theme="light"] code { background: #f1f5f9; color: #4338ca; }
[data-theme="light"] pre  { background: #f1f5f9; }

/* Light mode — forms */
[data-theme="light"] .form-input,
[data-theme="light"] .form-textarea,
[data-theme="light"] .form-select {
  background: #ffffff;
  border-color: rgba(0,0,0,0.15);
  color: #0f172a;
}
[data-theme="light"] .form-input:focus,
[data-theme="light"] .form-textarea:focus,
[data-theme="light"] .form-select:focus {
  background: #ffffff;
  border-color: var(--brand-500);
}

/* Light mode — badges */
[data-theme="light"] .badge-gray { background: #f1f5f9; }
[data-theme="light"] .tag { background: #f1f5f9; }

/* Light mode — skeleton */
[data-theme="light"] .skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--fw-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  background-color: var(--bg-base);
  min-height: 100vh;
  overflow-x: hidden;
}

img, video, svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--text-brand);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--brand-300); }

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

ul, ol { list-style: none; }

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-6);
}
.container-sm  { max-width: var(--container-sm); }
.container-md  { max-width: var(--container-md); }
.container-lg  { max-width: var(--container-lg); }
.container-2xl { max-width: var(--container-2xl); }

.section { padding: var(--space-20) 0; }
.section-sm { padding: var(--space-12) 0; }
.section-lg { padding: var(--space-32) 0; }

.grid          { display: grid; }
.grid-2        { grid-template-columns: repeat(2, 1fr); }
.grid-3        { grid-template-columns: repeat(3, 1fr); }
.grid-4        { grid-template-columns: repeat(4, 1fr); }
.grid-auto     { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.gap-4         { gap: var(--space-4); }
.gap-6         { gap: var(--space-6); }
.gap-8         { gap: var(--space-8); }

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.justify-center{ justify-content: center; }
.justify-between{justify-content: space-between; }
.gap-2         { gap: var(--space-2); }
.gap-3         { gap: var(--space-3); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(var(--text-3xl), 5vw, var(--text-6xl)); font-weight: var(--fw-extrabold); }
h2 { font-size: clamp(var(--text-2xl), 4vw, var(--text-4xl)); }
h3 { font-size: clamp(var(--text-xl), 3vw, var(--text-3xl)); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); }

p { margin-bottom: var(--space-4); color: var(--text-secondary); line-height: var(--leading-relaxed); }
p:last-child { margin-bottom: 0; }

strong { font-weight: var(--fw-semibold); color: var(--text-primary); }
em     { font-style: italic; }
small  { font-size: var(--text-sm); color: var(--text-muted); }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-elevated);
  color: var(--brand-300);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}
pre code { background: none; border: none; padding: 0; font-size: inherit; }

blockquote {
  border-left: 3px solid var(--brand-500);
  padding: var(--space-4) var(--space-6);
  margin: var(--space-8) 0;
  background: rgba(99,102,241,0.06);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* Article body typography */
.prose h2 { margin: var(--space-10) 0 var(--space-4); }
.prose h3 { margin: var(--space-8) 0 var(--space-3); }
.prose h4 { margin: var(--space-6) 0 var(--space-2); }
.prose p  { margin-bottom: var(--space-5); }
.prose ul, .prose ol {
  padding-left: var(--space-6);
  margin-bottom: var(--space-5);
  color: var(--text-secondary);
}
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li { margin-bottom: var(--space-2); line-height: var(--leading-relaxed); }
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-8) 0;
  font-size: var(--text-sm);
}
.prose th, .prose td {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-default);
  text-align: left;
}
.prose th { background: var(--bg-elevated); font-weight: var(--fw-semibold); }
.prose tr:hover td { background: rgba(255,255,255,0.02); }
.prose img {
  border-radius: var(--radius-lg);
  margin: var(--space-8) 0;
  box-shadow: var(--shadow-lg);
}
.prose a { color: var(--brand-400); border-bottom: 1px solid transparent; transition: border-color var(--transition-fast); }
.prose a:hover { border-color: var(--brand-400); }
.prose hr { border: none; border-top: 1px solid var(--border-default); margin: var(--space-10) 0; }

/* ============================================================
   COMPONENTS — BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-weight: var(--fw-semibold);
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base);
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-500);
  color: #fff;
  border-color: var(--brand-600);
  box-shadow: 0 1px 0 rgba(0,0,0,0.1), inset 0 1px 0 rgba(255,255,255,0.1);
}
.btn-primary:hover {
  background: var(--brand-600);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  color: #fff;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover {
  background: var(--bg-overlay);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); }

.btn-danger { background: var(--color-error); color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-success { background: var(--accent-500); color: #fff; border-color: var(--accent-600); }
.btn-success:hover { background: var(--accent-600); color: #fff; }

.btn-lg { padding: var(--space-4) var(--space-8); font-size: var(--text-base); border-radius: var(--radius-xl); }
.btn-sm { padding: var(--space-2) var(--space-4); font-size: var(--text-xs); }

/* Gradient CTA button */
.btn-gradient {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-500), #8b5cf6);
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.btn-gradient:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(99,102,241,0.5);
  color: #fff;
}

/* ============================================================
   COMPONENTS — CARDS
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
}
.card:hover {
  border-color: var(--border-default);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-glass {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
}

.card-interactive {
  cursor: pointer;
}
.card-interactive:hover .card-title { color: var(--brand-400); }

/* Post card */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transition: all var(--transition-base);
}
.post-card:hover {
  border-color: var(--border-brand);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 0 1px rgba(99,102,241,0.1);
}
.post-card-image {
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--bg-elevated);
}
.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}
.post-card:hover .post-card-image img { transform: scale(1.04); }
.post-card-body { padding: var(--space-5); flex: 1; }
.post-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.post-card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-snug);
  transition: color var(--transition-fast);
}
.post-card:hover .post-card-title { color: var(--brand-400); }
.post-card-excerpt { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-relaxed); }
.post-card-footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ============================================================
   COMPONENTS — BADGES & TAGS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}
.badge-brand   { background: rgba(99,102,241,0.15); color: var(--brand-400); border: 1px solid rgba(99,102,241,0.3); }
.badge-success { background: rgba(16,185,129,0.15); color: var(--accent-400); border: 1px solid rgba(16,185,129,0.3); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--gold-400); border: 1px solid rgba(245,158,11,0.3); }
.badge-error   { background: rgba(239,68,68,0.15);  color: #f87171;         border: 1px solid rgba(239,68,68,0.3); }
.badge-gray    { background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border-subtle); }

.tag {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.tag:hover { background: rgba(99,102,241,0.1); color: var(--brand-400); border-color: rgba(99,102,241,0.3); }

/* ============================================================
   COMPONENTS — FORMS
   ============================================================ */
.form-group { margin-bottom: var(--space-5); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.form-label span { color: var(--color-error); margin-left: 2px; }

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  transition: all var(--transition-fast);
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-brand);
  background: var(--bg-overlay);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-select { cursor: pointer; }
.form-hint { font-size: var(--text-xs); color: var(--text-muted); margin-top: var(--space-1); }
.form-error { font-size: var(--text-xs); color: var(--color-error); margin-top: var(--space-1); }
.form-input.is-error, .form-textarea.is-error, .form-select.is-error {
  border-color: var(--color-error);
}

/* ============================================================
   SITE HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--header-height);
  background: rgba(8,13,22,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  transition: background 0.3s ease, border-color 0.3s ease;
}

/* ── Theme Toggle Button ─────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover {
  background: var(--bg-overlay);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}
.theme-icon {
  position: absolute;
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
/* Dark mode: show sun, hide moon */
:root:not([data-theme="light"]) .theme-icon-sun  { opacity: 1; transform: rotate(0deg) scale(1); }
:root:not([data-theme="light"]) .theme-icon-moon { opacity: 0; transform: rotate(90deg) scale(0.5); }
/* Light mode: show moon, hide sun */
[data-theme="light"] .theme-icon-sun  { opacity: 0; transform: rotate(-90deg) scale(0.5); }
[data-theme="light"] .theme-icon-moon { opacity: 1; transform: rotate(0deg) scale(1); }
[data-theme="light"] .theme-toggle { color: var(--text-secondary); }

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}
.site-logo-text {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--fw-black);
  background: linear-gradient(135deg, #fff 30%, var(--brand-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.03em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.site-nav-link {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
}
.site-nav-link:hover, .site-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

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

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
}
.menu-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--transition-base);
}
/* ============================================================
   CONTENT + SIDEBAR LAYOUT
   ============================================================ */
.layout-content-sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: var(--space-10);
  align-items: start;
  /* Prevent grid blowout */
  width: 100%;
  max-width: 100%;
}
/* CRITICAL: all grid children must have min-width:0 */
.layout-content-sidebar > * {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
/* But allow sidebar to scroll vertically */
.layout-content-sidebar > aside,
.layout-content-sidebar > .layout-sticky-sidebar {
  overflow: visible;
}

.layout-sticky-sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
  max-height: calc(100vh - var(--header-height) - var(--space-12));
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

@media (max-width: 1024px) {
  .layout-content-sidebar {
    grid-template-columns: minmax(0, 1fr) 240px !important;
    gap: var(--space-8);
  }
}
@media (max-width: 768px) {
  .layout-content-sidebar {
    grid-template-columns: 1fr !important;
    gap: var(--space-6);
  }
  .layout-content-sidebar > * {
    width: 100% !important;
    max-width: 100% !important;
  }
  .layout-sticky-sidebar {
    position: static !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
}


.site-footer {
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: var(--space-20) 0 var(--space-8);
  margin-top: var(--space-20);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-12);
  margin-bottom: var(--space-16);
}
.footer-brand p { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-4); max-width: 280px; }

.footer-col-title {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.footer-links { display: flex; flex-direction: column; gap: var(--space-3); }
.footer-links a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
.footer-links a:hover { color: var(--text-primary); }

.footer-bottom {
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.footer-copyright { font-size: var(--text-sm); color: var(--text-muted); }

.social-links { display: flex; gap: var(--space-3); }
.social-link {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  text-decoration: none;
}
.social-link:hover {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.3);
  color: var(--brand-400);
}

/* ============================================================
   HERO SECTIONS
   ============================================================ */
.hero {
  position: relative;
  padding: var(--space-32) 0 var(--space-24);
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(99,102,241,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: rgba(99,102,241,0.1);
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  color: var(--brand-300);
  margin-bottom: var(--space-6);
}
.hero-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-400);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(1.5); }
}

.hero-title {
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-family: var(--font-display);
  font-weight: var(--fw-extrabold);
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  max-width: 900px;
  margin-bottom: var(--space-6);
}
.hero-title .gradient-text {
  background: linear-gradient(135deg, var(--brand-400), #a78bfa, var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-size: var(--text-xl);
  color: var(--text-secondary);
  max-width: 680px;
  margin-bottom: var(--space-10);
  line-height: var(--leading-relaxed);
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  align-items: center;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-8);
  margin-top: var(--space-16);
  padding-top: var(--space-16);
  border-top: 1px solid var(--border-subtle);
}
.hero-stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--fw-extrabold);
  font-family: var(--font-display);
  color: var(--text-primary);
}
.hero-stat-label { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }

/* ============================================================
   BREADCRUMBS
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; transition: color var(--transition-fast); }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb-sep { color: var(--text-disabled); }
.breadcrumb-current { color: var(--text-secondary); }

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */
.toc {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-8) 0;
}
.toc-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.toc-list { display: flex; flex-direction: column; gap: var(--space-2); }
.toc-item a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-1) 0;
  transition: color var(--transition-fast);
  border-left: 2px solid transparent;
  padding-left: var(--space-3);
}
.toc-item a:hover, .toc-item.active a { color: var(--brand-400); border-left-color: var(--brand-500); }
.toc-item.toc-h3 a { padding-left: var(--space-6); font-size: var(--text-xs); }

/* ============================================================
   AUTHOR BOX
   ============================================================ */
.author-box {
  display: flex;
  gap: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-top: var(--space-12);
}
.author-box-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}
.author-box-name { font-weight: var(--fw-semibold); color: var(--text-primary); }
.author-box-credentials { font-size: var(--text-xs); color: var(--text-muted); margin-top: 2px; }
.author-box-bio { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-2); }

/* ============================================================
   NEWSLETTER / LEAD CAPTURE
   ============================================================ */
.newsletter-box {
  background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.05));
  border: 1px solid rgba(99,102,241,0.2);
  border-radius: var(--radius-2xl);
  padding: var(--space-10) var(--space-8);
  text-align: center;
}
.newsletter-box h3 { font-size: var(--text-2xl); color: var(--text-primary); }
.newsletter-box p  { color: var(--text-secondary); margin: var(--space-3) 0 var(--space-6); }
.newsletter-form {
  display: flex;
  gap: var(--space-3);
  max-width: 460px;
  margin: 0 auto;
}
.newsletter-form .form-input { flex: 1; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
}
.stat-card:hover { border-color: var(--border-brand); box-shadow: var(--shadow-glow); }
.stat-card-value {
  font-size: var(--text-4xl);
  font-weight: var(--fw-black);
  font-family: var(--font-display);
  background: linear-gradient(135deg, var(--text-primary), var(--brand-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card-label { font-size: var(--text-sm); color: var(--text-muted); margin-top: var(--space-1); }

/* ============================================================
   GLOSSARY TERM
   ============================================================ */
.glossary-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.glossary-letter {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--brand-600);
  color: #fff;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-black);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
  position: relative;
  max-width: 640px;
  width: 100%;
}
.search-bar input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-10);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: var(--text-base);
  outline: none;
  transition: all var(--transition-fast);
}
.search-bar input:focus { border-color: var(--brand-500); box-shadow: var(--shadow-brand); }
.search-bar-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-12);
}
.pagination a, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  text-decoration: none;
  transition: all var(--transition-fast);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  background: var(--bg-surface);
}
.pagination a:hover { background: var(--bg-elevated); border-color: var(--border-default); color: var(--text-primary); }
.pagination .active { background: var(--brand-600); color: #fff; border-color: var(--brand-500); }
.pagination .disabled { opacity: 0.4; pointer-events: none; }

/* ============================================================
   ALERTS / MESSAGES
   ============================================================ */
.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.25); color: var(--accent-400); }
.alert-error   { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.25);  color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); color: var(--gold-400); }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: #60a5fa; }

/* ============================================================
   SKELETON LOADERS
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-overlay) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text  { height: 1em; margin-bottom: 0.5em; }
.skeleton-title { height: 1.5em; width: 60%; }
.skeleton-image { aspect-ratio: 16/9; }

/* ============================================================
   READING PROGRESS BAR
   ============================================================ */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-500), #8b5cf6, var(--accent-500));
  z-index: calc(var(--z-sticky) + 10);
  transition: width 100ms linear;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ── Tablet & Small Desktop (≤1024px) ──────────────────── */
/* ── Tablet (≤1024px) ──────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: var(--space-8); }

  /* Reduce header nav gap slightly */
  .site-nav { gap: 0; }
  .site-nav-link { padding: var(--space-2); font-size: var(--text-xs); }

  /* Scale down hero on tablets */
  .hero { padding: var(--space-20) 0 var(--space-16); }
  .hero-title { font-size: clamp(2rem, 5vw, 3.5rem); }

  /* Article sidebar: narrower */
  .article-layout,
  [style*="grid-template-columns:minmax(0,1fr) 300px"],
  [style*="grid-template-columns:minmax(0,1fr) 320px"],
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns:1fr 320px"] {
    grid-template-columns: 1fr 260px !important;
  }

  /* Services stats: 2 col on tablet */
  .svc-stats { grid-template-columns: repeat(2,1fr); }
}

/* ── Mobile (≤768px) ───────────────────────────────────── */
@media (max-width: 768px) {
  /* GLOBAL: prevent horizontal overflow */
  html, body { overflow-x: hidden; max-width: 100vw; }
  * { box-sizing: border-box; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero-title { font-size: 2rem; }
  .hero-subtitle { font-size: var(--text-base); }

  /* ── HEADER ────────────────────────────────────────────── */
  .site-nav { display: none; }
  .menu-toggle { display: flex; }

  /* Hide Hindi & CTA on very mobile-small header to avoid overflow */
  .header-actions .btn-ghost[href="/hi"] { display: none; }
  .header-actions { gap: var(--space-2); }
  .header-actions .btn-primary { font-size: 11px; padding: 6px 10px; }

  /* ── MOBILE NAV (outside header — viewport positioning) ── */
  .mobile-nav {
    display: none; /* hidden by default */
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    z-index: 999;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 16px 48px rgba(0,0,0,0.7);
    flex-direction: column;
    padding: var(--space-2) 0 var(--space-3);
    animation: mobileNavSlide 0.2s cubic-bezier(0.4,0,0.2,1);
  }
  .mobile-nav.is-open { display: flex; }
  .mobile-nav-inner { display: flex; flex-direction: column; }
  .mobile-nav-link {
    display: block;
    padding: var(--space-3) var(--space-5);
    font-size: var(--text-base);
    font-weight: var(--fw-medium);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    transition: color 0.15s, background 0.15s;
  }
  .mobile-nav-link:last-of-type { border-bottom: none; }
  .mobile-nav-link:hover,
  .mobile-nav-link.active { color: var(--brand-400); background: var(--bg-elevated); }
  .mobile-nav-footer { padding: var(--space-3) var(--space-5) 0; }

  /* Backdrop overlay */
  .mobile-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0,0,0,0.5);
    z-index: 998;
  }
  .mobile-nav-backdrop.is-visible { display: block; }

  @keyframes mobileNavSlide {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }


  /* Mobile nav — NO scrollbar, full content visible */
  .site-nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    /* NO bottom:0 — height is auto based on content */
    background: var(--bg-surface);
    padding: var(--space-3) var(--space-4) var(--space-4);
    z-index: var(--z-overlay);
    overflow: visible;  /* NO scrollbar */
    gap: 0;
    animation: slideDown 0.2s cubic-bezier(0.4,0,0.2,1);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  }
  .site-nav.is-open .site-nav-link {
    width: 100%;
    padding: var(--space-3) var(--space-3);
    font-size: var(--text-base);
    border-radius: 0;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
  }
  .site-nav.is-open .site-nav-link:last-child { border-bottom: none; }
  @keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── ARTICLE / PILLAR PAGE LAYOUT ─────────────────────── */
  /* Stack sidebar ABOVE content on mobile (sidebar = chapters, should come first) */
  [style*="grid-template-columns:minmax(0,1fr)"],
  [style*="grid-template-columns:1fr 300px"],
  [style*="grid-template-columns:1fr 320px"],
  [style*="grid-template-columns:1fr 280px"],
  [style*="grid-template-columns:2fr 1fr"],
  [style*="grid-template-columns:3fr 1fr"],
  [style*="display:grid;grid-template-columns:1fr 300px"],
  [style*="display:grid;grid-template-columns:1fr 320px"] {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar first (chapters on top), article below */
  .layout-content-sidebar > aside,
  .layout-content-sidebar > .layout-sticky-sidebar { order: 1; }
  .layout-content-sidebar > article,
  .layout-content-sidebar > div:not(.layout-sticky-sidebar) { order: 2; }

  /* Make sticky sidebar non-sticky on mobile */
  aside[style*="position:sticky"],
  [style*="position:sticky;top"],
  .layout-sticky-sidebar {
    position: static !important;
    top: auto !important;
    max-height: none !important;
  }

  /* ── TABLE OF CONTENTS ─────────────────────────────────── */
  .toc {
    margin: var(--space-4) 0;
    max-height: none;
    overflow: visible;
  }
  /* Collapsible TOC on mobile */
  .toc details { display: block; }
  .toc-list { display: none; }
  .toc.toc-open .toc-list { display: flex; }
  .toc-title {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0;
    padding-bottom: var(--space-2);
    user-select: none;
  }
  .toc-title::after {
    content: '▾';
    font-size: 14px;
    transition: transform 0.2s;
    flex-shrink: 0;
  }
  .toc.toc-open .toc-title { margin-bottom: var(--space-4); }
  .toc.toc-open .toc-title::after { transform: rotate(180deg); }

  /* ── SERVICES PAGE ─────────────────────────────────────── */
  .svc-hero { padding: var(--space-14) 0 var(--space-10); }
  .svc-hero-title { font-size: clamp(1.75rem,6vw,2.5rem); }
  .svc-hero-actions { flex-direction: column; align-items: stretch; }
  .svc-hero-actions .btn { justify-content: center; }
  .svc-stats {
    grid-template-columns: repeat(2,1fr);
    gap: var(--space-3);
  }
  .svc-stat-divider { display: none; }
  .svc-section { padding: var(--space-8) 0; }
  .svc-cards { grid-template-columns: 1fr; }
  .svc-card-features { display: none; } /* hide features list on mobile cards */
  .svc-cta-grid,
  [style*="grid-template-columns:1fr 300px"] { grid-template-columns: 1fr !important; }

  /* ── SERVICE SINGLE PAGE CTA ───────────────────────────── */
  [style*="grid-template-columns:1fr 300px;gap:var(--space-10)"] {
    grid-template-columns: 1fr !important;
  }

  /* ── CONTACT PAGE ──────────────────────────────────────── */
  /* Contact form grid → single column */
  [style*="grid-template-columns:1fr 1fr;gap:var(--space-4)"] {
    grid-template-columns: 1fr !important;
  }

  /* ── FREE AUDIT PAGE ───────────────────────────────────── */
  .audit-hero-inner { flex-direction: column !important; }
  .audit-form-col { width: 100% !important; min-width: 0 !important; }
  [style*="grid-template-columns:1fr 1fr;gap"] { grid-template-columns: 1fr !important; }

  /* ── FOOTER ────────────────────────────────────────────── */
  .footer-grid { grid-template-columns: 1fr; gap: var(--space-8); }
  .newsletter-form { flex-direction: column; }
  .author-box { flex-direction: column; }
  .hero-stats { flex-direction: column; gap: var(--space-6); }
  .footer-bottom { flex-direction: column; align-items: flex-start; }

  /* ── CARDS ─────────────────────────────────────────────── */
  .card { padding: var(--space-5); }
  .post-card-body { padding: var(--space-4); }
  .post-card-footer { padding: var(--space-3) var(--space-4); }

  /* ── BUTTONS ───────────────────────────────────────────── */
  .hero-actions { flex-direction: column; align-items: stretch; }
  .hero-actions .btn { justify-content: center; }

  /* ── PAGINATION ────────────────────────────────────────── */
  .pagination a, .pagination span { width: 36px; height: 36px; font-size: var(--text-xs); }

  /* ── NEWSLETTER FOOTER ─────────────────────────────────── */
  .newsletter-form .form-input { min-width: 0; }

  /* ── STAT BARS (4-col grids) ───────────────────────────── */
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }
  [style*="grid-template-columns:repeat(3,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }

  /* ── PROSE / ARTICLE CONTENT ───────────────────────────── */
  .prose { font-size: var(--text-base); }
  .prose pre { overflow-x: auto; }
  .prose table { display: block; overflow-x: auto; }
  .prose img { max-width: 100%; height: auto; }
}

/* ── Small Mobile (≤480px) ─────────────────────────────── */
@media (max-width: 480px) {
  .container { padding: 0 var(--space-4); }
  .hero { padding: var(--space-12) 0 var(--space-10); }
  .hero-title { font-size: 1.75rem; }
  .section { padding: var(--space-10) 0; }
  .section-lg { padding: var(--space-16) 0; }

  /* Shrink badge text */
  .hero-badge { font-size: 10px; }

  /* Reduce heading sizes */
  h1 { font-size: clamp(1.5rem, 7vw, 2rem); }
  h2 { font-size: clamp(1.25rem, 5vw, 1.75rem); }

  /* Footer newsletter row */
  [style*="display:flex;align-items:center;justify-content:space-between"] {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  .newsletter-form { min-width: 100% !important; }

  /* Footer bottom */
  .footer-grid { gap: var(--space-6); }
  .footer-brand p { max-width: 100%; }

  /* Buttons */
  .btn-lg { padding: var(--space-3) var(--space-6); font-size: var(--text-sm); }

  /* Author box */
  .author-box { padding: var(--space-4); }
  .author-box-avatar { width: 48px; height: 48px; }

  /* Cards */
  .svc-card-header { flex-wrap: wrap; }
  .svc-card-badge { font-size: 10px; }

  /* Service stats: single col */
  .svc-stats { grid-template-columns: 1fr 1fr; }

  /* Stats bar in service single page */
  [style*="grid-template-columns:repeat(4,1fr)"] { grid-template-columns: repeat(2,1fr) !important; }

  /* Process steps: wrap nicely */
  [style*="display:flex;gap:var(--space-3);flex-wrap:wrap;justify-content:center"] {
    gap: var(--space-2) !important;
  }
}

/* ── Touch device improvements ──────────────────────────── */
@media (hover: none) and (pointer: coarse) {
  /* Increase tap targets */
  .btn { min-height: 44px; }
  .site-nav-link { min-height: 44px; display: flex; align-items: center; }
  .tag { padding: var(--space-2) var(--space-3); }
  .pagination a, .pagination span { width: 44px; height: 44px; }

  /* Remove hover transforms on touch (reduces jank) */
  .card:hover, .post-card:hover, .svc-card:hover { transform: none; }

  /* Keep hover states for accessibility but no lift */
  .btn-primary:hover { transform: none; }
  .btn-gradient:hover { transform: none; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-primary { color: var(--text-primary); }
.text-secondary{color: var(--text-secondary); }
.text-muted   { color: var(--text-muted); }
.text-brand   { color: var(--brand-400); }
.text-success { color: var(--color-success); }
.text-error   { color: var(--color-error); }
.text-sm      { font-size: var(--text-sm); }
.text-xs      { font-size: var(--text-xs); }
.font-bold    { font-weight: var(--fw-bold); }
.font-semibold{ font-weight: var(--fw-semibold); }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rounded-full { border-radius: var(--radius-full); }
.hidden       { display: none; }
.w-full       { width: 100%; }
.mt-4         { margin-top: var(--space-4); }
.mt-6         { margin-top: var(--space-6); }
.mt-8         { margin-top: var(--space-8); }
.mb-4         { margin-bottom: var(--space-4); }
.mb-6         { margin-bottom: var(--space-6); }
.mb-8         { margin-bottom: var(--space-8); }
.gradient-text {
  background: linear-gradient(135deg, var(--brand-400), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ============================================================
   UX POLISH — GLOBAL FIXES (all pages, both mobile + web)
   ============================================================ */

/* ── 1. Global: word-break for long titles ─────────────────── */
h1, h2, h3, h4 {
  overflow-wrap: break-word;
  word-break: break-word;
}

/* ── 2. Section headers (flex between title and "View All" btn) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
}

/* ── 3. Post/Article: tags row flex-wrap ────────────────────── */
.post-tags, .post-meta-tags, .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── 4. Hero stats: improved on all sizes ───────────────────── */
.hero-stats {
  display: flex;
  gap: var(--space-8);
  flex-wrap: wrap;
  margin-top: var(--space-10);
  padding-top: var(--space-8);
  border-top: 1px solid var(--border-subtle);
}
.hero-stat-value {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--text-primary);
  font-family: var(--font-display);
}
.hero-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── 5. Prose: cap h2/h3 size for readability ──────────────── */
.prose h2 { font-size: clamp(var(--text-xl), 3vw, var(--text-3xl)); }
.prose h3 { font-size: clamp(var(--text-lg), 2.5vw, var(--text-2xl)); }
.prose h4 { font-size: var(--text-xl); }

/* ── 6. Author box: proper flex layout ─────────────────────── */
.author-box {
  display: flex;
  gap: var(--space-5);
  align-items: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin: var(--space-10) 0;
}
.author-box-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}
.author-box-info { flex: 1; min-width: 0; }
.author-box-name { font-weight: var(--fw-semibold); color: var(--text-primary); margin-bottom: var(--space-1); }
.author-box-bio { font-size: var(--text-sm); color: var(--text-secondary); line-height: var(--leading-relaxed); }

/* ── 7. Breadcrumb: don't overflow ─────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-6);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--brand-400); }
.breadcrumb-sep { opacity: 0.4; }

/* ── 8. Glossary alphabet nav: flex-wrap ────────────────────── */
.glossary-alpha, .alpha-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* ── 9. Process steps: hide arrows on mobile cleanly ──────── */
.process-arrow { display: inline-flex; align-items: center; }

/* ── 10. Newsletter form: always stack on wrap ──────────────── */
.newsletter-form {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.newsletter-form .form-input { flex: 1; min-width: 200px; }

/* ── 11. Inline style flex headers — universal fix ─────────── */
[style*="justify-content:space-between"][style*="display:flex"] {
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ── 12. Card grids — consistent gaps ──────────────────────── */
.grid.gap-6 { gap: var(--space-6); }
.grid.gap-4 { gap: var(--space-4); }


/* ============================================================
   UX POLISH — MOBILE OVERRIDES (≤768px)
   ============================================================ */
@media (max-width: 768px) {

  /* Section padding reduction */
  .section    { padding: var(--space-12) 0; }
  .section-sm { padding: var(--space-8) 0; }
  .section-lg { padding: var(--space-16) 0; }

  /* ── LAYOUT: Content+Sidebar stacking ─────────────────────── */
  /* Define layout class HERE (guaranteed live) */
  .layout-content-sidebar {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: var(--space-5) !important;
  }
  /* Hide entire aside sidebar on mobile — CHAPTERS, Author, Quick Links */
  /* User sees article content only; TOC shown inline in article */
  .layout-content-sidebar > aside,
  .layout-sticky-sidebar {
    display: none !important;
  }
  .layout-content-sidebar > article { order: 1 !important; }

  /* ── MOBILE MENU: no scrollbar ───────────────────────────── */
  .site-nav.is-open {
    overflow: visible !important;
    bottom: auto !important;
    height: auto !important;
    max-height: none !important;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  }

  /* ── AUTHOR BOX (in-article, below content) padding fix ───── */
  #author-box {
    padding: var(--space-4) !important;
    margin-top: var(--space-8) !important;
  }
  #author-box > div {
    flex-direction: column !important;
    gap: var(--space-3) !important;
    align-items: flex-start !important;
  }
  #author-box > div > div:first-child {
    width: 48px !important;
    height: 48px !important;
    font-size: 20px !important;
  }


  /* Section header: stack on mobile */
  .section-header { margin-bottom: var(--space-6); }
  .section-header .btn-secondary,
  .section-header .btn-sm { width: 100%; justify-content: center; }

  /* Hero stats: 2x2 grid on mobile */
  .hero-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    margin-top: var(--space-8);
  }
  .hero-stat-value { font-size: var(--text-xl); }

  /* Prose mobile typography */
  .prose h2 { font-size: var(--text-xl); margin: var(--space-8) 0 var(--space-3); }
  .prose h3 { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-2); }
  .prose ul, .prose ol { padding-left: var(--space-5); }

  /* Post article image: limit height on mobile */
  .post-card-image { max-height: 220px; }
  .post-hero-image { max-height: 240px; object-fit: cover; }

  /* Author box: stack on mobile */
  .author-box {
    flex-direction: column;
    padding: var(--space-5);
    gap: var(--space-4);
  }
  .author-box-avatar { width: 48px; height: 48px; }

  /* Breadcrumb: smaller text */
  .breadcrumb { font-size: var(--text-xs); margin-bottom: var(--space-4); }

  /* Card interactive: reduce padding */
  .card-interactive { padding: var(--space-4); }

  /* Process steps: hide separator arrows */
  .process-arrow { display: none; }

  /* Newsletter form: full stack */
  .newsletter-form { flex-direction: column; }
  .newsletter-form .form-input { min-width: 0; }
  .newsletter-form .btn { width: 100%; justify-content: center; }

  /* Contact card: reduce mobile padding */
  .contact-card { padding: var(--space-5) !important; }

  /* Service single: feature card padding */
  .card.card-interactive { padding: var(--space-4); }

  /* Services svc-stat font */
  .svc-stat-value { font-size: var(--text-2xl) !important; }

  /* Footer newsletter row */
  .footer-newsletter-row {
    flex-direction: column;
    align-items: flex-start !important;
  }

  /* Inline style flex between → wrap */
  [style*="display:flex;align-items:center;justify-content:space-between"] {
    flex-wrap: wrap !important;
    gap: var(--space-3) !important;
  }

  /* Reduce heading padding-top in container */
  .container > h1:first-child,
  .container > h2:first-child { margin-top: 0; }

  /* Safe area bottom padding for forms (notch phones) */
  .audit-form-card, .contact-form-card {
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
  }
}

/* ── Very small screens (≤420px) ──────────────────────────── */
@media (max-width: 420px) {
  /* Hide header "Free Audit" btn — too cramped */
  .header-cta-btn { display: none !important; }

  /* Remove border from last mobile nav link */
  .site-nav.is-open .site-nav-link:last-child { border-bottom: none; }

  /* Smaller container padding */
  .container { padding: 0 var(--space-3); }

  /* Hero title line-height tighter */
  .hero-title { line-height: 1.2; }

  /* Stats: single column */
  .hero-stats { grid-template-columns: 1fr 1fr; gap: var(--space-4); }

  /* Process steps: full width pills */
  [style*="display:flex;gap:var(--space-3);flex-wrap:wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  [style*="display:flex;gap:var(--space-3);flex-wrap:wrap"] > div {
    width: 100% !important;
  }

  /* Smaller card padding */
  .card { padding: var(--space-4); }
  .card-glass { padding: var(--space-4); }

  /* Tags smaller */
  .tag { font-size: 10px; padding: 2px var(--space-2); }
}

