/* ============================================================
   Base — typography, layout primitives, global behaviours.
   Components and pages compose on top of these.
   ============================================================ */

html {
  /* 100%, never a px value: pinning this to 16px silently overrides the
     user's browser font-size preference, so anyone who has enlarged
     their default text gets nothing. Every size downstream is rem, so
     honouring the preference scales the whole layout with it. */
  font-size: 100%;
  background: var(--abyssal);
  color: var(--pearl);
  /* Hide native scrollbar visually — scroll still works fully.
     Lenis (loaded by js/main.js) handles smooth scrolling. */
  -ms-overflow-style: none;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
  width: 0;
  background: transparent;
}

body {
  font-family: var(--font-sans);
  font-size: var(--type-body);
  font-weight: 400;
  line-height: var(--lh-body);
  background: var(--abyssal);
  color: var(--pearl);
  /* Kerning + contextual alternates only. The previous
     "ss01","ss02","cv01" set was General Sans's stylistic-alternate
     codes, left behind when the body face changed to Author — those
     codes mean something different (or nothing) in Author, so they
     were firing unintended glyph substitutions. Never carry one
     font's feature codes over to another. */
  font-feature-settings: "kern", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  hanging-punctuation: first allow-end last;
  /* clip, not hidden. `hidden` makes the element a scroll container,
     which is the documented way sticky positioning silently dies; it
     survives here only because html is `visible`, so body's overflow
     propagates to the viewport instead. `clip` never creates a scroll
     container, so the ten sticky heads on this site cannot be broken
     by a future ancestor gaining an overflow. Declared as a pair —
     Safari below 16 ignores `clip` and keeps `hidden`. */
  overflow-x: hidden;
  overflow-x: clip;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Lock scroll while hero animation runs */
body.is-locked {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;   /* dvh here: the lock should match whatever the
                       viewport actually is at this instant */
}

/* ---------- Display & headings ---------- */

/* Each step below pairs its own size, tracking and leading. `.display`
   deliberately sets NO size/tracking of its own — it is a face+colour
   mixin applied on top of h1/h2/h3, and when it also carried a fixed
   -0.02em that one value leaked onto everything from 22px to 112px.
   Optical sizing lets the variable face adjust its own contrast. */
.display,
h1.display, h2.display, h3.display {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--pearl);
  text-wrap: balance;
  font-optical-sizing: auto;
}

h1, .h1 {
  font-family: var(--font-display);
  font-size: var(--type-display-xl);
  font-weight: 500;
  line-height: var(--lh-display-xl);
  letter-spacing: var(--tr-display-xl);
  color: var(--pearl);
  font-optical-sizing: auto;
}

h2, .h2 {
  font-family: var(--font-display);
  font-size: var(--type-display-l);
  font-weight: 500;
  line-height: var(--lh-display-l);
  letter-spacing: var(--tr-display-l);
  color: var(--pearl);
  font-optical-sizing: auto;
}

h3, .h3 {
  font-family: var(--font-display);
  font-size: var(--type-display-m);
  font-weight: 500;
  line-height: var(--lh-display-m);
  letter-spacing: var(--tr-display-m);
  color: var(--pearl);
  font-optical-sizing: auto;
}

h4, .h4 {
  font-family: var(--font-display);
  font-size: var(--type-display-s);
  font-weight: 500;
  line-height: var(--lh-display-s);
  letter-spacing: var(--tr-display-s);
  color: var(--pearl);
}

/* ---------- Body text ---------- */

p {
  max-width: var(--reading-max);
  line-height: var(--lh-body-text);
  letter-spacing: var(--tr-body);
  color: var(--pearl);
  text-wrap: pretty;
}

p + p { margin-top: var(--space-3); }

.lead {
  font-size: var(--type-body-l);
  line-height: var(--lh-body-l);
  letter-spacing: var(--tr-body-l);
  max-width: 56ch;
}

.muted    { color: var(--pearl-muted); }
.subtle   { color: var(--pearl-quiet); }
.brand    { color: var(--navy); }

/* ---------- Eyebrow / overline labels (brief §3.2) ----------
   General Sans, uppercase, weight 500, letter-spacing 0.18em,
   colour --pearl-muted. No red rule prefix — that was a Matrix
   pattern, gone. Use a separate `.hairline` element when a rule
   is wanted. */

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--type-eyebrow);
  /* 500 -> 550: small uppercase type over translucent glass needs a
     little more weight to hold its colour (Apple's vibrancy rule —
     don't fight a moving backdrop with thin flat grey). */
  font-weight: 550;
  text-transform: uppercase;
  letter-spacing: var(--tr-eyebrow-t);
  line-height: var(--lh-eyebrow);
  color: var(--pearl-muted);
  display: inline-block;
}

.label {
  font-family: var(--font-sans);
  font-size: var(--type-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-label);
  color: var(--pearl);
}

/* ---------- Numeric face ---------- */

