/* ==========================================================================
   Base — reset, document, typography primitives, shared utilities
   ========================================================================== */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* keeps focused targets clear of the sticky header */
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-text);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* Grain sits above the background but below all content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--grain);
  opacity: 0.30;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 1;
}

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

a { color: inherit; }

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

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

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

/* --- Layout shell --------------------------------------------------------- */

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

.section {
  position: relative;
  z-index: 2;
  padding-block: var(--space-section);
}

/* --- Type primitives ------------------------------------------------------ */

.label {
  font-size: var(--text-label);
  font-weight: 600;
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--ink-mute);
}

.label--accent { color: var(--accent); }

.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: -0.018em;
  text-wrap: balance;
}

.display em {
  font-style: italic;
  color: var(--accent);
}

.lead {
  font-size: var(--text-lead);
  line-height: 1.48;
  color: var(--ink-soft);
  max-width: var(--measure);
  text-wrap: pretty;
}

/* --- Section heading ------------------------------------------------------ */

.section-head {
  display: grid;
  gap: 1.25rem;
  padding-bottom: clamp(1.5rem, 2.4vw, 2.25rem);
  border-bottom: 1px solid var(--ink);
  margin-bottom: clamp(2rem, 3.5vw, 3.5rem);
}

@media (min-width: 60rem) {
  .section-head {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    align-items: end;
    gap: 3rem;
  }
}

.section-head__title {
  font-size: var(--text-h2);
  grid-column: 1;
}

.section-head__note {
  color: var(--ink-mute);
  font-size: var(--text-small);
  max-width: 34ch;
}

/* --- Links ---------------------------------------------------------------- */

.link {
  --link-line: color-mix(in oklab, var(--accent) 55%, transparent);
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  text-decoration: none;
  padding-bottom: 2px;
  background-image: linear-gradient(var(--link-line), var(--link-line));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--duration-normal) var(--ease-out-expo),
              color var(--duration-fast) linear;
}

.link:hover,
.link:focus-visible {
  color: var(--accent);
  --link-line: var(--accent);
}

/* --- Button --------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.82em 1.5em;
  border-radius: 999px;
  font-size: var(--text-small);
  font-weight: 550;
  letter-spacing: -0.005em;
  text-decoration: none;
  border: 1px solid var(--ink);
  transition: transform var(--duration-fast) var(--ease-out-soft),
              background-color var(--duration-fast) linear,
              color var(--duration-fast) linear,
              border-color var(--duration-fast) linear;
}

.btn--solid { background: var(--ink); color: var(--paper); }
.btn--solid:hover { background: var(--accent); border-color: var(--accent); }

.btn--ghost { color: var(--ink); border-color: var(--rule-strong); }
.btn--ghost:hover { border-color: var(--ink); background: var(--paper-raised); }

.btn:active { transform: translateY(1px); }

/* --- Scroll progress bar --------------------------------------------------- */

@supports (animation-timeline: scroll()) {
  .progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    transform-origin: 0 50%;
    transform: scaleX(0);
    z-index: 60;
    animation: progress-grow linear both;
    animation-timeline: scroll(root);
  }

  @keyframes progress-grow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
  }
}

/* --- Scroll reveal -------------------------------------------------------- */

/* Content only hides for the reveal when main.js is running (it adds .js). */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--duration-slow) var(--ease-out-soft),
              transform var(--duration-slow) var(--ease-out-expo);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

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

.skip-link:focus {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  width: auto;
  height: auto;
  margin: 0;
  padding: 0.6rem 1.1rem;
  overflow: visible;
  clip-path: none;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@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;
  }

  .js .reveal { opacity: 1; transform: none; }
}

/* --- Print ------------------------------------------------------------------
   Reveals only fire on scroll, so make sure a printed or saved page shows
   everything, without the fixed header or the moving ticker. */
@media print {
  .js .reveal { opacity: 1; transform: none; }
  .site-header, .progress, .ticker { display: none; }
}
