/* ═══════════════════════════════════════════════════════════════
   MADMAX — Global Design System
   Shared variables, reset, scrollbar, selection, background glow,
   and unified navbar/topbar padding for consistent mobile UX.
   ═══════════════════════════════════════════════════════════════ */

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

/* ── Design tokens ────────────────────────────────────────────── */
:root {
  --bg:       #0a0e14;
  --bg2:      #0d1117;
  --bg3:      #161b22;
  --bg4:      #1c2333;
  --border:   #21262d;
  --border2:  #30363d;
  --text:     #f0f6fc;
  --text2:    #c9d1d9;
  --text3:    #8b949e;
  --text4:    #484f58;
  --red:      #f85149;
  --red-glow: rgba(248,81,73,0.35);
  --red-deep: #b91c1c;
  --purple:   #8b5cf6;
  --blue:     #58a6ff;
  --blue-deep:#1d4ed8;
  --green:    #3fb950;
  --orange:   #d29922;
  --serif:    Georgia, 'Times New Roman', 'Noto Serif', serif;
  --sans:     'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono:     'JetBrains Mono', 'SF Mono', Consolas, monospace;
  --radius:   10px;
  /* ── Unified nav dimensions ── */
  --nav-height: 60px;
  --nav-pad-x: 24px;
  --nav-pad-x-sm: 14px;  /* <=480px */
}

/* ── Body base ────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text2);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Ambient background glow ─────────────────────────────────── */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 0%, rgba(248,81,73,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(139,92,246,0.04) 0%, transparent 60%);
}

/* ── Base link ────────────────────────────────────────────────── */
a { color: inherit; text-decoration: none; }

/* ── Selection ────────────────────────────────────────────────── */
::selection { background: rgba(248,81,73,0.3); color: #fff; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text4); }

/* ── Google Fonts preconnect reminder ─────────────────────────
   Each page should include in <head>:
   <link rel="preconnect" href="https://fonts.googleapis.com">
   <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
   <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
   ─────────────────────────────────────────────────────────────── */

/* ═══════════════════════════════════════════════════════════════
   UNIFIED NAV BAR — used by both .navbar (listing) and .topbar (articles)
   Same height, same horizontal padding, same responsive breakpoints.
   ═══════════════════════════════════════════════════════════════ */

/* ── Listing pages: .navbar ──────────────────────────────────── */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: var(--nav-height);
  background: rgba(10,14,20,0.82);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center;
  padding: 0 var(--nav-pad-x);
}
.navbar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(88,166,255,0.3) 50%, transparent 100%);
}
.navbar-inner {
  max-width: 1200px; width: 100%; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.navbar-logo {
  font-family: Georgia, serif; font-size: 18px; font-weight: 400;
  letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 8px;
  transition: opacity .2s;
}
.navbar-logo:hover { opacity: 0.8; }
.navbar-logo span { color: var(--red); font-weight: 700; }
.navbar-right { display: flex; align-items: center; gap: 20px; font-size: 13px; }
.navbar-right a {
  color: var(--text3); transition: color .2s; font-weight: 500;
  position: relative;
}
.navbar-right a::after {
  content: '';
  position: absolute; bottom: -4px; left: 0; right: 0;
  height: 2px; background: var(--red);
  transform: scaleX(0); transition: transform .25s;
  border-radius: 1px;
}
.navbar-right a:hover { color: var(--text); }
.navbar-right a:hover::after { transform: scaleX(1); }
.navbar-right a.active { color: var(--text); }
.navbar-right a.active::after { transform: scaleX(1); }

/* ── Article pages: .topbar ──────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-height);
  background: rgba(10,14,20,0.85);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 0;
}
.topbar::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--red) 0%, rgba(139,92,246,0.4) 50%, transparent 100%);
}
.topbar-inner {
  max-width: 780px; margin: 0 auto;
  padding: 0 var(--nav-pad-x);
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-home {
  font-family: var(--serif); font-size: 15px; color: var(--text);
  white-space: nowrap; display: flex; align-items: center; gap: 5px;
  transition: opacity .2s;
}
.topbar-home span { color: var(--red); font-weight: 700; }
.topbar-home:hover { text-decoration: none; opacity: 0.8; }
.topbar-sep { color: var(--border2); font-size: 18px; flex-shrink: 0; }
.topbar-title { font-size: 13px; color: var(--text3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 14px; flex-shrink: 0; font-size: 12px; color: var(--text4); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — Unified breakpoints
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .navbar-right { gap: 14px; }
}

@media (max-width: 480px) {
  :root {
    --nav-pad-x: 14px;
  }
  .navbar-right { gap: 12px; }
  .navbar-right a { font-size: 12px; }
  .topbar-title { display: none; }
}

@media (max-width: 375px) {
  :root {
    --nav-pad-x: 12px;
  }
}
