/* =========================================================
   flow.css — stacked scrolling layout for smaller screens
   Phones, tablets, foldables and any window below 1280×720.
   The same scenes as the canvas layout, stacked as one page.

   THE BREAKPOINT LIVES HERE AND ONLY HERE. The media query
   sets --layout: flow, which js/canvas.js reads. Change the
   numbers below and both CSS and JS follow.

   Everything in this file is inside the media query, so the
   desktop canvas layout is untouched.
   ========================================================= */

@media (max-width: 1279.98px), (max-height: 719.98px) {

  :root {
    --layout: flow;
    --flow-gutter: clamp(20px, 5vw, 48px);
    --flow-topbar-h: 64px;
    --flow-nav-h: 58px;
  }

  /* =========================================================
     PAGE + CANVAS — a normal scrolling document
     ========================================================= */
  html, body {
    overflow-x: clip;
    overflow-y: visible;
    height: auto;
    min-height: 100%;
  }
  html { scroll-padding-top: var(--flow-topbar-h); }
  body { padding-bottom: calc(var(--flow-nav-h) + env(safe-area-inset-bottom)); }

  #canvas-viewport {
    position: static;
    overflow: visible;
  }
  #canvas {
    position: relative;
    width: 100%;
    height: auto;
    transform: none;
  }

  /* Countdown and light beams are canvas-layout features */
  .preloader,
  .beams { display: none; }

  /* Softer vignette — it sits over scrolling content here */
  .vignette { background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.55) 100%); }

  /* =========================================================
     TOP BAR — fixed, compact
     ========================================================= */
  .topbar {
    position: fixed;
    padding: 10px var(--flow-gutter);
    padding-top: calc(10px + env(safe-area-inset-top));
    background: rgba(6,5,4,0.86);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rule);
  }
  .brand { padding: 0; gap: 12px; }
  .brand-logo { width: 40px; height: 40px; }
  .brand-name { font-size: 14px; letter-spacing: 0.16em; }
  .brand-sub { font-size: 8px; letter-spacing: 0.22em; margin-top: 5px; }
  .topbar-btn { padding: 8px 12px; }

  /* =========================================================
     RAIL — becomes the bottom navigation bar
     ========================================================= */
  .rail {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: auto;
    flex-direction: row;
    justify-content: stretch;
    align-items: stretch;
    gap: 0;
    padding: 0 4px env(safe-area-inset-bottom);
    background: rgba(6,5,4,0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule);
  }
  .rail::before { display: none; }
  .rail-item {
    flex: 1 1 0;
    width: auto;
    height: var(--flow-nav-h);
    flex-direction: column;
    gap: 5px;
    background: transparent;
    font-size: 10px;
    letter-spacing: 0.14em;
    box-shadow: inset 0 2px 0 transparent;
    transition: color 0.3s var(--ease), box-shadow 0.3s var(--ease);
  }
  .rail-item::before { display: none; }
  .rail-item.active { box-shadow: inset 0 2px 0 var(--ember); }
  .rail-label,
  .rail-item:hover .rail-label,
  .rail-item.active .rail-label {
    position: static;
    opacity: 1;
    transform: none;
    font-size: 8px;
    letter-spacing: 0.1em;
    line-height: 1.2;
    white-space: normal;
    text-align: center;
    color: inherit;
  }

  /* Status strip has no place on a small screen */
  .reel-strip { display: none; }

  /* =========================================================
     SCENES — stacked sections
     ========================================================= */
  .scene,
  .scene.active {
    position: relative;
    width: 100%;
    height: auto;
    display: block;
    opacity: 1;
    visibility: visible;
    transition: none;
    padding: 72px var(--flow-gutter) 64px;
    border-top: 1px solid var(--rule);
  }
  .scene.active { z-index: 10; }

  .scene-number,
  .scene.active .scene-number {
    font-size: clamp(110px, 30vw, 220px);
    top: 20px;
    right: -6px;
    opacity: 0.55;
    animation: none;
  }

  .scene-heading { margin-bottom: 20px; }

  /* Long words in headings wrap instead of running off-screen */
  .studio-headline, .work-headline, .work-title, .cap-headline,
  .cap-card h3, .contact-headline, .hero-panel-headline {
    overflow-wrap: break-word;
  }

  /* =========================================================
     HERO — the cycling panel, full width under the top bar
     ========================================================= */
  .scene-hero,
  .scene-hero.active {
    padding: calc(var(--flow-topbar-h) + env(safe-area-inset-top)) 0 0;
    border-top: none;
  }
  .hero-corner { display: none; }

  /* Landscape screens keep the side text zone of the desktop panel */
  #hero-panel {
    position: relative;
    top: auto; left: auto; right: auto; bottom: auto;
    height: clamp(340px, 52vw, 640px);
  }
  #hero-panel .hero-panel-text {
    width: 52%;
    padding: 0 var(--flow-gutter);
  }
  #hero-panel .hero-panel-slide[data-flat="true"] .hero-panel-image { background-size: cover; }
  #hero-panel .hero-panel-slide[data-flat="true"][data-side="left"] .hero-panel-image { background-position: var(--focus, 75% center); }
  #hero-panel .hero-panel-slide[data-flat="true"][data-side="right"] .hero-panel-image { background-position: var(--focus, 25% center); }

  .hero-panel-eyebrow { font-size: 10px; letter-spacing: 0.3em; margin-bottom: 14px; padding-left: 28px; }
  .hero-panel-headline { font-size: clamp(26px, 4.4vw, 52px); margin-bottom: 14px; }
  .hero-panel-detail { font-size: clamp(15px, 1.9vw, 20px); }
  .hero-panel-dots { bottom: 16px; }
  .hero-panel-dot { width: 9px; height: 9px; }
  .hero-panel-dot.active { width: 11px; height: 11px; }

  /* =========================================================
     STUDIO
     ========================================================= */
  .scene-studio .studio-wrap {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .studio-headline {
    font-size: clamp(34px, 8.5vw, 60px);
    margin-bottom: 20px;
  }
  .studio-body p { font-size: 17px; line-height: 1.65; }

  /* =========================================================
     THE SLATE — poster above details
     ========================================================= */
  .work-header { gap: 16px; margin-bottom: 28px; }
  .work-headline { font-size: clamp(36px, 9vw, 60px); }
  .work-counter { font-size: 16px; }
  .work-counter .current { font-size: 30px; }

  .work-stage {
    grid-template-columns: 1fr;
    gap: 32px;
    min-height: 0;
  }
  .work-poster {
    width: min(100%, 340px);
    margin: 0 auto;
    max-height: none;
    touch-action: pan-y;
  }
  .work-title { font-size: clamp(32px, 8vw, 56px); min-height: 0; }
  .work-tagline { font-size: 15px; min-height: 0; margin-bottom: 20px; }
  .work-desc { max-width: none; min-height: 0; font-size: 16px; margin-bottom: 24px; }
  .work-cast { margin-top: 0; padding: 16px 0 24px; gap: 8px 14px; }
  .work-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }
  .work-meta-item strong { font-size: 12px; overflow-wrap: break-word; }
  .work-controls { margin-top: 28px; justify-content: center; gap: 16px; }
  .work-nav-btn { width: 48px; height: 48px; flex-shrink: 0; }
  .work-dots { gap: 6px; flex-wrap: wrap; justify-content: center; }
  .work-dot { width: 18px; height: 2px; }

  /* =========================================================
     CAPABILITIES
     ========================================================= */
  .cap-header { margin-bottom: 28px; }
  .cap-headline { font-size: clamp(34px, 8.5vw, 60px); }
  .cap-intro { font-size: 17px; }
  .cap-grid { grid-template-columns: 1fr; }
  .cap-card { min-height: 0; padding: 26px 22px; }
  .cap-card h3 { font-size: 23px; }
  .cap-card p { font-size: 15px; }

  /* =========================================================
     CONTACT
     ========================================================= */
  .scene-contact .contact-wrap {
    grid-template-columns: 1fr;
    gap: 40px;
  }
  .contact-left .contact-headline {
    font-size: clamp(44px, 12vw, 88px);
    margin-bottom: 24px;
  }
  .contact-intro { font-size: 17px; margin-bottom: 28px; max-width: none; }
  .contact-lines { padding-top: 12px; }
  .contact-line {
    flex-wrap: wrap;
    gap: 6px 16px;
    padding: 16px 0;
  }
  .contact-line:hover { padding-left: 0; }
  .contact-line .value {
    font-size: clamp(13px, 3.6vw, 17px);
    letter-spacing: 0.02em;
    overflow-wrap: anywhere;
  }
  .contact-form { padding: 32px 22px; }
  .form-submit { padding: 18px; }


  /* =========================================================
     WIDER FLOW SCREENS — tablets and small laptop windows
     ========================================================= */
  @media (min-width: 640px) {
    .cap-grid { grid-template-columns: repeat(2, 1fr); }
  }
  @media (min-width: 820px) {
    .scene,
    .scene.active { padding-top: 96px; padding-bottom: 88px; }
    .scene-hero,
    .scene-hero.active { padding: calc(var(--flow-topbar-h) + env(safe-area-inset-top)) 0 0; }
    .studio-wrap, .work-wrap, .cap-wrap, .contact-wrap { margin: 0 auto; }
    .work-stage { grid-template-columns: 5fr 6fr; gap: 48px; align-items: start; }
    .work-poster { width: 100%; }
    .work-controls { justify-content: flex-start; }
    .scene-contact .contact-wrap { grid-template-columns: 1fr 1fr; gap: 48px; }
  }
  @media (min-width: 1000px) {
    .scene-studio .studio-wrap { grid-template-columns: 5fr 7fr; gap: 56px; }
    .cap-grid { grid-template-columns: repeat(3, 1fr); }
  }

  /* =========================================================
     PORTRAIT — hero text moves to the bottom of the frame
     ========================================================= */
  @media (orientation: portrait) {
    #hero-panel {
      height: clamp(520px, calc(100svh - var(--flow-topbar-h) - var(--flow-nav-h) - 24px), 860px);
    }
    /* Each slide's portrait focal point comes from data/hero-panels.json */
    #hero-panel .hero-panel-slide[data-side] .hero-panel-image {
      background-position: var(--focus-portrait, var(--focus, center));
    }
    #hero-panel .hero-panel-slide[data-side] .hero-panel-video {
      object-position: var(--video-focus-portrait, var(--focus-portrait, var(--focus, center)));
    }
    #hero-panel .hero-panel-slide .hero-panel-overlay {
      background: linear-gradient(
        to top,
        rgba(6, 5, 4, 0.96) 0%,
        rgba(6, 5, 4, 0.90) 30%,
        rgba(6, 5, 4, 0.40) 55%,
        rgba(6, 5, 4, 0.00) 75%
      );
    }
    #hero-panel .hero-panel-slide .hero-panel-text {
      left: 0;
      right: 0;
      top: auto;
      bottom: 52px;
      transform: none;
      width: 100%;
    }
    .hero-panel-headline { font-size: clamp(30px, 8vw, 52px); }
    .hero-panel-detail { font-size: clamp(16px, 4.2vw, 20px); }
  }
}
