/* ==========================================================================
   chrome — preloader, cursor, topbar, fullscreen menu
   Everything that floats above the document.
   ========================================================================== */

/* ── preloader ─────────────────────────────────────────────────────────── */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: end stretch;
  background: var(--ground);
  padding: var(--gut);
}

.preloader__inner {
  display: grid;
  gap: clamp(1.5rem, 4vh, 3rem);
  width: 100%;
}

.preloader__wordmark {
  font-family: var(--f-display);
  font-size: clamp(3rem, 13vw, 11rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  display: flex;
}

.preloader__wordmark span {
  display: inline-block;
  transform: translateY(110%);
  opacity: 0;
}

.preloader__meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2rem;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
}

.preloader__count {
  font-size: clamp(1rem, 2.2vw, 1.6rem);
  color: var(--fg);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.preloader__rail {
  height: 1px;
  background: var(--line);
  overflow: hidden;
}

.preloader__rail i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--signal);
  transform: scaleX(0);
  transform-origin: left;
}

/* The curtain wipes UP off the top, revealing the hero already in motion. */
.preloader__curtain {
  position: fixed;
  inset: 0;
  background: var(--ground);
  transform-origin: top;
  pointer-events: none;
}

/* ── custom cursor ─────────────────────────────────────────────────────── */

/* The ring is a fixed-size box that GSAP writes x/y to every frame; the visible
   circle is an inner element that only ever scales. Transitioning the ring's own
   width/height/margin would invalidate layout on the same element being
   transformed per frame — cheap in isolation, wasteful in that combination. */
.cursor {
  position: fixed;
  top: 0; left: 0;
  z-index: 350;
  pointer-events: none;
  mix-blend-mode: difference;

  --ring-scale: 0.365;
  --ring-line: rgba(250, 247, 242, 0.55);
  --ring-fill: transparent;
}

.cursor__dot,
.cursor__ring {
  position: absolute;
  top: 0; left: 0;
  border-radius: 50%;
  will-change: transform;
}

.cursor__dot {
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  background: var(--paper);
}

/* Sized to the largest state; every smaller state is a scale-down. */
.cursor__ring {
  width: 104px; height: 104px;
  margin: -52px 0 0 -52px;
  display: grid;
  place-items: center;
}

.cursor__shape {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  /* Scales with the shape: ~1px at rest, ~1.7px on links, and invisible under
     the filled card state — so the stroke never needs its own animation. */
  border: 2.75px solid var(--ring-line);
  background: var(--ring-fill);
  transform: scale(var(--ring-scale));
  transition: transform 0.45s var(--ease), background-color 0.45s var(--ease),
              border-color 0.45s var(--ease);
}

.cursor__label {
  font-family: var(--f-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s var(--ease), transform 0.45s var(--ease);
}

.cursor.is-link {
  --ring-scale: 0.615;
  --ring-line: rgba(250, 247, 242, 0.9);
}

.cursor.is-card {
  --ring-scale: 1;
  --ring-line: var(--paper);
  --ring-fill: var(--paper);
}

.cursor.is-card .cursor__label { opacity: 1; transform: scale(1); }
.cursor.is-card .cursor__dot,
.cursor.is-link .cursor__dot { opacity: 0; }

.cursor__dot { transition: opacity 0.3s var(--ease); }

@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
}

/* ── topbar ────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: clamp(1rem, 2.6vh, 1.9rem) var(--gut);
  mix-blend-mode: difference;
}

.topbar__mark {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--paper);
}

.topbar__markDot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--signal);
  transition: transform 0.5s var(--ease);
}

.topbar__mark:hover .topbar__markDot { transform: scale(2.2); }

.topbar__centre {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 0.75em;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(250, 247, 242, 0.55);
}

.topbar__ring {
  width: 20px; height: 20px;
  transform: rotate(-90deg);
  overflow: visible;
}

.topbar__ringTrack,
.topbar__ringFill {
  fill: none;
  stroke-width: 2.5;
}

.topbar__ringTrack { stroke: rgba(250, 247, 242, 0.2); }

.topbar__ringFill {
  stroke: var(--signal);
  stroke-dasharray: 97.4;
  stroke-dashoffset: 97.4;
  stroke-linecap: round;
}

@media (max-width: 720px) {
  .topbar__section { display: none; }
}

/* ── menu button ───────────────────────────────────────────────────────── */

