/* =============================================================
   shared.css — The Made Self
   Variables · Reset · Body · Nav · Animations
   Linked by every page on the site.
   ============================================================= */

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg:       #0e0d0c;
  --bg2:      #161513;
  --bg3:      #1e1c1a;
  --border:   rgba(255,255,255,0.07);
  --text:     #e8e4dc;
  --muted:    #9a9690;
  --accent:   #c9a96e;
  --accent2:  #8b6f47;
  --serif:    'Cormorant Garamond', Georgia, serif;
  --sans:     'DM Sans', system-ui, sans-serif;
  --ease:     0.4s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg:       #f5f2ec;
  --bg2:      #ede9e1;
  --bg3:      #e4dfd5;
  --border:   rgba(0,0,0,0.08);
  --text:     #1a1917;
  --muted:    #635f5b;
  --accent:   #8b6030;
  --accent2:  #b8843f;
}

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

html {
  scroll-behavior: smooth;
  /* Backstop: if the breathing overlay ever bleeds through (Safari
     compositor edge cases), the html element shows the same dark
     color instead of the browser's default white. */
  background: #0e0d0c;
}

/* ── Base ────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  line-height: 1.7;
  transition: background var(--ease), color var(--ease);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.022;
  pointer-events: none;
  z-index: 1000;
}

/* ── Visually hidden — accessible but not visible ───────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Skip to content ─────────────────────────────────────────── */
.skip-to-content {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg);
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 20px;
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}
.skip-to-content:focus {
  top: 16px;
}

/* ── Navigation ──────────────────────────────────────────────── */
nav {
  position: fixed; top: 0; z-index: 90;
  /* Centre the nav in the viewport so it always aligns with the
     page's content container (site-wrap or body::after bars) */
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--max-w, 1280px); /* fallback for pages that don't load index.css */
  padding: 22px var(--pad, clamp(24px, 5vw, 80px));
  display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(to bottom, var(--bg) 55%, transparent);
}

/* Last-updated chip in nav */
.nav-updated {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 300;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.42;
  white-space: nowrap;
}
@media (max-width: 540px) {
  .nav-updated { display: none; }
}

.nav-logo {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--ease);
}
.nav-logo:hover { color: var(--text); }

/* Nav right group */
.nav-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-link {
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color var(--ease);
}
.nav-link:hover { color: var(--text); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px 14px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.1em;
  color: var(--muted);
  transition: border-color var(--ease), color var(--ease);
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }

/* Sun/moon icon visibility */
.icon-sun                     { display: none; }
[data-theme="dark"] .icon-sun  { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }

/* ── Animations ──────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; opacity: 1 !important; }
}


/* ── Breathing overlay — first-visit entrance ────────────────── */
#breath-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0e0d0c;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0;
  opacity: 1;
  transition: opacity 1.6s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
  /* NO will-change, transform, or backface tricks here.
     Previous attempts all added GPU-promotion CSS in the hope of
     "containing" the brownish flash — but they were the cause of it.
     will-change:opacity pre-promotes the overlay to a compositor layer.
     When the text labels then fire their CSS opacity transitions inside
     that pre-promoted layer, Safari has to re-rasterize it, and briefly
     shows the stale compositor buffer — revealing the warm-colored page
     behind. Without will-change the overlay stays in the normal paint
     flow; there is no pre-created layer to go stale, so no flash.
     The fade-out transition still GPU-composes fine: it just promotes
     at the moment it actually runs, not preemptively. */
  isolation: isolate;
}
#breath-overlay.leaving {
  opacity: 0;
  pointer-events: none;
}
/* Ring lives inside a fixed-size wrapper so scaling never overlaps the text below */
.breath-ring-wrap {
  width: 220px;
  height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.breath-ring {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(201,169,110,0.45);
  animation: breath-cycle 9s ease-in-out forwards;
  /* No will-change — Safari already GPU-promotes @keyframes on
     transform/opacity automatically. Explicit will-change was
     creating a nested compositor sub-layer inside the overlay,
     which compounded the compositing problem. */
}
@keyframes breath-cycle {
  0%   { transform: scale(0.85); opacity: 0.15; }
  8%   { opacity: 0.6; }
  42%  { transform: scale(2.4);  opacity: 0.75; }
  52%  { transform: scale(2.4);  opacity: 0.70; }
  92%  { transform: scale(0.85); opacity: 0.20; }
  100% { transform: scale(0.85); opacity: 0.05; }
}
/* Two-label crossfade wrapper — avoids a textContent DOM mutation
   (which triggers a Safari repaint and can cause the flash). */
.breath-text-wrap {
  position: relative;
  height: 18px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.breath-text {
  position: absolute;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(201,169,110,0.90);
  /* No CSS transition — the crossfade is driven by breath.js via
     requestAnimationFrame so no CSS compositor promotion ever fires
     inside the overlay, which was the cause of Safari's color flashes. */
  white-space: nowrap;
}
.breath-skip {
  margin-top: 36px;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  opacity: 0;
  animation: breath-skip-in 1s 5s forwards;
}
@keyframes breath-skip-in {
  to { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  #breath-overlay { display: none !important; }
}
