/* Reset & base element styling */

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

* {
  margin: 0;
}

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  /* Explicit root colour: iPhone Safari falls back to it for the strip
     around the Dynamic Island and for overscroll at the page edges. */
  background-color: var(--color-bg);
}

@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;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  /* Landscape phones: keep page content out from under the notch or
     camera cutout at the sides (0 everywhere else). */
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100svh;
}

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

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-3xl); }
h2 { font-size: var(--fs-2xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p {
  color: var(--color-text-muted);
}

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

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

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

/* Accessible focus ring, visible only for keyboard users */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Utilities */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

.container--narrow {
  max-width: var(--content-narrow);
}

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

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 1000;
  background: var(--color-accent);
  color: var(--color-ink);
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: top var(--dur-fast) var(--ease-out);
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--color-accent);
}

/* ============================================================
   Scroll reveal
   Elements fade/rise in when js/main.js adds .is-revealed.
   --reveal-delay is set per-element by JS to stagger a group;
   it defaults to 0ms so an un-staggered element still works.
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Grouped stagger — the container is the scroll trigger, but its children
   are what actually animate, each offset by the --reveal-delay that
   js/main.js assigns. The container's own fade/slide is switched off
   here: leaving it on would slide the whole group as a block while the
   children slide inside it, doubling the motion. */
[data-reveal][data-reveal-stagger] {
  opacity: 1;
  transform: none;
  transition: none;
}

[data-reveal-stagger] > * {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal-stagger].is-revealed > * {
  opacity: 1;
  transform: translateY(0);
}

/* Wipe variant — used for photographs. Instead of fading, the frame is
   unveiled bottom-to-top via clip-path while the image itself settles
   from a slight overscale. Reads like a print being drawn from a sleeve.
   Declared after the base rule so it wins the same-specificity tie.

   The clip lands on the CHILD, never on the observed element itself.
   IntersectionObserver folds clipping into its ratio, so an element
   clipped to inset(100%) reports zero intersection and never fires —
   it would sit there clipped forever, waiting for a reveal that its own
   hidden state prevents. Clipping one level down keeps the observed
   box's geometry intact and breaks that deadlock. */
[data-reveal="wipe"] {
  opacity: 1;
  transform: none;
  clip-path: none;
}

[data-reveal="wipe"] > * {
  /* `round` keeps the clip in step with the element's border-radius;
     without it the wipe would square off any rounded corners. Consumers
     set --reveal-radius to match (see .grid-gallery__item). */
  clip-path: inset(100% 0 0 0 round var(--reveal-radius, 0px));
  transition: clip-path 1.15s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal="wipe"].is-revealed > * {
  clip-path: inset(0 0 0 0 round var(--reveal-radius, 0px));
}

[data-reveal="wipe"] img {
  transform: scale(1.06);
  transition: transform 1.4s var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}

[data-reveal="wipe"].is-revealed img {
  transform: scale(1);
}

@media (prefers-reduced-motion: reduce) {
  [data-reveal],
  [data-reveal="wipe"],
  [data-reveal="wipe"] > *,
  [data-reveal="wipe"] img,
  [data-reveal-stagger] > * {
    opacity: 1;
    transform: none;
    clip-path: none;
    transition: none;
    transition-delay: 0ms !important;
  }
}

/* ============================================================
   Film grain
   A single fixed noise layer over the whole page for analog
   texture. Static rather than animated on purpose: a flickering
   grain repaints the full viewport every frame, which is a real
   cost on an image-heavy mobile page for a subtle payoff.
   ============================================================ */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   Cross-document View Transitions
   Gives page-to-page navigation a crossfade, and lets elements
   tagged with a matching view-transition-name morph between
   pages (see [data-vt-name] in js/main.js). Progressive
   enhancement: browsers without support just navigate normally.
   ============================================================ */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 420ms;
  animation-timing-function: var(--ease-out);
}

/* Persist the header across navigations instead of crossfading it */
.site-header {
  view-transition-name: site-header;
}

/* A morphing photo should travel above the page it's leaving */
::view-transition-group(*) {
  animation-duration: 520ms;
  animation-timing-function: var(--ease-out);
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) {
    animation: none !important;
  }
}

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