/* ==========================================================================
   StilledInk — Base
   Fonts, reset, typography, atmosphere (grain), layout helpers, motion.
   ========================================================================== */

/* --- Self-hosted variable fonts (latin subset) --------------------------- */
@font-face {
  font-family: "Fraunces";
  src: url("../assets/fonts/fraunces-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/inter-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* --- Reset --------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-h) + 16px);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--paper-200);
  background-color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-optical-sizing: auto;
  overflow-x: hidden;
  position: relative;
  min-height: 100%;
}

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

a { color: inherit; text-decoration: none; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

ul { list-style: none; padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent-300);
  outline-offset: 3px;
  border-radius: 4px;
}

/* --- Atmosphere: subtle paper grain over the whole canvas ---------------- */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Page content sits above the grain layer */
.page { position: relative; z-index: 2; }

/* ─── CUSTOM CURSOR ─── */
@media (pointer: fine) {
  html.custom-cursor-ready body {
    cursor: none;
  }
  #cur {
    position: fixed;
    width: 6px;
    height: 6px;
    background: var(--ember-400);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    transition: width 0.15s, height 0.15s, background 0.15s;
    display: none;
  }
  #cur-ring {
    position: fixed;
    width: 28px;
    height: 28px;
    border: 1px solid var(--ember-400);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%);
    transition: width 0.25s, height 0.25s, opacity 0.25s, border-color 0.25s;
    opacity: 0.35;
    display: none;
  }
  html.custom-cursor-ready #cur,
  html.custom-cursor-ready #cur-ring {
    display: block;
  }
  html.custom-cursor-ready body:has(a:hover, button:hover, .btn:hover) #cur {
    width: 10px;
    height: 10px;
  }
  html.custom-cursor-ready body:has(a:hover, button:hover, .btn:hover) #cur-ring {
    width: 44px;
    height: 44px;
    opacity: 0.6;
  }
}

/* --- Typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--paper-50);
  font-weight: 500;
  line-height: var(--lh-head);
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); letter-spacing: -0.005em; }

.display {
  font-family: var(--font-serif);
  font-size: var(--fs-display);
  line-height: var(--lh-tight);
  letter-spacing: -0.022em;
  font-weight: 480;
  color: var(--paper-50);
}

p { color: var(--paper-200); }

strong { color: var(--paper-50); font-weight: 600; }

.lead {
  font-size: var(--fs-lead);
  line-height: 1.5;
  color: var(--paper-200);
}

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--fs-caption);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-300);
}

.muted { color: var(--paper-400); }

/* --- Layout helpers ------------------------------------------------------ */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: var(--section-y); position: relative; }
.section--tight { padding-block: clamp(56px, 8vh, 104px); }

.measure { max-width: var(--measure); }
.center { text-align: center; margin-inline: auto; }

.divider {
  height: 1px;
  background: var(--line);
  border: 0;
  width: 100%;
  margin: 0;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -64px;
  z-index: 100;
  background: var(--ink-700);
  color: var(--paper-50);
  padding: 10px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-hair);
  transition: top var(--dur-base) var(--ease-quiet);
}
.skip-link:focus { top: var(--sp-4); }

/* --- Motion: scroll reveal ----------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--dur-slow) var(--ease-quiet),
              transform var(--dur-slow) var(--ease-quiet);
  will-change: opacity, transform;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger children when parent carries .stagger */
.stagger > * { transition-delay: var(--d, 0ms); }

/* --- Reduced motion ------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
