/* ============================================================
   Responsive — All Media Queries
   ============================================================ */

@media (max-width: 900px) {
  /* Mobile: solid bg + flex column so glass fills remaining space */
  #project-expanded-view.is-active {
    background: #040810;
    display: flex;
    flex-direction: column;
  }

  /* Mobile Project Expanded View (Vertical Mode) */
  #project-expanded-view.is-active:not(.is-fullscreen) .expanded-media-layer {
    position: relative;
    top: 0;
    height: 56.25vw;
    min-height: unset;
    flex-shrink: 0;
    z-index: 10;
  }
  
  #project-expanded-view.is-active:not(.is-fullscreen) .custom-player-ui {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 56.25vw;
  }
  
  #project-expanded-view.is-active:not(.is-fullscreen) .expanded-media-layer img,
  #project-expanded-view.is-active:not(.is-fullscreen) .expanded-media-layer iframe,
  #project-expanded-view.is-active:not(.is-fullscreen) #yt-player-target {
    min-width: unset !important;
    min-height: unset !important;
    width: 100vw !important;
    height: 56.25vw !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    position: absolute !important;
  }

  #project-expanded-view.is-active:not(.is-fullscreen) .expanded-media-inner {
    transform: none !important;
    opacity: 1 !important;
  }

  /* Glass layer fills remaining viewport — no page bleed-through */
  #project-expanded-view.is-active .expanded-glass-layer {
    flex: 1 0 auto;
    min-height: calc(100vh - 56.25vw);
    padding: 24px 20px 140px;
    background: #040810;
    margin-top: 0;
    opacity: 1;
  }

  /* Text must be visible immediately on mobile — no stagger/scroll reveal */
  .glass-stagger {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .glass-title {
    font-size: 2.2rem;
  }
  
  .glass-description {
    font-size: 1.05rem;
  }
  
  .player-top-bar {
    padding: 20px;
  }
  
  .player-bottom-bar {
    padding: 0 20px 20px;
  }

  /* Mobile close button — easily reachable */
  .expanded-close-btn {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.25);
  }

  /* ── Mobile simulated fullscreen (iOS can't FS iframes) ── */
  #project-expanded-view.is-active.is-fullscreen .expanded-media-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    z-index: 10;
  }
  #project-expanded-view.is-active.is-fullscreen .expanded-media-layer iframe,
  #project-expanded-view.is-active.is-fullscreen #yt-player-target {
    min-width: 177.77vh !important;
    min-height: 100vh !important;
    width: 100vw !important;
    height: 56.25vw !important;
    top: 50% !important; left: 50% !important;
    transform: translate(-50%, -50%) !important;
    position: absolute !important;
  }
  #project-expanded-view.is-active.is-fullscreen .expanded-glass-layer {
    display: none;
  }
  #project-expanded-view.is-active.is-fullscreen .custom-player-ui {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 100vh;
  }

  /* ── Native YouTube controls on mobile — iframe must receive touches ── */
  #project-expanded-view.is-active .expanded-media-layer iframe,
  #project-expanded-view.is-active #yt-player-target {
    pointer-events: auto !important;
  }

  .modal-inner {
    grid-template-columns: 1fr;
  }

  .modal-visual {
    min-height: 260px;
    max-height: 300px;
  }

  .modal-content {
    padding: 32px 24px;
  }

  .modal-meta-grid {
    grid-template-columns: 1fr;
  }

  .nav-pill {
    width: calc(100% - 24px);
    padding: 0 8px 0 14px;
  }

  .nav-links {
    position: fixed;
    top: 0;
    right: -100%;
    width: min(320px, 85vw);
    height: 100vh;
    background: rgba(6,18,11,0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid rgba(160,120,40,0.2);
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 80px 32px 32px;
    transition: right var(--t-slow) var(--ease-cinematic);
    box-shadow: -10px 0 60px rgba(0,0,0,0.6);
    gap: 8px;
    border-radius: 0;
  }

  #site-nav.nav-open .nav-links {
    right: 0;
  }

  .nav-links a {
    font-size: 1.1rem;
    letter-spacing: 0.12em;
    width: 100%;
    padding: 10px 16px;
    border-radius: 8px;
  }

  .nav-links li:last-child a {
    border-radius: 8px;
  }

  .nav-toggle {
    display: flex;
  }

  .hero-description {
    display: none;
  }

  #hero {
    height: 65vh;
  }

  /* ── Scroll-snap carousel track ── */
  .row-track {
    --hover-shift: 0px;
    --hover-shift-edge: 0px;
    padding: 16px var(--page-pad);
    scroll-snap-type: x mandatory;
    scroll-padding-left: var(--page-pad);
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Viewport-relative card sizing ── */
  .project-card {
    flex: 0 0 calc(85vw);
    scroll-snap-align: start;
  }

  .project-card:hover,
  .row-track:has(.project-card:hover) .project-card:hover {
    transform: none !important;
    z-index: var(--z-base) !important;
    transition: none !important;
  }

  /* ── Hide arrow buttons — touch users swipe ── */
  .row-arrow {
    display: none !important;
  }

  /* ── Reduce fade edges on mobile ── */
  .row-track-wrapper::before,
  .row-track-wrapper::after {
    width: 28px;
  }

  /* ── Always-visible card title on mobile ── */
  .card-image::after {
    opacity: 1 !important;
    height: 70%;
    background: linear-gradient(to top, rgba(2,10,6,0.97) 0%, rgba(2,10,6,0.75) 40%, rgba(2,10,6,0.3) 65%, transparent 100%);
  }

  .card-info {
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-top: none;
    padding: 14px 16px 14px;
  }

  .card-title {
    filter: none !important;
    font-size: 0.95rem;
    font-weight: 600;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9), 0 0 16px rgba(0,0,0,0.6);
  }

  .card-meta {
    font-size: 0.65rem;
    margin-top: 2px;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  }

  .card-tagline {
    display: none;
  }

  .card-play {
    opacity: 0 !important;
  }

  /* Disable ALL hover effects on mobile — touch has no hover */
  .project-card:hover .card-image {
    box-shadow: var(--shadow-card) !important;
  }
  .project-card:hover .card-image img {
    transform: none !important;
    filter: none !important;
  }
  .project-card:hover .card-play {
    opacity: 0 !important;
  }
}

