/* ==========================================================================
   ANTIHORIZN: brand layer
   Loaded after site.css on every page. The pieces every page shares that are
   about how the brand moves, not how a page is laid out.

   B1  Night scope        any block can be dark: class="night" data-nav-dark
   B2  Horizon            the scroll line under the bar
   B3  Rise               a headline that comes up from behind its own baseline
   B4  Type               a line that types itself (data-type), with a caret
   B5  Marquee            one line of very large type, moving
   B6  Grain              film grain over a dark block
   B7  Theatre            the full-window player for a film or a YouTube video
   B8  Play disc          the round play control used over a still
   B9  Reduced motion

   Colour is ink, paper and one grey. There is no accent hue. "Hot" is paper
   on a dark ground and ink on a light one (see site.css).
   ========================================================================== */

/* --- B1. Night scope ----------------------------------------------------- */

:root {
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --night:       #0B0B0C;
  --night-2:     #111112;
  --night-3:     #18181A;
  --line-night:  rgba(244, 244, 245, 0.12);
  --line-night-2: rgba(244, 244, 245, 0.2);
  --on-dark-soft: rgba(244, 244, 245, 0.76);
  --dim:         rgba(244, 244, 245, 0.56);
  --dimmer:      rgba(244, 244, 245, 0.4);
}

.night { background: var(--night); color: var(--on-dark); }
.night .label { color: var(--dim); }
.night .lede { color: var(--on-dark-soft); }
.night .prose { color: var(--on-dark-soft); }
.night .sec-head { border-color: var(--line-night); }
.night .sec-head__n { color: var(--dim); }
.night ::selection { background: var(--hot); color: var(--on-hot); }
.night :focus-visible { outline-color: var(--hot); }
.night .btn { border-color: var(--line-night-2); color: var(--on-dark); }
.night .btn--solid, .night .btn--light { border-color: var(--hot); color: var(--on-hot); }
.night + .foot { border-top: 1px solid var(--line-night); }

