/* ==========================================================================
   The Balance Theory — design system
   Editorial broadcast: warm paper, ink blocks, butter signature, B&W photography.
   ========================================================================== */

/* --- Brand faces --------------------------------------------------------- */
/* Licensed files, self-hosted and subset to Latin. Sofia Pro carries every
   running word; IvyPresto Display carries every headline, upright and italic. */

@font-face {
  font-family: "Sofia Pro";
  src: url("../fonts/sofia-pro-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IvyPresto Display";
  src: url("../fonts/ivypresto-display-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IvyPresto Display";
  src: url("../fonts/ivypresto-display-400-italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* --- Tokens ------------------------------------------------------------- */

:root {
  /* Palette */
  --ink: #16130f;
  --ink-70: rgba(22, 19, 15, 0.7);
  --ink-45: rgba(22, 19, 15, 0.45);
  --ink-15: rgba(22, 19, 15, 0.15);
  --ink-08: rgba(22, 19, 15, 0.08);
  --paper: #f4ede1;
  --paper-deep: #e9dfcd;
  --paper-05: rgba(244, 237, 225, 0.05);
  --paper-60: rgba(244, 237, 225, 0.6);
  --butter: #f2ee8b;
  --butter-deep: #ddd251;
  --periwinkle: #7899d4;
  /* Accent. Was clay (#b4502c); now the brand periwinkle. Name kept so
     every existing var(--clay) still resolves. */
  --clay: var(--periwinkle);

  /* Type */
  --display: "IvyPresto Display", Georgia, "Times New Roman", serif;
  --display-italic: "IvyPresto Display", Georgia, serif;
  --body: "Sofia Pro", "Helvetica Neue", Arial, sans-serif;
  /* Small uppercase labels: the body face, tracked out. */
  --label: var(--body);

  /* Page-title size. A token so layout can allow for its descenders
     (see .hero__film in pages.css). */
  --h1-size: clamp(3rem, 1.2rem + 8.4vw, 8.5rem);

  /* Rhythm */
  --gutter: clamp(1.25rem, 5vw, 5rem);
  --section-y: clamp(4.5rem, 11vw, 9.5rem);
  --max: 82rem;

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-glide: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 0.6s;
}

/* --- Reset -------------------------------------------------------------- */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: clamp(1.0625rem, 1.02rem + 0.2vw, 1.125rem);
  line-height: 1.58;
  /* Only one Sofia weight is licensed: never let the browser fake the rest. */
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

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

img { height: auto; }

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

a { color: inherit; }

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

::selection {
  background: var(--butter);
  color: var(--ink);
}

/* --- Texture ------------------------------------------------------------ */

/* Fine paper grain over the whole page, drifting slowly so flat fills breathe. */
body::before {
  content: "";
  position: fixed;
  inset: -50%;
  z-index: 9000;
  pointer-events: none;
  opacity: 0.32;
  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.82' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  animation: grain 6s steps(6) infinite;
  mix-blend-mode: multiply;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-3%, 2%); }
  40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -2%); }
  80% { transform: translate(3%, 3%); }
}

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

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

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

.section--ink {
  background: var(--ink);
  color: var(--paper);
}

.section--ink ::selection {
  background: var(--butter);
  color: var(--ink);
}

.rule {
  height: 1px;
  background: var(--ink-15);
  border: 0;
}

/* --- Typography --------------------------------------------------------- */

.kicker {
  font-family: var(--label);
  font-size: clamp(0.5625rem, 0.5rem + 0.2vw, 0.6875rem);
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 0.75em;
}

.kicker::before {
  content: "";
  width: 1.75em;
  height: 1px;
  background: currentColor;
  opacity: 0.5;
  flex: none;
}

.kicker--plain::before { display: none; }

.display {
  font-family: var(--display);
  font-weight: 400;
  line-height: 0.94;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.display em {
  font-family: var(--display-italic);
  font-style: italic;
  letter-spacing: -0.005em;
}

h1.display { font-size: var(--h1-size); }
h2.display { font-size: clamp(2.25rem, 1.3rem + 4.4vw, 5rem); }
h3.display { font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem); }

.lede {
  font-size: clamp(1.0625rem, 1rem + 0.55vw, 1.4375rem);
  line-height: 1.5;
  color: var(--ink-70);
  max-width: 46ch;
  text-wrap: pretty;
}

.section--ink .lede { color: var(--paper-60); }

.mark {
  /* Butter highlight that sweeps in when the line scrolls into view. */
  background-image: linear-gradient(var(--butter), var(--butter));
  background-repeat: no-repeat;
  background-position: 0 88%;
  background-size: 0% 0.42em;
  padding-inline: 0.06em;
  transition: background-size 0.9s var(--ease) 0.15s;
}

