/* ==========================================================================
   Layout: app shell, navigation, pages, hero, grids, search
   ========================================================================== */

.app { min-height: 100vh; min-height: 100svh; }

/* ---- Brand ----------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex: none;
  color: var(--ivory);
  border-radius: var(--radius-sm);
}
.brand__mark { width: 2.05rem; height: auto; flex: none; color: var(--accent); }
.mark-roof { color: var(--ivory); }
.brand__word {
  padding-top: 0.12em;
  font-family: var(--font-display);
  font-stretch: condensed;
  font-size: 1.0625rem;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wordmark);
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---- Top bar ----------------------------------------------------------------
   Transparent over the hero, glass once content scrolls beneath it. */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.4vw, 2.75rem);
  height: calc(var(--topbar-h) + var(--safe-top));
  padding: var(--safe-top) var(--gutter) 0;
  transition:
    background-color var(--dur-slow) var(--ease-out),
    box-shadow var(--dur-slow) var(--ease-out);
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 -3rem 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgb(8 7 10 / 0.72), rgb(8 7 10 / 0.3) 55%, rgb(8 7 10 / 0));
  transition: opacity var(--dur-slow) var(--ease-out);
}
.topbar.is-solid {
  background: rgb(15 13 18 / 0.86);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow: 0 1px 0 var(--line), 0 12px 32px -14px rgb(0 0 0 / 0.7);
}
.topbar.is-solid::before { opacity: 0; }

.primary-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 1.7vw, 1.9rem);
  min-width: 0;
}
.primary-nav__link {
  position: relative;
  padding: 0.45rem 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}
.primary-nav__link:hover { color: var(--text-primary); }
.primary-nav__link[aria-current="page"] { color: var(--text-primary); font-weight: var(--weight-semibold); }
.primary-nav__link[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.15rem;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}
.profile { position: relative; margin-left: 0.35rem; }

@media (max-width: 899px) and (min-width: 720px) {
  .topbar .brand__word { display: none; }
}
@media (max-width: 719px) {
  .primary-nav { display: none; }
  .brand__mark { width: 1.8rem; }
  .brand__word { font-size: 0.95rem; }
}

/* ---- Bottom tab bar (phones) ------------------------------------------- */

.tabbar { display: none; }

@media (max-width: 719px) {
  .tabbar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: var(--z-tabbar);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--tabbar-h);
    padding-bottom: var(--safe-bottom);
    background: rgb(15 13 18 / 0.92);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
    box-shadow: 0 -1px 0 var(--line);
  }
  .tabbar__link {
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 0.2rem;
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    font-weight: var(--weight-semibold);
    letter-spacing: 0.01em;
  }
  .tabbar__link .icon { width: 1.45rem; height: 1.45rem; }
  .tabbar__link[aria-current="page"] { color: var(--text-primary); }
  .tabbar__link[aria-current="page"] .icon { color: var(--accent); }
}

/* ---- Pages ----------------------------------------------------------------- */

.main {
  display: block;
  min-height: 100vh;
  min-height: 100svh;
  padding-bottom: calc(var(--tabbar-h) + var(--space-16));
  outline: none;
}

.page {
  padding-top: calc(var(--topbar-h) + var(--safe-top) + clamp(1.5rem, 3vw, 2.75rem));
  animation: page-in var(--dur-base) var(--ease-out);
}
.page--hero { padding-top: 0; }
@keyframes page-in { from { opacity: 0; } }

