:root {
  color-scheme: light;
  --paper: #f7f6f2;
  --ink: #111111;
  --muted: #6d6a64;
  --safe-top: max(12px, env(safe-area-inset-top, 0px));
  --safe-right: max(12px, env(safe-area-inset-right, 0px));
  --safe-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  --island-inset: max(32px, calc(env(safe-area-inset-top, 0px) + 20px), calc(env(safe-area-inset-bottom, 0px) + 20px));
}

* { box-sizing: border-box; }

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

@font-face {
  font-family: Outfit;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/outfit-600.woff2") format("woff2");
}

html {
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100svh;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", monospace;
  -webkit-font-smoothing: antialiased;
}

body.player-open { overflow: hidden; }

button, a {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.masonry {
  position: relative;
  z-index: 0;
  display: grid;
  width: 100%;
  align-items: stretch;
  gap: 0;
  padding: 0;
  margin: 0;
  line-height: 0;
  background: var(--paper);
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.tile {
  position: relative;
  display: grid;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: auto;
  grid-column: span 3;
  aspect-ratio: var(--tile-ratio, 16 / 9);
  overflow: hidden;
  border: 0;
  margin: 0;
  padding: 0;
  line-height: 0;
  background-color: #e8e6e0;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 100% 100%;
  cursor: zoom-in;
  contain: layout;
}

.tile.span-third { background-size: cover; }

.tile.span-third { grid-column: span 2; }
.tile.span-full { grid-column: span 6; }

.masonry[data-variant="landscape"] .tile { --tile-ratio: 16 / 9; }
.masonry[data-variant="portrait"] .tile { --tile-ratio: 4 / 5; }

.preview-low,
.preview-high {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.tile.span-third .preview-low,
.tile.span-third .preview-high {
  object-fit: cover;
}

.preview-low {
  opacity: 0;
  transition: opacity 240ms ease;
}

.tile.is-posted .preview-low { opacity: 1; }

.preview-high {
  z-index: 1;
  opacity: 0;
  transition: opacity 320ms ease;
}

.tile.has-frame .preview-high { opacity: 1; }

.vhs-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 280ms ease;
}

.tile.is-paused.is-vhs .vhs-canvas { opacity: 1; }

.masonry.no-vhs .tile.is-paused .preview-low {
  filter: grayscale(1) contrast(1.12);
}

.masonry.no-vhs .tile.is-paused::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, .04) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: overlay;
}

@media (max-width: 720px) {
  .masonry.no-vhs .tile.is-paused::after {
    background: repeating-linear-gradient(
      to bottom,
      rgba(255, 255, 255, .08) 0 1px,
      transparent 1px 3px
    );
  }
}

.tile-pause {
  position: absolute;
  z-index: 4;
  top: 12px;
  left: 12px;
  display: flex;
  gap: 3px;
  height: 11px;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 1px 6px rgba(0, 0, 0, .22));
  transition: opacity .35s ease;
}

.tile.is-paused .tile-pause { opacity: .42; }

.tile-pause span {
  display: block;
  width: 3px;
  height: 100%;
  background: rgba(244, 241, 234, .72);
  border-radius: 1px;
}

.tile-title {
  position: absolute;
  z-index: 3;
  left: 14px;
  right: 14px;
  bottom: 12px;
  color: #fff;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-shadow: 0 0 12px rgba(0, 0, 0, .4);
  line-height: 1.2;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
}

.tile:focus-visible .tile-title {
  opacity: 1;
  transform: none;
}

@media (hover: hover) and (pointer: fine) {
  .tile:hover .tile-title {
    opacity: 1;
    transform: none;
  }
}

