/* ==========================================================================
   base.css — reset, typography, layout primitives, motion utilities
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + var(--space-4));
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Theme swap should crossfade, but never on first paint — theme.js removes
   .theme-booting after the initial theme is applied. */
html.theme-booting,
html.theme-booting * {
  transition: none !important;
}
body,
.site-header,
.card,
.chip,
.btn,
input,
textarea,
select {
  transition-property: background-color, border-color, color, box-shadow;
  transition-duration: var(--dur-base);
  transition-timing-function: var(--ease-out);
}

img,
picture,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button { cursor: pointer; }

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

a {
  color: var(--brand);
  text-decoration-color: color-mix(in srgb, var(--brand) 40%, transparent);
  text-underline-offset: 0.2em;
}
a:hover { color: var(--brand-hover); }

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--text);
  text-wrap: balance;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

p { text-wrap: pretty; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }

::selection {
  background: color-mix(in srgb, var(--brand) 26%, transparent);
  color: var(--text);
}

/* --------------------------------------------------------------------------
   Focus — visible for keyboard users, suppressed for mouse clicks
   -------------------------------------------------------------------------- */

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) { outline: none; }

.skip-link {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  z-index: calc(var(--z-toast) + 1);
  padding: var(--space-3) var(--space-5);
  /* Pinned to brand-600 rather than --brand: in dark mode --brand resolves to
     the lighter brand-400, which only gives white text ~3:1. */
  background: var(--brand-600);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  transform: translateY(-200%);
  transition: transform var(--dur-base) var(--ease-out);
}
.skip-link:focus { transform: translateY(0); color: #fff; }

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */

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

.section {
  position: relative;
  padding-block: var(--section-y);
}
.section--sunken { background: var(--bg-subtle); }

/* NOTE: `content-visibility: auto` was tried here and deliberately removed.
   On a single page whose entire nav is anchor links, the placeholder heights
   of not-yet-rendered sections made every #anchor jump land in the wrong
   place, and it left sections blank in full-page screenshots and print.
   The page is small enough that it bought nothing measurable. */

.section-head {
  max-width: 60ch;
  margin-bottom: var(--space-12);
}
.section-head--center {
  margin-inline: auto;
  text-align: center;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--brand);
}
.eyebrow::before {
  content: "";
  width: 24px;
  height: 2px;
  border-radius: var(--radius-full);
  background: var(--gradient-brand);
}
.section-head--center .eyebrow::before { display: none; }

.section-sub {
  margin-top: var(--space-4);
  font-size: var(--text-lg);
  color: var(--text-secondary);
}

.gradient-text {
  background: var(--gradient-text);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  /* Fallback if background-clip:text is unsupported. */
  -webkit-text-fill-color: transparent;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--solid { fill: currentColor; stroke: none; }

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Scroll reveal — the base state. reveal.js adds .is-visible.
   No-JS users get .no-js on <html>, which forces everything visible.
   -------------------------------------------------------------------------- */

[data-reveal] {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition:
    opacity var(--dur-reveal) var(--ease-out),
    transform var(--dur-reveal) var(--ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
  will-change: opacity, transform;
}
[data-reveal="left"]  { transform: translate3d(-28px, 0, 0); }
[data-reveal="right"] { transform: translate3d(28px, 0, 0); }
[data-reveal="scale"] { transform: scale(0.94); }

[data-reveal].is-visible {
  opacity: 1;
  transform: none;
  will-change: auto;
}

html.no-js [data-reveal] {
  opacity: 1;
  transform: none;
}

/* --------------------------------------------------------------------------
   Reduced motion — content lands in its final state, nothing is left hidden
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* --------------------------------------------------------------------------
   Print — "print to PDF" should yield a readable one-pager
   -------------------------------------------------------------------------- */

@media print {
  :root {
    --bg: #fff; --surface: #fff; --text: #000;
    --text-secondary: #333; --border: #ccc;
  }
  .site-header,
  .hero__bg,
  .hero__visual,
  .nav-toggle,
  .theme-toggle,
  .cursor,
  .scroll-progress,
  .to-top,
  .contact-form,
  .filter-bar { display: none !important; }

  body { background: #fff; }
  .section { padding-block: 1.5rem; break-inside: avoid; }
  a::after { content: " (" attr(href) ")"; font-size: 0.8em; color: #555; }
  a[href^="#"]::after { content: ""; }
}
