:root { --mobile-gutter: 20px; }

.mobile-menu-button,
.mobile-header-cv,
.mobile-menu-backdrop,
.storyboard-mobile-controls,
.mobile-media-action,
.mobile-embed-preview { display: none; }

body.mobile-menu-open,
body.media-lightbox-open { overflow: hidden; }

.media-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 64px 20px 24px;
  background: rgba(12, 12, 11, .94);
}
.media-lightbox[hidden] { display: none; }
.media-lightbox img { width: auto; max-width: 100%; height: auto; max-height: calc(100dvh - 90px); object-fit: contain; }
.media-lightbox-close {
  position: absolute; top: 12px; right: 14px; width: 48px; height: 48px;
  border: 1px solid rgba(255,255,255,.55); background: #111; color: #fff;
  font: 28px/1 Arial, sans-serif; cursor: pointer;
}
.case-nav ~ main figure img { cursor: zoom-in; }

@media (max-width: 820px) {
  html { scroll-padding-top: calc(64px + env(safe-area-inset-top)); }
  html.home-reel { scroll-snap-type: none; }
  body { min-width: 320px; font-size: 16px; line-height: 1.65; }
  .shell, .case-shell { width: calc(100% - (var(--mobile-gutter) * 2)); }

  .a-header,
  .case-nav {
    position: sticky; top: 0; z-index: 100;
    width: 100%; min-height: calc(64px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) var(--mobile-gutter) 0;
    margin: 0; gap: 10px;
  }
  .a-header .wordmark,
  .case-nav > a:first-child {
    min-width: 0; margin-right: auto; overflow: hidden;
    font-size: 13px; white-space: nowrap; text-overflow: ellipsis;
  }
  .a-header > nav,
  .case-nav-links {
    position: fixed; inset: calc(64px + env(safe-area-inset-top)) 0 0;
    z-index: 102; display: flex !important; flex-direction: column; align-items: stretch;
    gap: 0; padding: 24px var(--mobile-gutter) calc(28px + env(safe-area-inset-bottom));
    background: var(--paper, #f4f4f0); color: var(--ink, #333);
    opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
    overflow-y: auto;
  }
  .mobile-menu-open .a-header > nav,
  .mobile-menu-open .case-nav-links { opacity: 1; visibility: visible; transform: none; }
  .a-header > nav a,
  .case-nav-links a {
    display: flex !important; align-items: center; min-height: 56px;
    border-bottom: 1px solid rgba(51,51,51,.25); font-size: 20px;
  }
  .mobile-header-cv,
  .mobile-menu-button {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    min-width: 48px; min-height: 48px; padding: 0 10px;
    border: 1px solid currentColor; background: transparent; color: inherit;
    font: 700 12px/1 Arial, sans-serif;
  }
  .mobile-header-cv { border: 0; }
  .mobile-menu-button span { display: block; width: 18px; height: 1px; background: currentColor; transition: transform 180ms ease; }
  .mobile-menu-button span + span { margin-top: 5px; }
  .mobile-menu-open .mobile-menu-button span:first-child { transform: translateY(3px) rotate(45deg); }
  .mobile-menu-open .mobile-menu-button span:last-child { transform: translateY(-3px) rotate(-45deg); }

  .portfolio-entry { min-height: 100dvh; overflow-y: auto; }
  .entry-frame { min-height: 100dvh; padding: max(24px, env(safe-area-inset-top)) var(--mobile-gutter) max(20px, env(safe-area-inset-bottom)); }
  .entry-main { display: block; }
  .entry-title { font-size: clamp(44px, 14vw, 68px); }
  .entry-statement-column { margin-top: 36px; }
  .entry-statement { font-size: 16px; line-height: 1.65; }
  .entry-bottomline { gap: 12px; }
  .entry-profile, .entry-enter { min-height: 48px; }

  .a-project-list { display: block; }
  .a-project {
    display: flex; flex-direction: column; min-height: 0 !important;
    padding-top: 36px; padding-bottom: 56px; scroll-snap-align: none;
  }
  .a-project-image { order: 1; }
  .a-project-copy { order: 2; min-height: 0 !important; padding-top: 24px; }
  .a-project-copy h2 { font-size: clamp(32px, 10vw, 40px); line-height: 1.04; }
  .a-project-copy > div > p { font-size: 16px; line-height: 1.65; }
  .a-project-actions { margin-top: 24px; }
  .a-project-actions a, .text-link { min-height: 48px; }
  .writing-section { min-height: 0 !important; padding: 56px var(--mobile-gutter) 72px; scroll-snap-align: none; }
  .writing-header { display: block; }
  .writing-header h2 { font-size: clamp(28px, 9vw, 38px); }
  .writing-list { grid-template-columns: 1fr !important; }
  .profile-narrative { padding-top: 48px; }
  .profile-narrative-intro h1 { font-size: clamp(36px, 11vw, 44px); }
  .profile-narrative-body { margin-top: 48px; }
  .profile-narrative-section { padding: 30px 0 38px; }
  .profile-narrative-section h2 { font-size: clamp(24px, 7vw, 28px); }
  .profile-narrative-section > p:not(.profile-narrative-index) { font-size: 16px; line-height: 1.7; text-align: left; }

  .case-hero { padding-top: 48px; }
  .case-title h1 { font-size: clamp(36px, 11vw, 48px); line-height: 1; }
  .case-title .cn { font-size: 16px; }
  .case-lead { margin: 24px 0 34px; font-size: 16px; line-height: 1.68; text-align: left; }
  .case-meta { display: block; }
  .case-meta div, .case-meta div + div {
    display: grid; grid-template-columns: 76px minmax(0,1fr); align-items: baseline;
    min-height: 0; padding: 14px 0; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .case-meta div:last-child { border-bottom: 0; }
  .case-meta dt { margin: 0; font-size: 11px; }
  .case-meta dd { font-size: 14px; line-height: 1.5; }
  .case-section { padding: 62px 0; }
  .section-heading, .section-heading.small { margin-bottom: 24px; font-size: clamp(24px, 7vw, 28px); line-height: 1.18; }
  .prose p { font-size: 16px; line-height: 1.7; text-align: left; }
  .media-grid.two, .media-grid.three { grid-template-columns: 1fr; }
  .media-grid figure img, .wide-media img { height: auto; aspect-ratio: auto; object-fit: contain; }
  .hero-media img { height: 100%; object-fit: cover; }
  .media-grid figcaption, .wide-media figcaption, .cat-asset-card figcaption { font-size: 13px; line-height: 1.55; }
  .quote-band .case-section, .cat .quote-band .case-section { min-height: 0; padding-top: 58px; padding-bottom: 58px; }
  .quote-band blockquote { font-size: clamp(24px, 7vw, 28px); }
  .case-next-inner { flex-wrap: wrap; gap: 24px; padding: 52px 0 calc(68px + env(safe-area-inset-bottom)); }
  .case-next-inner h2 { font-size: 28px; }
  .case-next-inner a { min-height: 48px; white-space: normal; }

  .scene-strip .cat-asset-viewport { overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior-inline: contain; touch-action: pan-x pan-y; }
  .scene-strip .cat-asset-track { gap: 12px; animation: none !important; transform: none !important; }
  .scene-strip .cat-asset-card { width: min(84vw, 420px); scroll-snap-align: start; }
  .storyboard-mobile-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
  .storyboard-mobile-controls button { width: 48px; height: 48px; border: 1px solid currentColor; background: transparent; color: inherit; font-size: 21px; }
  .storyboard-mobile-count { font-size: 13px; font-variant-numeric: tabular-nums; }

  .project-video { position: relative; }
  .project-video video { min-height: 190px; }
  .mobile-media-action {
    position: absolute; inset: 50% auto auto 50%; z-index: 2; display: inline-flex;
    align-items: center; justify-content: center; min-width: 56px; min-height: 56px;
    padding: 0 18px; border: 1px solid #fff; border-radius: 999px;
    background: rgba(0,0,0,.72); color: #fff; transform: translate(-50%,-50%);
    font: 700 13px/1 Arial,sans-serif;
  }
  .project-video.is-ready .mobile-media-action { display: none; }

  .online-platform-frame[data-desktop-src] { display: none; }
  .mobile-embed-preview {
    position: relative; display: grid; min-height: 220px; place-items: end start; padding: 20px;
    overflow: hidden; background: #e8e3d9; border-bottom: 1px solid var(--line);
  }
  .mobile-embed-preview img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; cursor: default; filter: saturate(.82); }
  .mobile-embed-preview::after { position: absolute; inset: 0; background: linear-gradient(180deg,rgba(0,0,0,.03),rgba(0,0,0,.72)); content: ""; }
  .mobile-embed-preview > div { position: relative; z-index: 1; color: #fff; }
  .mobile-embed-preview strong { display: block; max-width: 18ch; font-size: 24px; line-height: 1.08; }
  .mobile-embed-preview a { display: inline-flex; align-items: center; min-height: 48px; margin-top: 18px; font-weight: 700; text-decoration: underline; text-underline-offset: 4px; }
  .rules-embed { height: min(680px, 78dvh); }
  .rules-embed-frame.is-deferred { position: relative; display: grid; min-height: 220px; place-items: center; padding: 20px; }
  .rules-embed-frame.is-deferred .rules-embed { display: none; }
}

@media (max-width: 380px) {
  :root { --mobile-gutter: 18px; }
  .mobile-header-cv { padding-inline: 6px; }
  .a-header .wordmark, .case-nav > a:first-child { max-width: 45vw; }
}

@media (max-width: 900px) and (orientation: landscape) {
  .portfolio-entry, .entry-frame { min-height: 100dvh; }
  .entry-frame { padding-top: 18px; padding-bottom: 18px; }
  .entry-title { font-size: clamp(34px, 8vw, 54px); }
  .entry-statement-column { margin-top: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .scene-strip .cat-asset-track { animation: none !important; transform: none !important; }
}