@media (max-width: 600px) {
  :root {
    --page-pad: 16px;
    --row-pad-v: 16px;
  }

  .row-track {
    --hover-shift: 0px;
    --hover-shift-edge: 0px;
    scroll-padding-left: 16px;
  }

  .project-card {
    flex: 0 0 calc(88vw);
  }

  .project-card:hover,
  .row-track:has(.project-card:hover) .project-card:hover {
    transform: none !important;
    z-index: var(--z-base) !important;
    transition: none !important;
  }

  .hero-title {
    font-size: 1.8rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  #site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Landscape Mode overrides for expanded view on mobile */
@media (orientation: landscape) and (max-width: 900px), (max-height: 500px) {

  /* Override the portrait flex-column — go back to block/fullscreen */
  #project-expanded-view.is-active {
    display: block;
    overflow: hidden;
  }

  /* Media layer: fill the viewport like desktop fullscreen */
  #project-expanded-view.is-active .expanded-media-layer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: unset !important;
    flex-shrink: unset;
    z-index: 10;
  }

  /* Video / iframe: letterbox correctly in landscape */
  #project-expanded-view.is-active .expanded-media-layer iframe,
  #project-expanded-view.is-active #yt-player-target {
    min-width: 177.77vh !important;
    min-height: 100vh !important;
    width: 100vw !important;
    height: 56.25vw !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    position: absolute !important;
  }

  /* Hero image: fill the viewport */
  #project-expanded-view.is-active .expanded-media-layer img {
    min-width: unset !important;
    min-height: unset !important;
    width: 100% !important;
    height: 100% !important;
    top: 0 !important;
    left: 0 !important;
    transform: none !important;
    position: absolute !important;
    object-fit: cover;
  }

  /* Inner media wrapper must not be disrupted either */
  #project-expanded-view.is-active .expanded-media-inner {
    transform: none !important;
    opacity: 1 !important;
  }

  /* Hide glass/description layer — video is fullscreen in landscape */
  #project-expanded-view.is-active .expanded-glass-layer {
    display: none !important;
  }

  /* Player UI: fixed fullscreen overlay */
  #project-expanded-view.is-active .custom-player-ui {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 100vh !important;
  }

  #project-expanded-view.is-active .glass-content-box {
    opacity: 0 !important;
    pointer-events: none !important;
  }
  
  .expanded-close-btn.is-visible {
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.2);
  }
}