.page__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
  padding: 0 var(--gutter);
  margin-bottom: clamp(1.25rem, 2.5vw, 2rem);
}
.page__titles { display: grid; gap: 0.3rem; }
.page__count { color: var(--text-tertiary); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.page__controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.page__section + .page__section { margin-top: var(--section-gap); }
.section-title { padding: 0 var(--gutter); margin-bottom: var(--space-3); }

.grid {
  --cols: 2;
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: clamp(1.1rem, 1.8vw, 1.75rem) var(--rail-gap);
  padding: 0 var(--gutter);
}
@media (min-width: 600px) { .grid { --cols: 3; } }
@media (min-width: 1024px) { .grid { --cols: 4; } }
@media (min-width: 1440px) { .grid { --cols: 5; } }
@media (min-width: 1920px) { .grid { --cols: 6; } }

.grid--wide { --cols: 1; row-gap: clamp(1.75rem, 3vw, 2.5rem); }
@media (min-width: 600px) { .grid--wide { --cols: 2; } }
@media (min-width: 1100px) { .grid--wide { --cols: 3; } }

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

.hero {
  --hero-overlap: clamp(4.5rem, 13vh, 9rem);
  --hero-content-bottom: calc(var(--hero-overlap) + clamp(2.25rem, 6vh, 4.25rem));
  position: relative;
  height: clamp(34rem, 86svh, 62rem);
  overflow: hidden;
  isolation: isolate;
  background: var(--velvet-0);
}
.hero__stage,
.hero__slide { position: absolute; inset: 0; }
.hero__slide { opacity: 0; transition: opacity var(--dur-scene) var(--ease-in-out); }
.hero__slide.is-active { opacity: 1; }

.hero__img {
  position: absolute;
  top: -4%;
  left: 0;
  width: 100%;
  height: 104%;
  object-fit: cover;
  object-position: 70% 28%;
  opacity: 0;
  transform: translate3d(0, var(--parallax, 0px), 0);
  transition: opacity var(--dur-scene) var(--ease-out);
  will-change: transform;
}
.hero__img.is-loaded { opacity: 1; }

.hero__beam {
  position: absolute;
  top: -35%;
  left: -20%;
  width: 78%;
  height: 120%;
  pointer-events: none;
  background: radial-gradient(closest-side, rgb(var(--brass-rgb) / 0.15), rgb(var(--brass-rgb) / 0));
  mix-blend-mode: screen;
}
.hero__shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgb(15 13 18 / 0.92) 0%, rgb(15 13 18 / 0.66) 24%, rgb(15 13 18 / 0.16) 52%, rgb(15 13 18 / 0) 70%),
    linear-gradient(0deg, var(--bg-primary) 0%, rgb(15 13 18 / 0.78) 14%, rgb(15 13 18 / 0) 44%),
    linear-gradient(180deg, rgb(8 7 10 / 0.5) 0%, rgb(8 7 10 / 0) 24%);
}
.hero__grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: var(--grain);
  opacity: 0.07;
  mix-blend-mode: overlay;
}
.hero.is-soft .hero__grain { opacity: 0.13; }

.hero__content {
  position: absolute;
  left: var(--gutter);
  bottom: var(--hero-content-bottom);
  z-index: 2;
  width: min(42rem, 100% - var(--gutter) * 2);
  opacity: var(--fade, 1);
}
.hero__inner {
  display: grid;
  justify-items: start;
  gap: var(--space-4);
  transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.hero__inner.is-swapping { opacity: 0; transform: translateY(0.5rem); }

.hero__title {
  max-width: 13ch;
  font-size: var(--text-display-l);
  text-shadow: 0 2px 40px rgb(0 0 0 / 0.35);
}
.hero__title[data-length="long"] { max-width: 18ch; font-size: var(--text-display-m); }
.hero__logo { max-width: min(30rem, 85%); max-height: 10rem; object-fit: contain; object-position: left bottom; }
.hero__meta { color: rgb(var(--ivory-rgb) / 0.86); font-size: var(--text-md); }
.hero__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  max-width: 34rem;
  overflow: hidden;
  color: rgb(var(--ivory-rgb) / 0.86);
  font-size: var(--text-lg);
  line-height: 1.5;
  text-shadow: 0 1px 18px rgb(0 0 0 / 0.5);
}
.hero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: var(--space-2); }
.hero__resume { display: flex; align-items: center; gap: 0.75rem; color: var(--text-secondary); font-size: var(--text-sm); }
.hero__resume .progress-line { width: 9rem; }

.hero__dots {
  position: absolute;
  right: var(--gutter);
  bottom: var(--hero-content-bottom);
  z-index: 2;
  display: flex;
  gap: 0.35rem;
}
.hero__dot {
  position: relative;
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.hero__dot::before,
.hero__dot::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  border-radius: 2px;
}
.hero__dot::before { background: rgb(var(--ivory-rgb) / 0.28); }
.hero__dot::after { background: var(--ivory); transform: scaleX(0); transform-origin: left center; }
.hero__dot[aria-current="true"]::after { animation: hero-dot var(--hero-interval, 9s) linear forwards; }
.hero.is-held .hero__dot[aria-current="true"]::after { animation: none; transform: scaleX(1); }
@keyframes hero-dot { to { transform: scaleX(1); } }

