/* ==========================================================================
   BASE — fonts, reset, typography defaults, shared components & utilities.
   ========================================================================== */

/* ---- Self-hosted fonts ------------------------------------------------- */
/* Only the two weights the design actually renders. Regular (400) and
   Bold (700) were declared but never used by any rule — dead requests
   waiting to happen. */
@font-face {
  font-family: "Clash Display";
  src: url("../assets/fonts/ClashDisplay-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Clash Display";
  src: url("../assets/fonts/ClashDisplay-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../assets/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("../assets/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

/* ---- Reset ------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--color-text-muted) transparent;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth; /* fallback when Lenis is not driving */
  }
}

/* Lenis drives scrolling programmatically — native smooth would fight it */
html.lenis {
  scroll-behavior: auto;
}

/* One-shot colour morph when the theme flips (class pulsed by theme.js).
   Colour properties only, and only for the length of the swap — never a
   standing transition on every element. */
html.theme-anim body,
html.theme-anim body * {
  transition:
    background-color var(--dur-fast) var(--ease-adjust),
    color var(--dur-fast) var(--ease-adjust),
    border-color var(--dur-fast) var(--ease-adjust);
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

/* Film grain over everything — the cinematic layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 998;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

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

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

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

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

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

/* ==========================================================================
   TOUCH — sized by pointer type, not by viewport width. A touch laptop
   needs finger-sized targets just as much as a phone does.
   Everything here reaches the 44px minimum without changing how the design
   looks: inline links grow their hit area with padding and take the space
   back with a negative margin, so the typographic rhythm is untouched.
   ========================================================================== */
@media (pointer: coarse) {
  /* No grey flash on tap — this site has its own feedback */
  a,
  button,
  input,
  textarea,
  [role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .btn {
    min-height: 44px;
  }

  .brand {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    min-width: 44px;
    padding-inline: 0.6rem;
    margin-inline: -0.6rem;
  }

  .theme-toggle,
  .nav-burger {
    width: 2.75rem;
    height: 2.75rem;
  }

  /* Inline links: hit area grows, layout does not */
  .link,
  .site-nav a,
  .contact__mail,
  .work-item__link,
  .to-top {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding-block: 0.55rem;
    margin-block: -0.55rem;
  }

  /* Stacked link lists need real separation between adjacent targets */
  .contact__links,
  .site-footer__links {
    gap: var(--sp-3);
  }
}

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

/* ---- Typography defaults ----------------------------------------------- */
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--track-tight);
  text-wrap: balance;
}

p {
  max-width: 62ch;
}

strong {
  font-weight: 600;
}

/* ---- Utilities ---------------------------------------------------------- */
.container {
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--container-pad);
}

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

.section--ruled {
  border-top: 1px solid var(--color-line);
}

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

.skip-link {
  position: fixed;
  top: var(--sp-3);
  left: var(--sp-3);
  z-index: var(--z-skip);
  padding: var(--sp-3) var(--sp-5);
  background: var(--color-accent-deep);
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  border-radius: var(--radius-pill);
  transform: translateY(-300%);
}

.skip-link:focus-visible {
  transform: none;
}

/* Mono eyebrow label: "01 — About" */
.eyebrow {
  display: flex;
  align-items: baseline;
  gap: 0.9em;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--color-text-muted);
}

.eyebrow__idx {
  color: var(--color-accent-ink);
}

/* Section heading block */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--gutter);
  margin-bottom: var(--head-gap);
}

.section-head__title {
  font-size: var(--fs-h2);
  text-transform: uppercase;
  margin-top: var(--sp-4);
}

.section-head__note {
  display: none;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--color-text-muted);
  padding-bottom: 0.75em;
  white-space: nowrap;
}

@media (min-width: 768px) {
  .section-head__note {
    display: block;
  }
}

/* Outlined display text (background words, cover monograms) */
.text-outline {
  color: transparent;
  -webkit-text-stroke: 1px var(--color-text);
}

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

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.65em;
  padding: 1em 1.75em;
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  transition:
    background-color var(--dur-micro) ease,
    border-color var(--dur-micro) ease,
    color var(--dur-micro) ease,
    transform var(--dur-micro) var(--ease-adjust);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  background: var(--color-text);
  border-color: var(--color-text);
  color: var(--color-bg);
}

.btn--primary:hover {
  background: var(--color-accent-deep);
  border-color: var(--color-accent-deep);
  color: #ffffff;
}

.btn--ghost:hover {
  border-color: var(--color-text);
}

.btn__arrow {
  transition: transform var(--dur-micro) var(--ease-adjust);
}

.btn:hover .btn__arrow {
  transform: translate(2px, -2px);
}

/* ---- Tags --------------------------------------------------------------- */
.tag {
  display: inline-block;
  padding: 0.4em 0.95em;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

/* ---- Inline text links -------------------------------------------------- */
.link {
  position: relative;
  transition: color var(--dur-micro) ease;
}

.link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.15em;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--dur-base) var(--ease-adjust);
}

.link:hover {
  color: var(--color-accent-ink);
}

.link:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* ---- Text masks (intro + set pieces) ------------------------------------ */
.mask {
  display: block;
  overflow: clip;
}

.mask > * {
  display: block;
}

.char {
  display: inline-block;
  transform-origin: 0% 100%; /* char reveals pivot from their baseline */
}

.word {
  display: inline-block;
}

/* Inline word clip — padding keeps descenders inside, margin restores rhythm */
.word-mask {
  display: inline-block;
  overflow: clip;
  padding-bottom: 0.12em;
  margin-bottom: -0.12em;
}

/* ==========================================================================
   REVEAL SYSTEM — Phase 1: CSS transitions driven by js/core/reveal.js.
   Phase 2 hands these presets to Anime.js. Elements are ONLY hidden when
   JS is running (html.js) — content is always visible for crawlers / no-JS.
   ========================================================================== */
/* Resting (hidden) state only — Anime.js owns the movement from here on,
   so there is no CSS transition to fight it. */
.js [data-animate],
.js [data-animate-group] > * {
  opacity: 0;
  transform: translateY(20px); /* SHIFT.rise */
}

.js [data-animate="fade"] {
  transform: none;
}

.js [data-animate="scale-in"] {
  transform: scale(0.95);
}

.js [data-animate].in-view,
.js [data-animate-group].in-view > * {
  opacity: 1;
  transform: none;
}

/* ---- Reduced motion: everything visible, nothing moves ------------------ */
@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 [data-animate],
  .js [data-animate-group] > * {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