.grid-empty {
  grid-column: 1 / -1;
  padding: 30vh 4vw;
  color: var(--muted);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.contact {
  --island-h: 56px;
  position: fixed;
  z-index: 20;
  left: 50%;
  isolation: isolate;
  display: flex;
  align-items: center;
  height: var(--island-h);
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 0 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(18, 18, 16, .42);
  background: color-mix(in oklab, black 40%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .34),
    0 18px 40px -22px rgba(0, 0, 0, .62);
  color: #f4f1ea;
  transform: translateX(-50%);
  transition: opacity .28s ease, transform .45s cubic-bezier(.34, 1.3, .5, 1);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .contact {
    background: color-mix(in oklab, black 38%, transparent);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    backdrop-filter: blur(28px) saturate(1.6);
  }
}

@supports (-apple-visual-effect: -apple-system-glass-material) {
  .contact {
    background: transparent;
    -apple-visual-effect: -apple-system-glass-material;
  }
}

.contact.bottom {
  top: auto;
  bottom: var(--island-inset);
}

.contact.top {
  bottom: auto;
  top: var(--island-inset);
}

.contact.is-switching {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
}

.contact.top.is-switching { transform: translateX(-50%) translateY(-8px); }

.contact-toggle:focus-visible,
.contact-links a:focus-visible {
  outline: 1px solid #f4f1ea;
}

.contact-toggle {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  height: var(--island-h);
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font-family: Outfit, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  line-height: 1;
}

.contact-links {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  margin-left: 0;
  pointer-events: none;
  white-space: nowrap;
  font-family: Outfit, "Helvetica Neue", Helvetica, Arial, sans-serif;
  transition: max-width .55s cubic-bezier(.34, 1.3, .5, 1), opacity .2s ease, margin .55s cubic-bezier(.34, 1.3, .5, 1);
}

.contact.is-open .contact-links {
  max-width: 22rem;
  opacity: 1;
  margin-left: 1.15rem;
  pointer-events: auto;
}

.contact-links a {
  text-decoration: none;
  color: rgba(244, 241, 234, .72);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: .02em;
}

.contact-links a:hover { color: #f4f1ea; }

body.player-open .contact {
  opacity: 0;
  pointer-events: none;
}

.player {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #0c0c0b;
  color: #f2f0e6;
  transition: transform .32s cubic-bezier(.22, 1, .36, 1), opacity .32s ease;
}

.player.is-dragging {
  transition: none;
}

.player-close {
  grid-row: 1;
  justify-self: end;
  margin: var(--safe-top) var(--safe-right) 0;
  border: 0;
  background: none;
  color: #e8e6dc;
  cursor: pointer;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-size: 11px;
  padding: 10px 4px;
}

.player-close-arrow {
  display: none;
  width: 28px;
  height: 28px;
}

.player-stage {
  grid-row: 2;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: min(2vh, 1rem) 4vw;
  /* Size container so the media can be measured against the space the stage
     actually got, rather than against a guess at how tall the surrounding
     chrome is. The stage sits in a minmax(0, 1fr) row, so its size comes from
     the grid, not from its contents -- size containment is safe here. */
  container-type: size;
}

.player-media {
  position: relative;
  /* Fallback for browsers without container query units; the cqh line below
     wins everywhere else and is exact. */
  width: min(100%, calc((100svh - 20rem) * 16 / 9));
  width: min(100%, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
}

.player-media iframe,
.player-poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.player-poster {
  object-fit: cover;
  pointer-events: none;
  transition: opacity .4s ease;
}

.player.is-playing .player-poster { opacity: 0; }

.player-details {
  grid-row: 3;
  display: grid;
  gap: .4rem;
  padding: .85rem clamp(1rem, 4vw, 2.2rem) max(1.2rem, var(--safe-bottom));
}

.kicker {
  margin: 0;
  color: #aea99c;
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.player:has(.player-episodes:not([hidden])) .kicker {
  text-transform: none;
  letter-spacing: .03em;
  font-size: 11px;
}

.player-episodes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 .55rem;
}

.player-episodes[hidden] { display: none; }

.player-episode {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(244, 241, 234, .28);
  background: transparent;
  color: rgba(244, 241, 234, .72);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 11px;
  letter-spacing: .04em;
  line-height: 1.2;
  cursor: pointer;
}

.player-episode.is-active {
  color: #f4f1ea;
  border-color: rgba(244, 241, 234, .78);
}

.player-credits {
  margin: 0;
  max-width: 46rem;
  color: #a8a396;
  font-size: clamp(11px, 1.7vw, 13px);
  line-height: 1.55;
  white-space: normal;
}

.player-credits b {
  color: #dedad0;
  font-weight: 600;
}

.player-details h1 {
  margin: 0;
  font-size: clamp(18px, 3.2vw, 28px);
  font-weight: 600;
  letter-spacing: .02em;
}

@media (max-width: 720px) {
  .masonry[data-variant="portrait"] .tile { --tile-ratio: 4 / 5; }

  .contact {
    --island-h: 48px;
    padding: 0 14px;
  }

  .contact.is-open .contact-links {
    margin-left: .85rem;
  }

  .player {
    grid-template-rows: auto auto minmax(3.5rem, 1fr);
    padding-top: max(44px, calc(env(safe-area-inset-top, 0px) + 32px));
    touch-action: pan-y;
  }

  .player-stage {
    grid-row: 1;
    place-items: start center;
    padding: 0;
    /* The stage is an auto row here, so it has to size from its contents. */
    container-type: normal;
  }

  .player-media {
    /* Full width on a portrait phone; the guard only bites on short screens
       (a landscape phone), where it keeps the video off the details block. */
    width: min(100%, calc((100svh - 20rem) * 16 / 9));
    max-height: none;
  }

  .player-details {
    grid-row: 2;
    gap: .3rem;
    padding: .7rem 1rem .2rem;
  }

  .player-episodes {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: .4rem;
  }

  .player-episodes::-webkit-scrollbar { display: none; }

  .player-close {
    grid-row: 3;
    justify-self: center;
    align-self: end;
    margin: 0 0 max(14px, var(--safe-bottom));
    padding: 14px 22px;
    letter-spacing: 0;
    text-transform: none;
  }

  .player-close-label { display: none; }

  .player-close-arrow {
    display: block;
    opacity: .62;
  }
}

@media (prefers-reduced-transparency: reduce) {
  .contact {
    background: rgba(22, 22, 20, .92);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .preview-low,
  .preview-high,
  .vhs-canvas,
  .tile-pause,
  .tile-title,
  .contact,
  .contact-links,
  .player,
  .player-poster { transition: none; }
}
