/* ==========================================================================
   BASE / RESET
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-interface);
  font-size: var(--type-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* No horizontal scroll under any circumstance (brief §16). */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

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

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

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

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

h1, h2, h3, p, figure {
  margin: 0;
}

::selection {
  background: var(--color-selection-bg);
  color: var(--color-selection-text);
}

/* ---- Focus ---------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

section[data-bg="red"] :focus-visible,
.dock :focus-visible {
  outline-color: var(--color-focus-ring);
}

/* ---- Safe areas (iOS notch / home indicator) ------------------------- */
body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* ---- Skip link (accessibility) ---------------------------------------- */
.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-16);
  z-index: 1000;
  background: var(--color-warm-white);
  color: var(--color-ink);
  padding: var(--space-12) var(--space-16);
  font-family: var(--font-interface);
  font-size: var(--type-interface);
  font-weight: 600;
  transition: top var(--motion-fast) var(--ease-standard);
}

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

/* ---- Reduced motion: global kill-switch -------------------------------
   Every animated/transitioning element in this system opts in via a class
   or attribute; this rule is the final safety net so nothing decorative
   moves when the user has asked for stillness. Functional transitions
   (e.g. dock show/hide) are handled explicitly in JS, not blocked here,
   since they convey real state changes, not decoration. */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
    clip-path: none !important;
  }
  /* Phase 6.2 QA fix: .mask-reveal (the quarter-circle image-wipe used by
     the About portrait and every project-sheet/narrative image, see
     components.css and reveal.js) had no reduced-motion override at all.
     It still starts fully clipped (clip-path: inset(0 100% 0 0)) and only
     reaches its final state through a JS-added .is-revealed class plus a
     600ms CSS transition — so a reduced-motion user got the exact same
     animated clip-path wipe as everyone else, which contradicts "no
     essential content depends on animation." Same fix as .reveal above,
     using the same established !important convention already in this
     block: force the final, fully-unclipped state and remove the
     transition, so the image is present at full width the instant it's
     eligible (still scroll-triggered like .reveal, just with the motion
     itself removed). */
  .mask-reveal {
    transition: none !important;
    clip-path: none !important;
  }
}

/* ---- Visually hidden but accessible ----------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