.home__rails {
  position: relative;
  z-index: 3;
  margin-top: calc(var(--hero-overlap, 0px) * -1);
}
.home__rails--flush { margin-top: 0; padding-top: calc(var(--topbar-h) + var(--safe-top) + var(--space-8)); }

@media (max-width: 719px) {
  .hero {
    --hero-overlap: 1.5rem;
    --hero-content-bottom: 3.75rem;
    height: min(82svh, 46rem);
  }
  .hero__img { object-position: 62% 30%; }
  .hero__beam { display: none; }
  .hero__shade {
    background:
      linear-gradient(0deg, var(--bg-primary) 0%, rgb(15 13 18 / 0.86) 24%, rgb(15 13 18 / 0.18) 54%, rgb(8 7 10 / 0.5) 100%);
  }
  .hero__content { left: var(--gutter); right: var(--gutter); width: auto; }
  .hero__inner { justify-items: center; text-align: center; gap: var(--space-3); }
  .hero__title,
  .hero__title[data-length="long"] { max-width: 16ch; font-size: clamp(2.25rem, 10.5vw, 3.25rem); }
  .hero__meta { justify-content: center; font-size: var(--text-sm); }
  .hero__desc { -webkit-line-clamp: 2; line-clamp: 2; font-size: var(--text-md); }
  .hero__actions { justify-content: center; width: 100%; }
  .hero__actions .btn { flex: 1 1 0; max-width: 11.5rem; padding-inline: 1em; }
  .hero__dots { left: 50%; right: auto; bottom: 1.4rem; transform: translateX(-50%); }
  .hero__dot { width: 1.4rem; }
}

/* ---- Search ----------------------------------------------------------------- */

.search-head { padding: 0 var(--gutter); margin-bottom: clamp(1.5rem, 3vw, 2.5rem); }
.search-field {
  display: flex;
  align-items: center;
  max-width: 56rem;
  border-bottom: 2px solid var(--line-strong);
  transition: border-color var(--dur-base) var(--ease-out);
}
.search-field:focus-within { border-bottom-color: var(--accent); }
.search-field__icon { width: clamp(1.6rem, 2.6vw, 2.2rem); height: auto; color: var(--text-tertiary); }
.search-field__input {
  flex: 1;
  min-width: 0;
  height: clamp(3.5rem, 7vw, 5rem);
  padding: 0 0.75rem 0 clamp(0.75rem, 1.4vw, 1.25rem);
  border: 0;
  background: transparent;
  color: var(--ivory);
  font-size: clamp(1.45rem, 1rem + 2.1vw, 2.6rem);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.02em;
  caret-color: var(--accent);
  -webkit-appearance: none;
  appearance: none;
}
.search-field__input:focus { outline: none; }
.search-field__input::placeholder { color: var(--text-tertiary); font-weight: var(--weight-medium); }
.search-field__input::-webkit-search-cancel-button,
.search-field__input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-summary { margin-top: 0.85rem; color: var(--text-tertiary); font-size: var(--text-sm); min-height: 1.4em; }

.genre-index {
  max-width: 72rem;
  padding: 0 var(--gutter);
  columns: 3 14rem;
  column-gap: clamp(1.5rem, 4vw, 4rem);
}
.genre-index__link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  break-inside: avoid;
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.3rem);
  font-weight: var(--weight-semibold);
  transition: color var(--dur-fast) var(--ease-out), padding var(--dur-fast) var(--ease-out);
}
.genre-index__link:hover { color: var(--accent); padding-left: 0.35rem; }
.genre-index__count { color: var(--text-tertiary); font-size: var(--text-sm); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }

.noscript { padding: 2rem; text-align: center; color: var(--text-secondary); }

/* Long resume labels ("Resume S1:E3") drop the episode code on narrow phones;
   the line under the buttons still says which episode. */
.btn__extra { margin-left: -0.2em; }
.hero__title-logo { margin: 0; }
@media (max-width: 719px) {
  .hero__actions .btn--lg { --btn-h: 3rem; font-size: var(--text-md); }
}
@media (max-width: 479px) {
  .btn__extra { display: none; }
}

/* YOUBIFLIX: editorial treatment on the existing authenticated hero. */
.hero__eyebrow {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border-left: 3px solid var(--accent);
  background: linear-gradient(90deg, rgb(8 7 10 / .48), transparent);
  color: var(--brass-bright);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .19em;
  line-height: 1.25;
}
