/* Instrument Serif is self-hosted so the serif never falls back. */
@font-face {
  font-family: "Instrument Serif";
  src: url("assets/fonts/InstrumentSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Serif";
  src: url("assets/fonts/InstrumentSerif-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #0c0c0c;
  --fg: #ffffff;
  /* 48px top/bottom; 147px sides at 1440px, scaling with viewport width */
  --pad-y: 48px;
  --pad-x: calc(147 / 1440 * 100vw);
  --nav-gap: 20px;
  --logo-w: calc(672 / 1440 * 100vw);
  --ease: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --cream: #f1ede6;
  --ink: #161412;
}

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

html { scroll-behavior: smooth; }

body { margin: 0; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700;
  font-size: 12px;
  line-height: 1.25;
  text-transform: uppercase;
  -webkit-font-smoothing: antialiased;
}

/* No scrolling while the preloader or the mobile menu is up. */
.js:not(.is-loaded),
.js:not(.is-loaded) body,
body.menu-open { overflow: hidden; }

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

/* ---------- Background video ---------- */

.bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: -1;
}

.bg__video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The video itself must stay visible: mobile browsers refuse to autoplay
   a video with opacity 0. Fade a solid cover off it instead. */
.bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--bg);
  transition: opacity 1.2s ease;
}

.bg.is-playing::after { opacity: 0; }

.bg__shade {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

/* ---------- Hero layout ---------- */

/* Fixed header: white over the hero, ink once the cream section
   reaches it (JS toggles .is-dark). */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: var(--pad-y) var(--pad-x) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--fg);
  pointer-events: none;
  transition: color 0.4s ease;
}

.site-header.is-dark { color: var(--ink); }
.menu-open .site-header { color: var(--fg); }

.site-header > * { pointer-events: auto; }

/* The hero stays pinned while the about section slides up over it. */
.hero {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  padding: calc(var(--pad-y) + 15px) var(--pad-x) var(--pad-y);
  display: grid;
  grid-template-rows: 1fr auto;
  transform: scale(calc(1 - var(--p, 0) * 0.06));
  opacity: calc(1 - var(--p, 0) * 0.8);
}

.nav {
  display: flex;
  gap: var(--nav-gap);
}

.hero__logo {
  margin: 0;
  display: grid;
  place-items: center;
  min-height: 0;
}

.hero__logo img {
  display: block;
  width: min(var(--logo-w), calc((100svh - 2 * var(--pad-y) - 120px) * 672 / 351));
  max-width: 100%;
  height: auto;
  opacity: 0.75;
}

.hero__bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
}

.tagline {
  margin: 0;
  text-align: center;
}

.mail { justify-self: end; }

/* Hover: a hairline draws in from the left, then leaves to the right. */
.link {
  position: relative;
  display: inline-block;
}

.link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.5s var(--ease);
}

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

.menu a { transition: opacity 0.2s ease; }

.burger,
.menu { display: none; }

/* ---------- Preloader ---------- */

.preloader { display: none; }

.js .preloader {
  display: block;
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.preloader__bg {
  position: absolute;
  inset: 0;
  background: var(--bg);
  transition: opacity 0.9s var(--ease);
}

/* Same size as the hero logo, centred in the viewport; JS slides it into place. */
.preloader__logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(var(--logo-w), calc((100svh - 2 * var(--pad-y) - 120px) * 672 / 351));
  max-width: calc(100vw - 2 * var(--pad-x));
  height: auto;
  opacity: 0.75;
  overflow: visible;
  transform: translate(-50%, -50%);
  transform-origin: 0 0;
}

.preloader__logo path {
  fill: var(--fg);
  fill-opacity: 0;
  stroke: var(--fg);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation:
    logo-draw 1.6s var(--ease) calc(var(--i) * 0.12s) forwards,
    logo-fill 0.8s ease calc(1.2s + var(--i) * 0.08s) forwards;
}

@keyframes logo-draw { to { stroke-dashoffset: 0; } }
@keyframes logo-fill { to { fill-opacity: 1; stroke-opacity: 0; } }

.preloader__count {
  position: absolute;
  right: var(--pad-x);
  bottom: var(--pad-y);
  font-variant-numeric: tabular-nums;
  transition: opacity 0.4s ease;
}

.preloader.is-leaving .preloader__bg,
.preloader.is-leaving .preloader__count { opacity: 0; }

/* Hero waits behind the preloader, then settles in. */
.js .hero__logo img { visibility: hidden; }
.js.is-loaded .hero__logo img { visibility: visible; }

.js .site-header,
.js .hero__bottom {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.8s ease, transform 0.8s var(--ease);
}

.js.is-loaded .site-header,
.js.is-loaded .hero__bottom {
  opacity: 1;
  transform: none;
}

.js.is-loaded .hero__bottom { transition-delay: 0.12s; }

/* ---------- About ---------- */

.about {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 140px var(--pad-x) 120px;
  background: var(--cream);
  color: var(--ink);
  isolation: isolate;
}

/* Paper grain */
.about::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .25 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.35;
  pointer-events: none;
}

.about__inner {
  width: max(400px, calc(400 / 1440 * 100vw));
  max-width: 100%;
  margin: 0 auto;
}

.about__title {
  margin: 0 0 40px;
  display: flex;
  justify-content: center;
  gap: 0.22em;
  font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
  font-weight: 400;
  font-size: max(76px, calc(136 / 1440 * 100vw));
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: none;
}

/* Each word rises out of a mask that clips only its bottom edge. */
.about__title .word {
  display: block;
  flex-shrink: 0;
  padding-bottom: 0.12em;
  clip-path: inset(-50% -20% 0 -20%);
}

