/* =========================
   styles.css (FULL) — Panels + Header + Footer (always visible, mobile-safe)
   UPDATED: Episode sub-menu cinematic theme + animated underlines + current ep highlight
   ========================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  background: #000;
}

/* =========================
   Footer token (single source of truth)
   ========================= */

:root{
  --footer-h: 42px;

  /* header sizing tokens */
  --header-top-h: 64px;      /* logo + socials row (desktop) */
  --header-ep-h: 40px;       /* episode subnav row (desktop) */
}

/* =========================
   Floating Header (SOLID)
   ========================= */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;

  /* header total height = top row + episode row */
  height: calc(var(--header-top-h) + var(--header-ep-h));

  z-index: 1000;
  background: #000;
  isolation: isolate;

  /* allow clicks only on header contents */
  pointer-events: none;
}

.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #000;
  z-index: -1;
}

.site-header * {
  pointer-events: auto;
}

/* Existing header row */
.header-inner {
  height: var(--header-top-h);
  padding: 0 20px;

  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo img {
  height: 28px;
  width: auto;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-actions a {
  width: 28px;
  height: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  opacity: 0.85;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.header-actions a:hover {
  opacity: 1;
  transform: scale(1.05);
}

.header-actions img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* =========================
   Episode Sub-menu (cinematic black + subtle animated underlines)
   ========================= */

.episode-nav{
  height: var(--header-ep-h);
  padding: 0 20px;

  display: flex;
  align-items: center;
  gap: 14px;

  /* cinematic black */
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border-top: 1px solid rgba(255,255,255,0.08);
  border-bottom: 1px solid rgba(255,255,255,0.06);

  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;

  scroll-padding-left: 20px;
  scroll-padding-right: 20px;
}

/* hide scrollbar (optional) */
.episode-nav::-webkit-scrollbar{ height: 0; }
.episode-nav{ scrollbar-width: none; }

.episode-nav a{
  position: relative;
  flex: 0 0 auto;

  padding: 10px 2px; /* vertical rhythm + tiny horizontal for underline */
  text-decoration: none;

  color: rgba(255,255,255,0.72);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1;

  opacity: 0.95;
  transition: color 220ms ease, opacity 220ms ease, transform 220ms ease;
}

/* underline */
.episode-nav a::after{
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;

  height: 1px;
  background: rgba(255,255,255,0.22);

  transform: scaleX(0);
  transform-origin: left;
  transition: transform 260ms ease, background 260ms ease, opacity 260ms ease;
  opacity: 0.9;
}

.episode-nav a:hover{
  color: rgba(255,255,255,0.92);
  transform: translateY(-1px);
}
.episode-nav a:hover::after{
  transform: scaleX(1);
  background: rgba(255,255,255,0.55);
}

/* keyboard focus */
.episode-nav a:focus-visible{
  outline: none;
  color: rgba(255,255,255,0.95);
}
.episode-nav a:focus-visible::after{
  transform: scaleX(1);
  background: rgba(255,255,255,0.75);
}

/* current episode highlight */
.episode-nav a.is-active,
.episode-nav a[aria-current="page"]{
  color: rgba(255,255,255,0.98);
  font-weight: 600;
}
.episode-nav a.is-active::after,
.episode-nav a[aria-current="page"]::after{
  transform: scaleX(1);
  background: rgba(255,255,255,0.85);
  opacity: 1;
}

/* Optional subtle "glint" on active underline only */
@media (prefers-reduced-motion: no-preference){
  .episode-nav a.is-active::after,
  .episode-nav a[aria-current="page"]::after{
    animation: ep-underline-glint 2.8s ease-in-out infinite;
  }

  @keyframes ep-underline-glint{
    0%, 100%{ opacity: 0.85; }
    50%{ opacity: 1; }
  }
}

/* =========================
   Panels Container
   ========================= */

.container {
  display: flex;
  width: 100%;

  /* Reserve space so footer is always visible */
  height: calc(100vh - var(--footer-h));
  overflow: hidden;

  background: #000;

  /* reserve full header height (top row + episode nav) */
  padding-top: calc(var(--header-top-h) + var(--header-ep-h));

  position: relative;
  z-index: 0;
}

/* Better behavior on mobile browsers with dynamic address bars */
@supports (height: 100svh){
  .container{
    height: calc(100svh - var(--footer-h));
  }
}

/* =========================
   Panels
   ========================= */

.panel {
  flex: 1;
  position: relative;

  display: flex;
  align-items: center;
  justify-content: center;

  text-decoration: none;
  color: #fff;
  font-size: 2rem;

  overflow: hidden;

  /* helps reduce flicker during animation */
  transform: translateZ(0);

  transition:
    flex 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Background image layer */
.panel::after {
  content: "";
  position: absolute;
  inset: 0;

  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;

  z-index: 0;
}

/* Dark overlay */
.panel::before {
  content: "";
  position: absolute;
  inset: 0;

  background: rgba(0, 0, 0, 0.4);

  z-index: 1;
}

.panel span {
  position: relative;
  z-index: 2;
}

/* =========================
   Panel titles scale safely within their panel (no clipping)
   ========================= */

/* Make each panel a container so font can scale to panel width */
.panel{
  container-type: inline-size;
}

/* Fit-to-panel-ish sizing + safe overflow rules */
.panel span{
  display: block;
  max-width: 100%;
  padding: 0.25em 0.4em;

  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  /* scales to the panel width (cqi = 1% of container width) */
  font-size: clamp(1.2rem, 14cqi, 2.6rem);
  line-height: 1.05;
}

/* =========================
   Active / Tap Logic
   ========================= */

.container.has-active .panel {
  flex: 0.9;
  transform: scale(0.985);
}

.panel.active {
  flex: 1.4;
  transform: scale(1);
}

/* =========================
   Background Images
   ========================= */

.panel-0::after { background-image: url("/images/about/portrait_destroyed.jpg"); }
.panel-1::after { background-image: url("/images/design/dv/design.jpg"); }
.panel-2::after { background-image: url("/images/directing/birch/birch-00-gross.jpg"); }
.panel-3::after { background-image: url("images/editing/plateindex.jpg"); }
.panel-4::after { background-image: url("/images/producing/boom.jpg"); }

/* =========================
   Desktop Hover (Safe)
   ========================= */

@media (hover: hover) and (pointer: fine) {
  .container:hover .panel {
    flex: 0.9;
    filter: brightness(0.85);
  }

  .container .panel:hover {
    flex: 1.4;
    filter: brightness(1);
  }
}

/* =========================
   iOS / Touch seam fix (only touch devices)
   ========================= */

@media (hover: none) and (pointer: coarse) {
  .panel {
    margin: -0.5px; /* kills hairline seams on iOS Safari */
  }
}

/* =========================
   Portrait Mobile Layout
   ========================= */

@media (max-width: 768px) and (orientation: portrait) {
  .container {
    flex-direction: column;

    /* Still reserve footer space */
    height: calc(100vh - var(--footer-h));

    /* reserve full mobile header height */
    padding-top: calc(var(--header-top-h) + var(--header-ep-h));
  }

  @supports (height: 100svh){
    .container{
      height: calc(100svh - var(--footer-h));
    }
  }

  .panel {
    width: 100%;
    margin: 0;
  }

  .container.has-active .panel {
    flex: 0.85;
  }

  .panel.active {
    flex: 1.6;
  }
}

/* =========================
   Mobile Header Scaling
   ========================= */

@media (max-width: 768px) {
  :root{
    --header-top-h: 56px;
    --header-ep-h: 38px;
  }

  .logo img {
    height: 24px;
  }

  .header-actions a {
    width: 24px;
    height: 24px;
  }

  .episode-nav{
    gap: 12px;
  }

  .episode-nav a{
    font-size: 0.74rem;
    letter-spacing: 0.12em;
    padding: 10px 2px;
  }

  .episode-nav a::after{
    bottom: 6px;
  }
}

/* =========================
   Footer always visible
   ========================= */

:root{
  --footer-h: 42px;
}

/* Make sure panels don't occupy footer space */
.container{
  height: calc(100vh - var(--footer-h));
}
@supports (height: 100svh){
  .container{ height: calc(100svh - var(--footer-h)); }
}

/* Footer always visible */
.site-footer{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;

  /* iPhone safe area */
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--footer-h) + env(safe-area-inset-bottom));

  width: 100%;
  background: #000;
  border-top: 1px solid rgba(255,255,255,0.12);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 2147483647;
  isolation: isolate;

  transform: none;
  opacity: 1;
  visibility: visible;
}

.footer-inner{
  font-family: "Lexend", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.12em;
}

/* Reserve bottom space (optional) */
body{
  padding-bottom: calc(var(--footer-h) + env(safe-area-inset-bottom));
}

/* =========================================================
   EDGE-SAFE THUMBNAILS (Project section thumbs + Gallery)
   Paste at END of page_wrap.css
   ========================================================= */

.thumbs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-gap: 12px;
  gap: 12px;
  align-content: start;
}

.thumbs-side,
.info-row,
.copy-wide {
  min-width: 0;
}

.thumb {
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;

  display: block;
  width: 100%;

  border-radius: 18px;
  overflow: hidden;

  position: relative;
}

.thumb::before {
  content: "";
  display: block;
  padding-top: 100%;
}

.thumb > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.thumbs-grid-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-block .thumbs-grid {
  grid-gap: 10px;
  gap: 10px;
}

/* =========================
   Panel Section Titles – DM Serif Display
   ========================= */

.panel span{
  font-family: "DM Serif Display", serif !important;
  font-weight: 400;
  letter-spacing: 0.02em;
}

/* iPhone Landscape – reduce panel text by 25% */
@media only screen 
  and (min-device-width: 375px) 
  and (max-device-width: 932px) 
  and (orientation: landscape) 
  and (-webkit-min-device-pixel-ratio: 2) {

  .panel span {
    font-size: 75%;
  }

}