@media (max-width: 820px) {
  .float-foot {
    inset-inline: 0;
    width: max-content;
    max-width: calc(100% - 44px);
    margin-inline: auto;
    text-align: center;
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  .hero .scene > :is(img,video) { object-position: 16% 50%; }

  #about {
    --terrace-height: max(740px, 100svh);
    --terrace-lift: clamp(32px, 5.5svh, 56px);
    --film-preview-height: clamp(150px, 43vw, 268px);
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: minmax(0, 1fr);
    min-height: var(--terrace-height);
    padding: clamp(76px, 12svh, 116px) 24px 44px;
    background: #382018;
    text-align: center;
  }

  #about .about-visual {
    position: absolute;
    inset: 0 0 auto;
    height: var(--terrace-height);
    max-height: none;
    aspect-ratio: auto;
    z-index: -1;
  }

  #about .about-visual > :is(img,video) {
    object-position: 57% 100%;
    transform: translateY(calc(-1 * var(--terrace-lift))) scale(1.25);
    transform-origin: center bottom;
  }

  #about .about-visual::after {
    display: block;
    inset: 0;
    height: auto;
    background: linear-gradient(180deg, #efb68f66, #f7c99dbf 26%, transparent 46%, transparent 73%, #382018 calc(100% - var(--terrace-lift)));
  }

  #about :is(.about-copy,.about-steps) { display: contents; }
  #about .story-step {
    display: grid;
    grid-template-rows: auto auto auto minmax(190px, 1fr) auto;
    grid-area: 2 / 1;
    align-self: stretch;
  }

  #about .about-eyebrow { grid-row: 1; }
  #about .step-kicker { grid-row: 1; }
  #about .step-title { grid-row: 2; }
  #about .step-sub {
    grid-row: 3;
    max-width: 31ch;
    margin: 14px auto 0;
  }

  #about .about-film {
    grid-row: 5;
    align-self: end;
    justify-self: center;
    width: min(100%, 620px);
    margin: 0;
  }

  #about .about-film video:not([controls]) {
    height: var(--film-preview-height);
    object-fit: cover;
    object-position: center 30%;
  }

  #about:has(.about-film video[controls]) {
    --film-playing-height: min(calc((100vw - 48px) * 2 / 3), 413.34px);
    min-height: calc(var(--terrace-height) + max(0px, var(--film-playing-height) - var(--film-preview-height)));
  }

  #about .about-film-play { top: calc(var(--film-preview-height) / 2); }
  #about .about-film-caption { margin: 8px 0 0; font-size: 12px; }
  #about .about-copy .about-film-caption { color: #fff1df; }
  #about .about-control { inset: auto 8px 10px auto; }

  #portfolio {
    --room-scene-height: clamp(356px, 62svh, 565px);
    --room-scene-top: clamp(123px, 18svh, 168px);
    background: #3b231d;
  }

  #portfolio::after {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: calc(var(--room-scene-top) + var(--room-scene-height) + 140px);
    background: url(../Indoor/Web-Portfolio-v1/portfolio-mobile-room.webp) center top / 100% 100% no-repeat;
    z-index: -3;
  }

  #portfolio .pf-stage {
    position: absolute;
    inset: var(--room-scene-top) 0 auto;
    height: var(--room-scene-height);
    aspect-ratio: auto;
    mask-image: linear-gradient(transparent, #000 15%, #000 82%, transparent);
  }

  #portfolio .pf-stage > :is(img,video) { object-position: 22% 58%; }
  #portfolio .pf-walk { object-position: 29% 58%; }

  #portfolio .pf-shade {
    display: block;
    height: calc(var(--room-scene-top) + var(--room-scene-height) + 65px);
    background: linear-gradient(#2b1715a6, #2b17154d 29%, transparent 45%, transparent 74%, #3b231d 100%);
  }

  #portfolio .pf-copy {
    width: auto;
    max-width: none;
    margin: 0;
    padding: clamp(76px, 11svh, 110px) 24px 0;
    text-shadow: 0 1px 7px #311a13b3;
  }

  #portfolio .pf-steps .step-sub { max-width: 33ch; }
  #portfolio .pf-works {
    margin-top: calc(var(--room-scene-top) + var(--room-scene-height) - clamp(190px, 27svh, 230px));
  }
  #portfolio .pf-motion { inset: calc(var(--room-scene-top) + var(--room-scene-height) - 34px) 12px auto auto; }

  #contact {
    --contact-height: max(690px, 100svh);
    min-height: var(--contact-height);
    background: #36231e;
  }

  #contact .contact-visual {
    position: absolute;
    inset: 0;
    max-height: none;
    aspect-ratio: auto;
    z-index: -2;
    background: url(../Contact/Web-Contact-v1/contact-mobile-room.webp) center / 100% 100% no-repeat;
  }

  #contact .contact-visual > :is(img,video) {
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
  }

  #contact .contact-shade {
    display: block;
    background: linear-gradient(#2c17159c, transparent 40%, transparent 66%, #2a1b19cc);
  }

  #contact .contact-intro {
    margin: clamp(82px, 12svh, 116px) 24px 0;
    text-shadow: 0 1px 7px #301a19a8;
  }

  #contact .contact-bar {
    top: auto;
    bottom: max(48px, env(safe-area-inset-bottom));
  }

  #contact .contact-control { inset: auto 12px 12px auto; }
}