.is-revealed .mark,
.mark.is-revealed { background-size: 100% 0.42em; }

/* On dark sections the site marks emphasis with butter type — the stat
   numbers, quote credits and guest names all do — because a butter band only
   covers the lower part of the letters, and no text colour reads on both the
   band and the dark above it. So here the mark colours in instead. */
.section--ink .mark {
  background-image: none;
  padding-inline: 0;
  transition: color 0.8s var(--ease) 0.2s;
}

.section--ink .is-revealed .mark,
.section--ink .mark.is-revealed { color: var(--butter); }

/* --- Buttons ------------------------------------------------------------ */

.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--paper);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  padding: 0.95em 1.6em;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-family: var(--label);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}

/* Butter fill wipes up from the base on hover. */
.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--butter);
  transform: translateY(101%);
  transition: transform 0.45s var(--ease);
}

.btn:hover::after,
.btn:focus-visible::after { transform: translateY(0); }

.btn:hover,
.btn:focus-visible { color: var(--ink); }

.btn__arrow { transition: transform 0.45s var(--ease); }
.btn:hover .btn__arrow { transform: translateX(0.28em); }

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
}

.section--ink .btn--ghost {
  --btn-fg: var(--paper);
  border-color: rgba(244, 237, 225, 0.35);
}

.btn--butter {
  --btn-bg: var(--butter);
  --btn-fg: var(--ink);
  border-color: var(--ink);
}

.btn--butter::after { background: var(--ink); }
.btn--butter:hover,
.btn--butter:focus-visible { color: var(--paper); }

.btn--lg { padding: 1.15em 2em; font-size: 0.75rem; }

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn:disabled::after { transform: translateY(101%); }

/* Underline link that draws left-to-right. */
.link {
  position: relative;
  text-decoration: none;
  padding-bottom: 0.1em;
}

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

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

/* --- Scroll progress ---------------------------------------------------- */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 100%;
  z-index: 900;
  background: var(--butter);
  transform: scaleX(var(--scroll, 0));
  transform-origin: left;
  pointer-events: none;
}

/* --- Header ------------------------------------------------------------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 800;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition:
    transform 0.6s var(--ease-glide),
    border-color 0.4s var(--ease),
    background 0.4s var(--ease);
}

.masthead.is-stuck { border-bottom-color: var(--ink-15); }

/* See-through at the very top, so a page's glow can run up behind the menu;
   it frosts over as soon as the page scrolls. */
.masthead:not(.is-stuck) {
  background: transparent;
  backdrop-filter: none;
}

/* Slides away while reading down, returns on the first move back up.
   Keyboard focus inside always brings it back so tabbing never lands
   on an off-screen link. */
.masthead.is-hidden { transform: translateY(-100%); }
.masthead.is-hidden:has(:focus-visible) { transform: none; }

.masthead__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.5rem;
}

.wordmark {
  display: block;
  flex-shrink: 0;
  line-height: 0;
}

/* The brand logo stacks three lines, so it needs more height than a
   single-line wordmark to stay legible; 3rem still sits inside the bar. */
.wordmark img {
  display: block;
  width: auto;
  height: 3rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.2vw, 2.1rem);
}