.numeric,
.tabular {
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum", "lnum";
}

.numeric {
  font-family: var(--font-numeric);
  letter-spacing: -0.015em;
}

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

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

.section {
  padding-block: var(--section-pad-y);
}

.section-tight {
  padding-block: clamp(4rem, 8vw, 7rem);
}

.divider {
  height: var(--hairline);
  background: var(--color-divider);
  border: none;
  width: 100%;
}

.rule {
  display: block;
  width: 64px;
  height: 1px;
  background: color-mix(in srgb, var(--pearl) 40%, transparent);
  border: none;
  margin-block: var(--space-3);
}
.rule--short { width: 24px; }

/* Legacy aliases for the old red rule — now a quiet pearl hairline. */
.rule-red,
.rule-red--thin {
  display: block;
  height: 1px;
  background: color-mix(in srgb, var(--pearl) 35%, transparent);
  border: none;
  margin-block: var(--space-3);
}
.rule-red       { width: 64px; }
.rule-red--thin { width: 24px; }

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

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--dur-micro) var(--ease-out-expo);
}

a:hover { color: var(--pearl); }

/* Inline body links — underline draws from left on hover (brief §7.3).
   Scoped to text-flow contexts only (not nav, not cards, not utility
   links that already manage their own underline). */
.story__body a:not(.link-arrow),
.about-excerpt__body a:not(.link-arrow),
.office__body dd a {
  position: relative;
  display: inline;
  background:
    linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat,
    linear-gradient(color-mix(in srgb, var(--pearl) 28%, transparent),
                    color-mix(in srgb, var(--pearl) 28%, transparent)) left bottom / 100% 1px no-repeat;
  background-position: 0 100%, 0 100%;
  padding-bottom: 2px;
  transition: background-size var(--dur-short) var(--ease-out-expo);
}
.story__body a:not(.link-arrow):hover,
.about-excerpt__body a:not(.link-arrow):hover,
.office__body dd a:hover {
  background-size: 100% 1px, 100% 1px;
}

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-sans);
  font-size: var(--type-caption);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--tr-eyebrow);
  color: var(--pearl);
  padding-bottom: 2px;
  transition: gap var(--dur-short) var(--ease-out-expo), color var(--dur-micro) var(--ease-out-expo);
}

.link-arrow > span:not(.arrow) {
  border-bottom: 1px solid color-mix(in srgb, var(--pearl) 30%, transparent);
  padding-bottom: 4px;
  transition: border-color var(--dur-short) var(--ease-out-expo);
}

.link-arrow .arrow {
  display: inline-block;
  transition: transform var(--dur-short) var(--ease-out-expo);
}

.link-arrow:hover {
  color: var(--pearl);
  gap: 0.85em;
}
.link-arrow:hover > span:not(.arrow) {
  border-color: var(--pearl);
}
.link-arrow:hover .arrow { transform: translateX(4px); }

/* ---------- Reveal helpers (set by reveals.js / GSAP) ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(24px);
}

/* ---------- Skip link ---------- */

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-2);
  background: var(--surface);
  color: var(--pearl);
  padding: var(--space-2) var(--space-3);
  z-index: var(--z-modal);
  border: 1px solid var(--pearl);
  font-size: var(--type-caption);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  transition: top var(--dur-micro) var(--ease-out-expo);
}

.skip-link:focus { top: var(--space-2); }

/* ---------- Reduced-motion overrides for JS-driven choreography ---------- */

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  body.is-locked {
    overflow: auto;
    height: auto;
  }
}

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

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

.no-scroll { overflow: hidden !important; }

/* ---------- Focus states (brief §8 a11y) ----------
   Designed, never browser-default. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--pearl);
  outline-offset: 3px;
  border-radius: 1px;
}
.lang-toggle__btn:focus-visible,
.menu-toggle:focus-visible,
.menu-list a:focus-visible,
.link-arrow:focus-visible {
  outline-offset: 6px;
}

/* ------------------------------------------------------------------
   ANCHOR LANDING — every in-page link (the products chapter rail, the
   contact page's "see office details") previously scrolled its target
   flush to y=0, i.e. underneath the fixed header, so the heading you
   clicked was the one thing you could not see. scroll-margin-top
   reserves the chrome height plus a little breathing room.
   ------------------------------------------------------------------ */
:target,
[id] {
  scroll-margin-top: calc(var(--header-h) + var(--space-4));
}
@media (max-width: 768px) {
  :target,
  [id] { scroll-margin-top: calc(var(--header-h-mobile) + var(--space-3)); }
}
/* The chapter rail is itself sticky below the header, so its targets
   need to clear both. */
.page-products #cephalopods,
.page-products #shrimp,
.page-products #fish,
.page-products #canned,
.page-products #cannery,
.page-products #oem {
  scroll-margin-top: calc(var(--header-h) + 3.5rem + var(--space-3));
}