@media not all and (max-width: 820px) {
  .about-film-caption { display: none; }
}

@media (max-width: 820px) and (orientation: landscape) {
  .about-film-caption { display: none; }
}

/* 25 Nov 2026 (Zen, checking on his iPhone in Chrome): fit each chapter to the real screen.
   On an iPhone, 100svh is the screen with the browser bars showing; once they shrink on scroll the screen is about
   100px taller, so a chapter sized 100svh left the next chapter peeking in below it (Chapter 03's top edge and
   eyebrow under Chapter 02, Chapter 04's top under Chapter 03, Chapter 05's floor above Chapter 06). 100lvh is the
   screen with the bars shrunk; with the bars showing, they simply cover the chapter's bottom edge. */
@supports (height: 100lvh) {
  @media (max-width: 820px) and (orientation: portrait) {
    #me, #nightfall { min-height: 100lvh; }
    #about { --terrace-height: max(740px, 100lvh); }
    #contact { --contact-height: max(690px, 100lvh); }
  }
}

/* 25 Nov 2026 (Zen, iPad held sideways: 'Bg video not filling full height? Because the browser top toolbar on and
   off? Same issue with the bottom of the TV scene'): a sideways iPad gets the laptop layout, whose chapters are 100svh
   (Safari's toolbar showing). Once the toolbar shrinks the screen is taller, so Chapter 05's floor showed above the
   Chapter 06 film and the next part peeked under the TV scene. On touch screens with the laptop layout the chapters
   are now 100lvh (toolbar shrunk), and the TV stage is sized to that height. The Intro stays 100svh (seen at the top,
   where the toolbar is out). Laptops and desktops have svh = lvh, so nothing changes there. */
@supports (height: 100lvh) {
  @media (min-width: 821px) and (aspect-ratio > 4/3) and (pointer: coarse) {
    #me, #nightfall, #portfolio { height: 100lvh; }
    #about, #contact { min-height: 100lvh; }
    .pf-stage { width: max(100%, calc(100lvh * 1.7741)); }
    .nf-departure-extension::after { height: 100lvh; }
  }
}

/* 25 Nov 2026 (Zen, iPhone: 'When the bottom toolbar shows up, the mayonis space and meet mayonis text overlap'):
   Chapter 06 is 100lvh tall, so while the browser's bottom toolbar is showing it covers the chapter's bottom edge and
   the words and links sank onto the fixed "Mayonis Space" line. 100lvh - 100dvh is the height the toolbars take
   right now (0 when they are tucked away), so the bar now stays 48px above whatever is visible. */