.nav a {
  font-family: var(--label);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.nav a[aria-current="page"],
.nav__group:has([aria-current="page"]) .nav__trigger { color: var(--clay); }

/* Podcast opens a small menu on hover, and on keyboard focus so tabbing
   reaches the links inside. */
.nav__group { position: relative; }

/* Block, like the other links (flex items are blockified). Left inline, it
   sits on the group's body-size line box and drops below the others. */
.nav__trigger { display: block; }

.nav__trigger::after {
  content: "";
  display: inline-block;
  width: 0.3rem;
  height: 0.3rem;
  margin-left: 0.45rem;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: translateY(-0.2em) rotate(45deg);
  transition: transform 0.3s var(--ease);
}

.nav__group:hover .nav__trigger::after,
.nav__group:focus-within .nav__trigger::after { transform: translateY(0) rotate(225deg); }

.nav__sub {
  position: absolute;
  top: calc(100% + 0.9rem);
  left: -1.1rem;
  display: grid;
  min-width: max-content;
  padding-block: 0.5rem;
  background: var(--paper);
  border: 1px solid var(--ink-15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-0.35rem);
  transition:
    opacity 0.3s var(--ease),
    transform 0.3s var(--ease),
    visibility 0s linear 0.3s;
}

/* Bridges the gap under the trigger so the menu stays open on the way down. */
.nav__sub::before {
  content: "";
  position: absolute;
  inset: auto 0 100%;
  height: 0.9rem;
}

.nav__group:hover .nav__sub,
.nav__group:focus-within .nav__sub {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.nav__sub a {
  display: block;
  padding: 0.6rem 1.1rem;
}

/* Hover sweeps in the butter band from the hero's .mark under the label;
   pressing fills it to full height. Desktop only: the phone menu has no
   hover. The content box bounds the band, so padding stays clear. */
@media (min-width: 861px) {
  .nav a {
    background-image: linear-gradient(var(--butter), var(--butter));
    background-repeat: no-repeat;
    background-origin: content-box;
    background-clip: content-box;
    background-position: 0 88%;
    background-size: 0% 0.42em;
    transition: background-size 0.5s var(--ease), transform 0.2s var(--ease);
  }

  .nav a:hover,
  .nav a:focus-visible,
  .nav__group:hover .nav__trigger { background-size: 100% 0.42em; }

  .nav a:active {
    background-size: 100% 100%;
    transform: translateY(1px);
    transition-duration: 0.15s;
  }

  /* Each menu link only as wide as its label, so the band matches it. */
  .nav__sub a { justify-self: start; }
}

.nav-toggle {
  display: none;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--ink-15);
  border-radius: 999px;
  background: none;
  cursor: pointer;
  padding: 0;
  /* place-content packs the three bars together in the middle; without it
     the grid rows stretch them across the whole button, so the close X
     came out lopsided. */
  place-content: center;
  place-items: center;
}

.nav-toggle span {
  display: block;
  width: 1.1rem;
  height: 1px;
  background: var(--ink);
}

.nav-toggle span + span { margin-top: 5px; }

/* Lines to X: a straight swap, no animation in between. */

.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: grid; }

  .nav {
    position: fixed;
    /* The full height of the screen below the header, so the panel never
       ends partway down the page with content showing under it. Set as a
       height, not bottom: 0: once the page scrolls, the header's blur makes
       it the panel's containing block, and bottom: 0 would then mean the
       bottom of the 72px header and squash the panel to nothing. */
    inset: 4.5rem 0 auto;
    height: calc(100dvh - 4.5rem);
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 1.5rem var(--gutter) 2.5rem;
    background: var(--paper);
    border-bottom: 1px solid var(--ink-15);
    clip-path: inset(0 0 100% 0);
    transition: clip-path 0.55s var(--ease);
    /* Scrolls instead of running off a short screen (a phone on its side). */
    overflow-y: auto;
  }

  /* The page underneath stays put while the menu is open. */
  body:has(.nav[data-open="true"]) { overflow: hidden; }

  .nav[data-open="true"] { clip-path: inset(0 0 0 0); }

  .nav a {
    font-family: var(--display);
    font-size: 1.75rem;
    letter-spacing: -0.01em;
    text-transform: none;
    padding-block: 0.55rem;
    width: 100%;
    border-bottom: 1px solid var(--ink-08);
    /* The long item would run off a phone at this size. */
    white-space: normal;
  }

  /* No hover on a phone: the Podcast links sit open beneath it, indented. */
  .nav__group { width: 100%; }

  /* Podcast's two links stay folded under it until it's tapped (site.js
     sets data-open on the group); the arrow flips when they're open. */
  .nav__trigger::after {
    width: 0.32em;
    height: 0.32em;
    margin-left: 0.5em;
    border-width: 0 1.5px 1.5px 0;
    transform: translateY(-0.2em) rotate(45deg);
  }

  .nav__group:hover .nav__trigger::after,
  .nav__group:focus-within .nav__trigger::after { transform: translateY(-0.2em) rotate(45deg); }

  .nav__group[data-open="true"] .nav__trigger::after { transform: translateY(0.05em) rotate(225deg); }

  .nav__sub {
    display: none;
    position: static;
    min-width: 0;
    padding: 0 0 0 1.25rem;
    background: none;
    border: 0;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }

  .nav__group[data-open="true"] .nav__sub { display: grid; }

  .nav__sub::before { display: none; }

  .nav__sub a {
    font-size: 1.25rem;
    padding-block: 0.5rem;
    padding-inline: 0;
  }
}

/* --- On-air chip + waveform --------------------------------------------- */

.onair {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.85rem 0.4rem 0.7rem;
  border: 1px solid var(--ink-15);
  border-radius: 999px;
  font-family: var(--label);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
}

.section--ink .onair { border-color: rgba(244, 237, 225, 0.25); background: transparent; }

.wave {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 0.85rem;
}

.wave span {
  width: 2px;
  background: var(--clay);
  border-radius: 1px;
  transform-origin: bottom;
  animation: wave 1.1s var(--ease-in-out) infinite;
}

