/* ============================================================
   base.css
   Shared variables, resets, layout, header, footer, components
   ============================================================ */


:root {
  --bg:    #f5f2ec;
  --ink:   #1a1814;
  --red:   #c0392b;
  --rule:  #d0cbbe;
  --muted: #8a8270;
  --paper: #faf8f3;
  --green: #2a6b3c;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Global link baseline ───────────────────────────────── */
/* Removes browser-default blue. Specific contexts (nav, footer,
   prose, buttons) override these with their own styles. */
a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.2s, border-color 0.2s;
}
a:hover {
  color: var(--red);
  border-color: var(--red);
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Grid paper background */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--rule) 1px, transparent 1px),
    linear-gradient(90deg, var(--rule) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

/* ── Animations ─────────────────────────────────────────── */
@keyframes appear {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes drawLine {
  to { width: 100%; }
}

/* ── Shared Nav (article pages) ─────────────────────────── */
.site-nav {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 48px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  animation: appear 0.4s ease forwards 0.05s;
}

.nav-home {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.nav-home:hover { color: var(--red); border-color: var(--red); }

.nav-title {
  font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
  font-weight: 900;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-title span {
  font-style: italic;
  font-weight: 400;
  color: var(--red);
}

/* ── Shared Footer ──────────────────────────────────────── */
.site-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 48px 40px;
  border-top: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  opacity: 0;
  animation: appear 0.4s ease forwards 1.3s;
}

.footer-rule {
  width: 100%;
  height: 2px;
  background: var(--ink);
}

.footer-left {
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.footer-tags { display: flex; gap: 10px; }

.footer-tag {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--rule);
}

.footer-center { display: flex; align-items: center; gap: 8px; }

.footer-legal-link {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.footer-legal-link:hover { color: var(--red); border-bottom-color: var(--red); }

.footer-legal-sep { font-size: 10px; color: var(--rule); }

/* ── Contact block (shared) ─────────────────────────────── */
.contact-block {
  margin-top: 44px;
  margin-bottom: 44px;
  padding: 26px 26px 22px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--red);
  position: relative;
  opacity: 0;
  animation: appear 0.5s ease forwards 1.05s;
}

.contact-corner {
  position: absolute;
  top: -1px; right: -1px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 0 22px 22px 0;
  border-color: transparent var(--bg) transparent transparent;
}

.contact-heading {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.contact-heading span { color: var(--red); }

.contact-block p {
  font-size: 13px;
  line-height: 1.75;
  color: #4a4640;
  margin-bottom: 18px;
  max-width: 420px;
}

.btn-primary {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-bottom: none;
  color: var(--bg);
  font-family: 'Courier Prime', 'Courier New', Courier, monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}

.btn-primary:hover { background: var(--red); border-color: var(--red); }

.links-row {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  font-size: 12px;
}

.links-row a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid var(--rule);
  transition: color 0.2s, border-color 0.2s;
}

.links-row a:hover { color: var(--red); border-color: var(--red); }

/* ── Skip navigation ────────────────────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  padding: 8px 16px;
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-decoration: none;
  border-bottom: none;
  z-index: 9999;
}

.skip-link:focus { top: 0; }

/* ── Dark mode ──────────────────────────────────────────── */

/* Anti-FOUC: applied via inline script before CSS renders.
   Palette: editorial luxury noir — warm, never cold or clinical.
   #111009 bg: deep warm near-black, like premium matte dark stock.
   #ede7da ink: aged vellum cream, not clinical white.
   Rule and paper sit just above bg to create depth without harshness. */
[data-theme="dark"] {
  --bg:    #111009;
  --ink:   #ede7da;
  --red:   #c0392b;
  --rule:  #252219;
  --muted: #7a6e5e;
  --paper: #1b1916;
}

/* Grid paper pattern — stays but subtler on dark */
[data-theme="dark"] body::before { opacity: 0.22; }

/* Hardcoded hex values that CSS variables can't reach */
[data-theme="dark"] .subhead p,
[data-theme="dark"] .cluster-desc,
[data-theme="dark"] .contact-block p { color: #b0a898; }

[data-theme="dark"] .prose p { color: #d5cfc4; }

[data-theme="dark"] .article-deck { color: #a09080; }

/* Smooth colour transitions when toggling — class added/removed by JS */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease,
    color 0.3s ease !important;
}

/* ── Theme toggle button ─────────────────────────────────── */
.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  color: var(--muted);
  width: 26px;
  height: 26px;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, color 0.2s;
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--red);
  color: var(--ink);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

/* Icon visibility — moon shown in light mode, sun in dark */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: block; }

[data-theme="dark"] .theme-toggle .icon-sun  { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Mobile shared ──────────────────────────────────────── */

/* Grid opacity — reduce on mobile in light mode (closer screen, more distracting) */
@media (max-width: 860px) {
  html:not([data-theme="dark"]) body::before {
    opacity: 0.2;
  }
}
@media (max-width: 680px) {
  .site-nav,
  .site-footer { padding-left: 24px; padding-right: 24px; }
  .site-footer { flex-direction: column; gap: 10px; align-items: flex-start; }
}