.about__title .word > span { display: block; }

.about__media {
  margin: 0;
  aspect-ratio: 1400 / 812;
  overflow: hidden;
  border-radius: 6px;
  background: #d9d3c9;
}

.about__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.about__sig {
  display: block;
  width: 112px;
  height: auto;
  margin: 28px 0 36px;
  overflow: visible;
  color: var(--ink);
}

.about__sig path { fill: currentColor; }

.about__text p {
  margin: 0 0 14px;
  line-height: 1.4;
  letter-spacing: -0.01em;
}

.about__links {
  display: flex;
  justify-content: space-between;
  margin-top: 40px;
}

/* ----- Scroll reveals (only when JS can undo them) ----- */

.js .about__title .word > span {
  transform: translateY(105%);
  transition: transform 1.1s var(--ease-out);
}

.js .about__title .word:nth-child(2) > span { transition-delay: 0.08s; }

.js .about__title.is-in .word > span { transform: none; }

.js .about__media {
  clip-path: inset(100% 0 0 0 round 6px);
  transition: clip-path 1.3s var(--ease);
}

.js .about__media img {
  transform: scale(1.25);
  transition: transform 1.8s var(--ease-out);
}

.js .about__media.is-in { clip-path: inset(0 0 0 0 round 6px); }
.js .about__media.is-in img { transform: scale(1); }

/* "made with passion" writes itself, letter by letter, left to right. */
.js .about__sig path {
  clip-path: inset(-20% 100% -20% -20%);
  transition: clip-path 0.42s cubic-bezier(0.55, 0.1, 0.45, 0.95);
  transition-delay: calc(0.5s + var(--i) * 0.11s);
}

.js .about__sig.is-in path { clip-path: inset(-20% -20% -20% -20%); }

.js .about__text p,
.js .about__links {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 1s ease, transform 1.2s var(--ease-out);
}

.js .about__text p:nth-child(2) { transition-delay: 0.1s; }
.js .about__text p:nth-child(3) { transition-delay: 0.2s; }

.js .about__text.is-in p,
.js .about__links.is-in {
  opacity: 1;
  transform: none;
}

/* ---------- Mobile ---------- */

@media (max-width: 767px) {
  :root {
    --pad-y: 32px;
    --pad-x: 20px;
  }

  .nav,
  .social,
  .mail { display: none; }

  .hero__bottom { grid-template-columns: 1fr; }

  .br-desktop { display: none; }

  .hero__logo img { width: 100%; }

  .preloader__logo { width: calc(100vw - 2 * var(--pad-x)); }

  .about { padding-top: 112px; padding-bottom: 72px; }
  .about__inner { width: 100%; }
  .about__title { margin-bottom: 28px; }

  /* ----- Hamburger: two lines that cross into an X ----- */

  .burger {
    display: block;
    width: 28px;
    height: 20px;
    padding: 0;
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    position: relative;
    -webkit-tap-highlight-color: transparent;
  }

  .burger span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    transition:
      top 0.3s var(--ease) 0.3s,
      width 0.3s var(--ease) 0.3s,
      transform 0.3s var(--ease);
  }

  .burger span:first-child { top: 5px; }
  .burger span:last-child { top: 13px; width: 65%; left: auto; right: 0; }

  .menu-open .burger span {
    top: 9px;
    width: 100%;
    transition:
      top 0.3s var(--ease),
      width 0.3s var(--ease),
      transform 0.3s var(--ease) 0.3s;
  }

  .menu-open .burger span:first-child { transform: rotate(45deg); }
  .menu-open .burger span:last-child { transform: rotate(-45deg); }

  /* ----- Menu panel: wipes down from the top ----- */

  .menu {
    position: fixed;
    inset: 0;
    z-index: 4;
    display: grid;
    place-items: center;
    background: rgba(12, 12, 12, 0.94);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition:
      clip-path 0.7s var(--ease) 0.25s,
      visibility 0s linear 0.95s;
  }

  .menu-open .menu {
    clip-path: inset(0 0 0 0);
    visibility: visible;
    transition:
      clip-path 0.7s var(--ease),
      visibility 0s;
  }

  /* ----- Menu links: each line rises out of a mask, staggered ----- */

  .menu__links {
    display: grid;
    gap: 12px;
    text-align: center;
    font-family: "Instrument Serif", Georgia, "Times New Roman", serif;
    font-weight: 400;
    font-size: 44px;
    line-height: 1.05;
  }

  .menu__links a {
    display: block;
    overflow: hidden;
    padding: 0 4px 2px;
  }

  .menu__links span {
    display: block;
    transform: translateY(110%) rotate(4deg);
    transform-origin: left bottom;
    transition: transform 0.35s var(--ease) calc((3 - var(--i)) * 0.04s);
  }

  .menu-open .menu__links span {
    transform: none;
    transition: transform 0.8s var(--ease) calc(0.3s + var(--i) * 0.08s);
  }

  .menu__links a:hover { opacity: 1; }
  .menu__links a:hover span,
  .menu__links a:focus-visible span { font-style: italic; }

  /* ----- Page content steps back while the menu is open ----- */

  .hero__logo,
  .hero__bottom {
    transition: opacity 0.5s var(--ease), transform 0.7s var(--ease), filter 0.5s var(--ease);
  }

  .menu-open .hero__logo,
  .menu-open .hero__bottom {
    opacity: 0;
    transform: scale(0.96);
    filter: blur(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }

  .js .about__sig path { clip-path: none; }

  .preloader__logo path {
    animation: none;
    fill-opacity: 1;
    stroke: none;
  }
}