@supports (height: 100dvh) {
  @media (max-width: 820px) and (orientation: portrait) {
    #contact .contact-bar {
      bottom: calc(max(48px, env(safe-area-inset-bottom)) + 100lvh - 100dvh);
      transition: opacity .65s ease, transform .65s ease, bottom .35s ease;
    }
  }
}

@media (max-width: 820px) and (orientation: portrait) {
  /* Chapter 03's top edge met Chapter 02's dusk in a hard line, seen through the gaps of the sunset clouds and bare once
     they rise past it. While that edge is on screen, a band of Chapter 02's colour (#8a6a9c, the bottom of .me-bg) sits
     on top of Chapter 03's picture, under its words and the clouds, and fades as the edge nears the top of the screen
     (--about-veil, set by me-section.js; 0 when Chapter 03 is in place, so its resting look is unchanged). */
  #about .about-visual::after {
    background:
      linear-gradient(rgb(138 106 156 / var(--about-veil, 0)) 0 40px, rgb(138 106 156 / 0) clamp(200px, 32svh, 280px)),
      linear-gradient(180deg, #efb68f66, #f7c99dbf 26%, transparent 46%, transparent 73%, #382018 calc(100% - var(--terrace-lift)));
  }

  /* Chapter 05: the room picture runs 75px below its shade, which left a band of unshaded floor between the fade and
     the brown. The shade now reaches the picture's bottom; its upper stops stay where they were. */
  #portfolio .pf-shade {
    --shade-was: calc(var(--room-scene-top) + var(--room-scene-height) + 65px);
    height: calc(var(--room-scene-top) + var(--room-scene-height) + 140px);
    background: linear-gradient(#2b1715a6, #2b17154d calc(var(--shade-was) * .29), transparent calc(var(--shade-was) * .45), transparent calc(var(--shade-was) * .74), #3b231d 100%);
  }

  /* Chapter 06: the film fills the whole screen height (cover) instead of fitting inside it (contain). */
  #contact .contact-visual > :is(img,video) { object-fit: cover; }
}

/* 25 Nov 2026 (Zen, iPhone Safari on iOS 26: 'the top and bottom cut off ... can be full height?'): Safari's bottom
   toolbar is now see-through glass and the page shows behind it. The Intro was 100svh (the screen above the toolbar),
   so Chapter 02's clouds showed behind the toolbar on arrival. On phones the Intro is now 100lvh like the other
   chapters, so its own picture runs to the bottom of the screen, and its footer (the pause button) stays above the
   toolbar: 100lvh - 100dvh is the height the toolbars take right now. lvh does not change while the toolbar
   shrinks, so the 9 Nov rule (the Intro must not resize) still holds; --u keeps using svh, so the words do not move. */
@supports (height: 100lvh) and (height: 100dvh) {
  @media (max-width: 820px) and (orientation: portrait) {
    main.hero { height: 100lvh; }
    main.hero .footer { bottom: calc(7px + 100lvh - 100dvh); }
  }
}

/* 25 Nov 2026 (Zen, iPhone Safari on iOS 26: 'the bottom brown overlay, can start from real bottom?', 'the grass, can
   start from real bottom?'): the strip that continues a chapter behind Safari's glass toolbar. Built and switched on
   and off by the last script in Site/story-effects.js (the reason is written there). The strip has no height of its
   own, so nothing in the page moves. */
.edge-skirt { display: none; }
@media (max-width: 820px) and (orientation: portrait) {
  .edge-skirt { display: block; position: relative; z-index: 6; height: 0; pointer-events: none; }
  .edge-skirt > i { position: absolute; left: 0; right: 0; top: 0; height: 140px; overflow: hidden; opacity: 0; visibility: hidden; }
  .edge-skirt.is-on > i { opacity: 1; visibility: visible; transition: opacity .25s ease; }
  .edge-skirt-about > i { background: #382018; }
  .edge-skirt-intro > i > img { position: absolute; left: 0; top: 0; display: block; width: 100%; object-fit: cover; transform: scaleY(-1); }
}
