/* =====================================================================
   LM Visuals — Base: reset, typography, global atmosphere
   ===================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* iOS: respect safe areas + avoid rubber-band white flash */
  background: var(--bg-deep);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  /* iOS momentum + no pull-to-refresh jank when Lenis is active */
  -webkit-tap-highlight-color: transparent;
}

/* When JS-driven smooth scroll is active we stop native smooth scroll fighting it */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

img, picture, video, canvas, svg { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; padding: 0; }

::selection { background: var(--accent); color: var(--accent-contrast); }

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

/* ---- Type ---- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  font-optical-sizing: auto;
}
h2 { font-size: var(--fs-h2); line-height: var(--lh-tight); }
h3 { font-size: var(--fs-h3); }
h4 { font-size: var(--fs-h4); }
p { text-wrap: pretty; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-body);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent);
}
.eyebrow::before {
  content: "";
  width: 1.8rem;
  height: 1px;
  background: currentColor;
  opacity: 0.7;
}
.eyebrow--center::before { display: none; }

.lead { font-size: var(--fs-lead); color: var(--text-muted); line-height: 1.5; }
.muted { color: var(--text-muted); }
.serif { font-family: var(--font-display); }
.accent-text { color: var(--accent); }

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

.section { padding-block: var(--space-section); position: relative; }
.section__head { max-width: 60ch; margin-bottom: var(--space-xl); }
.section__head--center { margin-inline: auto; text-align: center; }
.section__title { margin-top: var(--space-sm); }
.section__intro { margin-top: var(--space-md); }

.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 — hidden until keyboard-focused, then visible on-screen */
.skip-link {
  position: fixed;
  top: -200px;
  left: 1rem;
  z-index: var(--z-overlay);
  background: var(--accent);
  color: var(--accent-contrast);
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transition: top var(--dur-fast) var(--ease-out);
}
.skip-link:focus {
  top: calc(env(safe-area-inset-top, 0px) + 0.75rem);
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* ---- Film-grain + vignette atmosphere ---- */
.grain {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  opacity: 0.06;
  contain: strict;
  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='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette {
  position: fixed;
  inset: 0;
  z-index: var(--z-grain);
  pointer-events: none;
  background: radial-gradient(120% 120% at 50% 30%, transparent 55%, oklch(0% 0 0 / 0.45) 100%);
}

/* ---- Custom scrollbar (desktop) ---- */
@media (pointer: fine) {
  ::-webkit-scrollbar { width: 10px; }
  ::-webkit-scrollbar-track { background: var(--bg-deep); }
  ::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: var(--radius-pill);
    border: 2px solid var(--bg-deep);
  }
  ::-webkit-scrollbar-thumb:hover { background: var(--accent-strong); }
}

/* ---- Custom cursor (fine pointers only) ---- */
.cursor, .cursor-dot { display: none; }
@media (pointer: fine) {
  .cursor {
    position: fixed; top: 0; left: 0;
    width: 38px; height: 38px;
    border: 1px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: var(--z-cursor);
    transition: width var(--dur-base) var(--ease-out),
                height var(--dur-base) var(--ease-out),
                background-color var(--dur-base) var(--ease-out),
                opacity var(--dur-base) var(--ease-out);
    display: block;
    opacity: 0;
  }
  .cursor-dot {
    position: fixed; top: 0; left: 0;
    width: 5px; height: 5px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: var(--z-cursor);
    display: block;
    opacity: 0;
  }
  .cursor.is-active {
    width: 64px; height: 64px;
    background: var(--accent-soft);
  }
  body.cursor-ready { cursor: none; }
  body.cursor-ready a,
  body.cursor-ready button { cursor: none; }
}

/* ---- Reduced motion: calm everything ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .cursor, .cursor-dot { display: none !important; }
  body.cursor-ready { cursor: auto; }
}