.menubtn {
  justify-self: end;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.75em 1.35em;
  border: 1px solid rgba(250, 247, 242, 0.28);
  border-radius: 100px;
  overflow: hidden;
  isolation: isolate;
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--paper);
}

.menubtn__fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--paper);
  transform: translateY(101%);
  transition: transform 0.55s var(--ease);
}

.menubtn:hover .menubtn__fill { transform: translateY(0); }
.menubtn:hover { color: var(--ink); }

/* The mask height must clear the font's full line box, not just 1em, or the
   label loses its descenders and reads as a different word. */
.menubtn__text {
  position: relative;
  display: block;
  height: 1.35em;
  line-height: 1.35;
  overflow: hidden;
  /* The box is sized by "menu"; without a floor the longer "close" label is
     clipped to "clos" when the button flips state. */
  min-width: 5.4ch;
}

.menubtn__text i {
  display: block;
  font-style: normal;
  line-height: 1.35;
  transition: transform 0.5s var(--ease);
}

/* The second label is parked one line below and slides up on open. It must be
   at top:100%, not top:0 — at 0 both words render on top of each other. */
.menubtn__text i:last-child { position: absolute; top: 100%; left: 0; }

body.menu-open .menubtn__text i { transform: translateY(-100%); }

.menubtn__bars {
  display: grid;
  gap: 4px;
  width: 15px;
}

.menubtn__bars b {
  display: block;
  height: 1px;
  background: currentColor;
  transition: transform 0.5s var(--ease);
}

body.menu-open .menubtn__bars b:first-child { transform: translateY(2.5px) rotate(45deg); }
body.menu-open .menubtn__bars b:last-child  { transform: translateY(-2.5px) rotate(-45deg); }

/* ── fullscreen menu ───────────────────────────────────────────────────── */

.menu {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: grid;
  grid-template-rows: 1fr auto;
  align-content: center;
  padding: clamp(6rem, 16vh, 10rem) var(--gut) var(--gut);
  background: var(--house-1);
  /* Opens from the menu button in the top-right. Percentages only — GSAP
     interpolates those reliably; calc() inside circle() it does not. */
  clip-path: circle(0% at 92% 4%);
  visibility: hidden;
}

body.menu-open .menu { visibility: visible; }

.menu__media {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.menu__video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  transform: scale(1.08);
  filter: saturate(0.5) contrast(1.1) brightness(0.55);
  transition: opacity 0.8s var(--ease), transform 1.6s var(--ease);
}

.menu__video.is-active { opacity: 0.34; transform: scale(1); }

.menu__list {
  position: relative;
  z-index: 1;
  list-style: none;
  padding: 0;
  align-self: center;
}

.menu__item { overflow: hidden; }

.menu__item a {
  display: flex;
  align-items: baseline;
  gap: clamp(1rem, 3vw, 3rem);
  padding: clamp(0.15rem, 0.8vh, 0.5rem) 0;
  font-family: var(--f-display);
  font-size: clamp(2.4rem, 8.5vw, 8rem);
  line-height: 1.02;
  letter-spacing: -0.025em;
  color: var(--fg-2);
  transform: translateY(110%);
  transition: color 0.5s var(--ease);
}

.menu__item a em {
  font-family: var(--f-mono);
  font-style: normal;
  font-size: var(--t-meta);
  letter-spacing: 0.2em;
  color: var(--fg-4);
  transition: color 0.5s var(--ease);
}

.menu__word {
  display: inline-block;
  transition: transform 0.6s var(--ease), font-style 0s;
}

.menu__item a:hover { color: var(--paper); }
.menu__item a:hover em { color: var(--signal); }
.menu__item a:hover .menu__word { transform: translateX(clamp(0.6rem, 2vw, 2.2rem)); font-style: italic; }

.menu__foot {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
  padding-top: clamp(1.5rem, 4vh, 3rem);
  border-top: 1px solid var(--line);
  font-family: var(--f-mono);
  font-size: var(--t-meta);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0;
}

.menu__col { display: grid; gap: 0.5em; }
.menu__k { color: var(--fg-4); }
.menu__col a { color: var(--fg-2); transition: color 0.4s var(--ease); }
.menu__col a:hover { color: var(--signal); }
