/**
 * Reset, typography primitives, grid and shared utilities.
 */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: auto; /* Lenis owns smooth scrolling; native smooth would fight it */
}

/* Lenis drives transform-based scrolling. Without this the page keeps native scroll too. */
html.lenis,
html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  font-synthesis-weight: none;
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

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

img, video { height: auto; }

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

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

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

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

/* Visible focus is never removed — only replaced with something that matches
   the hard-edged visual language. */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 3px;
}

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

.display-xl,
.display-l,
.display-m,
.display-s {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
  text-wrap: balance;
}

.display-xl { font-size: var(--t-display-xl); }
.display-l  { font-size: var(--t-display-l); }
.display-m  { font-size: var(--t-display-m); }
.display-s  { font-size: var(--t-display-s); line-height: var(--lh-heading); }

.heading {
  font-family: var(--font-display);
  font-size: var(--t-heading);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-heading);
  text-transform: uppercase;
}

.body-l {
  font-size: var(--t-body-l);
  line-height: 1.45;
  max-width: var(--measure);
  color: var(--fg-muted);
}

.body {
  font-size: var(--t-body);
  max-width: var(--measure);
  color: var(--fg-muted);
}

/* Technical annotation. Used for every small uppercase label on the site. */
.label {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--fg-faint);
  line-height: 1;
}

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

/* Numbered index used across services, process and portfolio. */
.index {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  letter-spacing: 0.1em;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

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

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

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  gap: var(--grid-gap);
}

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

/* Section head: a mono label on the left, the headline beneath. The rule above
   is what gives the page its drawing-sheet feel. */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-5);
  padding-top: var(--s-4);
  border-top: var(--border-hair) solid var(--rule-strong);
  margin-bottom: var(--s-8);
}

.rule {
  height: var(--border-hair);
  background: var(--rule);
  border: 0;
  width: 100%;
}

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

.u-hide { display: none !important; }

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

.skip-link {
  position: absolute;
  top: 0; left: 0;
  z-index: calc(var(--z-cursor) + 1);
  transform: translateY(-120%);
  background: var(--c-charcoal);
  color: var(--c-paper);
  padding: var(--s-3) var(--s-5);
  font-family: var(--font-mono);
  font-size: var(--t-label);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  transition: transform var(--d-fast) var(--e-out);
}

.skip-link:focus { transform: translateY(0); }

/* ---- Media -------------------------------------------------------------- */

/* Every editorial image sits in a fixed-ratio frame so the page never shifts
   while images decode. The LQIP is painted as a background underneath. */
.media {
  position: relative;
  overflow: hidden;
  background-color: var(--c-concrete);
  background-size: cover;
  background-position: center;
}

/* Descendant, not child: bundled assets render as <picture><img>, so the image is
   a grandchild of the frame. Attachment images render as a bare <img>. Both match. */
.media img,
.media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media picture {
  display: block;
  width: 100%;
  height: 100%;
}

.media--16x9 { aspect-ratio: 16 / 9; }
.media--4x3  { aspect-ratio: 4 / 3; }
.media--3x4  { aspect-ratio: 3 / 4; }
.media--1x1  { aspect-ratio: 1 / 1; }
.media--tall { aspect-ratio: 3 / 4; }

/* Images fade in once decoded rather than popping. */
.media img {
  opacity: 0;
  transition: opacity var(--d-base) var(--e-out);
}

.media img.is-loaded,
.no-js .media img { opacity: 1; }

/* ---- Reveal primitive ---------------------------------------------------
   Elements start hidden only when JS is available to reveal them, so a JS
   failure or a crawler still sees full content. */
.js [data-reveal] {
  opacity: 0;
  will-change: transform, opacity;
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