.wave span:nth-child(1) { height: 40%; animation-delay: -0.9s; }
.wave span:nth-child(2) { height: 75%; animation-delay: -0.5s; }
.wave span:nth-child(3) { height: 100%; animation-delay: -0.2s; }
.wave span:nth-child(4) { height: 60%; animation-delay: -0.7s; }
.wave span:nth-child(5) { height: 85%; animation-delay: -0.35s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.35); }
  50% { transform: scaleY(1); }
}

/* --- Marquee ------------------------------------------------------------ */

.marquee {
  --speed: 42s;
  display: flex;
  overflow: hidden;
  user-select: none;
  gap: 0;
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}

.marquee__track {
  display: flex;
  align-items: center;
  flex: none;
  width: max-content;
  gap: 0;
  animation: slide var(--speed) linear infinite;
}

.marquee--reverse .marquee__track { animation-direction: reverse; }

.marquee:hover .marquee__track { animation-play-state: paused; }

/* One track holding the content twice, travelling exactly half its own width.
   Two side-by-side tracks each running their own animation cannot stay in
   phase — the second starts fractionally later and the drift shows as a gap
   opening on the right — so the duplicate lives inside the animated element. */
@keyframes slide {
  to { transform: translateX(-50%); }
}

.marquee__item {
  display: inline-flex;
  align-items: center;
  gap: 1.6rem;
  padding-inline: 1.6rem;
  white-space: nowrap;
}

.marquee__star {
  color: var(--butter-deep);
  font-size: 0.8em;
}

/* Big typographic guest marquee. Aligning on the baseline puts the upright and
   italic names on one line of type. */
.marquee--names .marquee__track { align-items: baseline; }

.marquee--names .marquee__item {
  --size: clamp(2.25rem, 1rem + 5.5vw, 5.5rem);
  font-family: var(--display);
  font-size: var(--size);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.marquee--names .marquee__item:nth-child(even) {
  font-family: var(--display-italic);
  font-style: italic;
}

/* Small mono ticker */
.marquee--ticker {
  --speed: 34s;
  border-block: 1px solid;
  border-color: inherit;
  padding-block: 0.8rem;
}

.marquee--ticker .marquee__item {
  /* inline-block, not inline-flex: as a flex container every phrase and every
     separator became its own flex item and picked up the 1.6rem gap, which is
     what made the strip read as scattered words rather than a line of text. */
  display: inline-block;
  gap: 0;
  padding-inline: 0;
  font-family: var(--label);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.marquee--ticker .marquee__star {
  margin-inline: 0.9rem;
  font-size: 0.7em;
  vertical-align: 0.15em;
  opacity: 0.75;
}

/* --- Reveal on scroll --------------------------------------------------- */

[data-reveal] {
  opacity: 0;
  transform: translateY(1.75rem);
  transition:
    opacity 0.85s var(--ease) var(--delay, 0s),
    transform 0.85s var(--ease) var(--delay, 0s),
    clip-path 0.85s var(--ease) var(--delay, 0s);
}

[data-reveal="wipe"] {
  transform: none;
  clip-path: inset(0 0 100% 0);
}

[data-reveal="scale"] {
  transform: scale(1.06);
  clip-path: inset(0 0 0 0);
}

.is-revealed[data-reveal] {
  opacity: 1;
  transform: none;
}

/* Only the clipping reveals keep a clip once shown. A plain fade-in has
   none, so anything that moves past its box (a magnetic button, a badge
   hanging off a corner) isn't cut off. */
.is-revealed[data-reveal="wipe"],
.is-revealed[data-reveal="scale"] { clip-path: inset(0 0 0 0); }

/* --- Utility ------------------------------------------------------------ */

/* Line breaks for one screen size: <br class="br-phone"> breaks only on
   phones, <br class="br-wide"> only on wider screens. */
.br-phone { display: none; }

@media (max-width: 640px) {
  .br-phone { display: inline; }
  .br-wide { display: none; }
}

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

.duo {
  filter: grayscale(1) contrast(1.08);
  transition: filter 0.7s var(--ease), transform 0.9s var(--ease);
}

.stack { display: grid; gap: clamp(1rem, 2vw, 1.75rem); }
.stack--tight { gap: 0.75rem; }
.flow > * + * { margin-top: 1.1em; }

.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
}

/* --- Reduced motion ----------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  body::before { animation: none; }

  [data-reveal] {
    opacity: 1;
    transform: none;
    clip-path: none;
  }

  .mark { background-size: 100% 0.42em; }
  .section--ink .mark { color: var(--butter); }
}