.fine { font-size: 12px; line-height: 1.45; letter-spacing: 0; color: var(--ink-mute); }
.night .fine { color: var(--dim); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- B1b. The bar over a dark ground ------------------------------------ */
/* The bar is the shared one. Over a dark section it only changes colour:
   the links are the dark-ground equivalent of ink-soft and hover to full. */

.nav[data-tone="dark"] {
  background: rgba(11, 11, 12, 0.78);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom-color: var(--line-night);
  color: var(--on-dark);
}
.nav[data-tone="dark"][data-scrolled="false"] {
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom-color: transparent;
}
.nav[data-tone="dark"] .slink { color: rgba(244, 244, 245, 0.78); }
.nav[data-tone="dark"] .slink:focus-visible,
.nav[data-tone="dark"] .slink[aria-current="page"] { color: var(--on-dark); }
.nav[data-tone="dark"] .btn--ghost { border-color: var(--line-night-2); color: var(--on-dark); }
.nav[data-tone="dark"] .btn--solid { border-color: var(--hot); }
.nav[data-tone="dark"] .nav__burger span { background: var(--on-dark); }
@media (hover: hover) and (pointer: fine) {
  .nav[data-tone="dark"] .slink:hover { color: var(--on-dark); }
  .nav[data-tone="dark"] .btn--ghost:hover { border-color: var(--on-dark); color: var(--on-dark); }
  .nav[data-tone="dark"] .btn--solid:hover { background: transparent; color: var(--hot); border-color: var(--hot); }
}

/* --- B2. Horizon --------------------------------------------------------- */
/* The mark is a peak over a line. The line is the page's progress: it runs
   along the bottom edge of the bar and fills as the page is read. */

.horizon {
  position: fixed;
  inset: calc(var(--nav-h) - 1px) 0 auto 0;
  z-index: 101;
  height: 2px;
  pointer-events: none;
  background: var(--ink);
  transform: scaleX(var(--read, 0));
  transform-origin: left;
}
.nav[data-tone="dark"] ~ .horizon { background: #FFFFFF; }

/* --- B3. Rise ------------------------------------------------------------ */

/* Only when scripts run (html.js is set in each page's head): without them
   the headline is simply there. */
.js [data-rise] {
  clip-path: inset(-0.1em -0.1em 100% -0.1em);
  transform: translateY(0.42em);
  transition: clip-path 1100ms var(--ease-out), transform 1100ms var(--ease-out);
  transition-delay: calc(var(--i, 0) * 90ms);
}
.js [data-rise].is-in { clip-path: inset(-0.1em -0.1em -0.2em -0.1em); transform: none; }

/* --- B4. Type ------------------------------------------------------------ */
/* brand.js writes the characters. The element keeps its full height from the
   first frame (the untyped part is there, transparent), so nothing below it
   moves while it types. */

[data-type] .ty-off { color: transparent; }
[data-type] .ty-caret {
  display: inline-block;
  width: 0.06em; min-width: 2px; height: 0.92em;
  margin-left: 0.04em;
  vertical-align: -0.08em;
  background: currentColor;
  animation: tyBlink 900ms steps(1) infinite;
}
[data-type][data-typed="done"] .ty-caret { animation-iteration-count: 3; animation-fill-mode: forwards; }
@keyframes tyBlink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
[data-type] strong { font-weight: 800; letter-spacing: -0.02em; }

/* --- B5. Marquee --------------------------------------------------------- */

.marquee {
  overflow: hidden;
  white-space: nowrap;
  border-block: 1px solid var(--rule);
  padding-block: clamp(18px, 2.6vh, 34px);
  user-select: none;
}
.night .marquee, .marquee.night { border-color: var(--line-night); }
.marquee__run {
  display: inline-flex;
  align-items: center;
  gap: clamp(28px, 3.4vw, 64px);
  padding-right: clamp(28px, 3.4vw, 64px);
  animation: marquee var(--marquee-s, 38s) linear infinite;
  will-change: transform;
}
.marquee__run > span {
  font-family: var(--display);
  font-size: clamp(44px, 7.2vw, 124px);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.035em;
}
/* Every other phrase is drawn as an outline: the same letters, hollow. */
.marquee__run > span:nth-of-type(even) {
  color: transparent;
  -webkit-text-stroke: 1.5px currentColor;
  -webkit-text-stroke-color: var(--mq-stroke, var(--ink));
}
.night .marquee__run > span:nth-of-type(even), .marquee.night .marquee__run > span:nth-of-type(even) { --mq-stroke: rgba(244, 244, 245, 0.7); }
.marquee__run > svg { flex: none; width: clamp(34px, 4.4vw, 76px); height: auto; }
@keyframes marquee { to { transform: translateX(-50%); } }
@media (hover: hover) and (pointer: fine) {
  .marquee:hover .marquee__run { animation-play-state: paused; }
}

/* --- B6. Grain ----------------------------------------------------------- */

.grain { position: relative; isolation: isolate; }
.grain::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.11;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
.grain > * { position: relative; z-index: 2; }

/* --- B7. Theatre --------------------------------------------------------- */
/* One player for the whole site. brand.js builds it on first use:
   AH.theatre.open({ yt: 'VIDEO_ID', title, credit, href })   a YouTube video
   AH.theatre.open({ src: 'assets/video/x.mp4', poster, title })   our own film
   Any element with data-theatre-yt or data-theatre-src opens it on click. */

.theatre {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(5, 5, 6, 0.96);
  color: #F4F4F5;
  --hot: #FFFFFF;
  --on-hot: #0B0B0C;
  opacity: 0;
  visibility: hidden;
  transition: opacity 320ms var(--ease-out), visibility 0s linear 320ms;
}
.theatre[data-open="true"] { opacity: 1; visibility: visible; transition-delay: 0s; }
.theatre__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px var(--gutter);
  min-height: var(--nav-h);
}
.theatre__title { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theatre__close {
  flex: none;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border: 1.5px solid rgba(244, 244, 245, 0.28);
  font-size: 14px; font-weight: 600; line-height: 1;
  color: #F4F4F5;
  transition: border-color 180ms var(--ease), background-color 180ms var(--ease), color 180ms var(--ease);
}
.theatre__close kbd { font-size: 11px; opacity: 0.6; }
@media (hover: hover) and (pointer: fine) {
  .theatre__close:hover { background: #FFFFFF; border-color: #FFFFFF; color: #0B0B0C; }
}
.theatre__stage {
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 0 var(--gutter);
}
.theatre__frame {
  width: min(100%, calc((100vh - 190px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: #000;
  transform: scale(0.965);
  transition: transform 520ms var(--ease-out);
}
.theatre[data-open="true"] .theatre__frame { transform: none; }
.theatre__frame iframe, .theatre__frame video { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.theatre__foot {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 16px var(--gutter) 22px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(244, 244, 245, 0.56);
}
.theatre__foot a { color: #F4F4F5; border-bottom: 1px solid rgba(244, 244, 245, 0.4); }

/* --- B8. Play disc ------------------------------------------------------- */

.playdisc {
  display: inline-grid;
  place-items: center;
  width: clamp(64px, 6.4vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #FFFFFF;
  color: #0B0B0C;
  transition: transform 420ms var(--ease-out);
}
.playdisc::before {
  content: "";
  width: 0; height: 0;
  margin-left: 6%;
  border-left: clamp(16px, 1.6vw, 26px) solid currentColor;
  border-block: clamp(10px, 1vw, 16px) solid transparent;
}
@media (hover: hover) and (pointer: fine) {
  a:hover > .playdisc, button:hover > .playdisc, .playdisc:hover { transform: scale(1.08); }
}

/* --- B9. Reduced motion -------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .js [data-rise], .js [data-rise].is-in { clip-path: none; transform: none; transition: none; }
  .marquee__run { animation: none; }
  [data-type] .ty-caret { display: none; }
  [data-type] .ty-off { color: inherit; }
  .theatre, .theatre__frame { transition: none; }
  .horizon { display: none; }
}
