/* ═══════════════════════════════════════════════
   BASE.CSS — shared across every page
   ═══════════════════════════════════════════════ */

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

/* ── Design tokens ── */
:root, [data-theme="light"] {
  --bg:           #f2f4f8;
  --surface:      #ffffff;
  --surface2:     #f7f8fa;
  --border:       #e1e4eb;
  --accent:       #2563eb;
  --accent-hover: #1d4ed8;
  --accent-text:  #ffffff;
  --text:         #1a1d27;
  --muted:        #8892a4;
  --success:      #16a34a;
  --input-bg:     #fafbfc;
  --shadow:       0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.04);
  --toggle-track: #cbd5e1;
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    14px;
}

[data-theme="dark"] {
  --bg:           #0d0f14;
  --surface:      #13161e;
  --surface2:     #1a1e28;
  --border:       #252a38;
  --accent:       #e8c84a;
  --accent-hover: #f0a030;
  --accent-text:  #0d0f14;
  --text:         #dce3f0;
  --muted:        #5a6278;
  --success:      #4ecb71;
  --input-bg:     #0d0f14;
  --shadow:       0 1px 4px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.2);
  --toggle-track: #252a38;
}

/* ── Base ── */
html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Syne', sans-serif;
  overflow-x: hidden;
  transition: background 0.25s, color 0.25s;
}

/* ── Layout ── */
.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px 56px;
}
.layout--narrow {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ── Typography ── */
h1 {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 16px;
}
h2 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 40px 0 14px;
  color: var(--text);
}
h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 28px 0 10px;
  color: var(--text);
}
p {
  font-size: 15px;
  color: var(--muted);
  line-height: 1.8;
  margin-bottom: 16px;
}
ul, ol { padding-left: 20px; margin-bottom: 16px; }
li { font-size: 15px; color: var(--muted); line-height: 1.8; margin-bottom: 6px; }
strong { color: var(--text); font-weight: 700; }
a { color: var(--accent); }
code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
.nav-logo {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  text-decoration: none;
}
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }
.nav-back {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.nav-back:hover { color: var(--accent); }

/* ── Buttons ── */
.btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.17s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  text-decoration: none;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.3);
}
[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 4px 14px rgba(232,200,74,0.28);
}
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(0) !important; }
.btn.success {
  background: var(--success) !important;
  color: #fff !important;
  border-color: transparent !important;
}

/* ── Theme toggle ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px 6px 8px;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.tt-track {
  width: 34px;
  height: 18px;
  background: var(--toggle-track);
  border-radius: 9px;
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}
[data-theme="dark"] .tt-track { background: var(--accent); }
.tt-track::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
[data-theme="dark"] .tt-track::after { left: 18px; }

/* ── Mini toggle (line numbers etc) ── */
.toggle {
  width: 28px; height: 15px;
  background: var(--toggle-track);
  border-radius: 8px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  width: 11px; height: 11px;
  background: white;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle.on::after { left: 15px; }

/* ── Callout / tip ── */
.callout {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin: 20px 0;
}
.callout p { margin: 0; }

/* ── CTA box ── */
.cta-box {
  background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  margin: 40px 0;
  color: white;
}
.cta-box h2 { color: white; margin-top: 0; }
.cta-box p { color: rgba(255,255,255,0.8); }
.cta-box .btn {
  background: white;
  color: #2563eb;
  font-size: 13px;
  padding: 11px 26px;
  margin-top: 14px;
}
.cta-box .btn:hover { transform: translateY(-2px); }

/* ── Post meta ── */
.post-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.post-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--accent);
  background: rgba(37,99,235,0.08);
  border: 1px solid rgba(37,99,235,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.post-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}

/* ── Footer ── */
.footer {
  padding: 28px 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}
.footer-copy {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
}
.footer-links { display: flex; gap: 20px; }
.footer-links a {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-links a:hover { color: var(--accent); }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 9px 18px;
  border-radius: var(--radius);
  opacity: 0;
  transition: all 0.28s ease;
  pointer-events: none;
  white-space: nowrap;
  z-index: 10000;
  box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .icon { color: var(--success); }

/* ── Comparison table ── */
.compare-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.compare-table th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.compare-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  vertical-align: top;
}
.compare-table tr:last-child td { border-bottom: none; }
.compare-table tr:hover td { background: var(--surface2); }
.compare-table tr.best td { background: rgba(37,99,235,0.04); }
.tick  { color: #16a34a; font-weight: 700; }
.cross { color: #dc2626; font-weight: 700; }
.mid   { color: #d97706; font-weight: 700; }

/* ── Responsive ── */
@media (max-width: 740px) {
  .layout { padding: 0 16px 48px; }
  .layout--narrow { padding: 0 16px 48px; }
}
