/* Opt-in mobile presentation of the accepted film, using the existing mobile source.
   Match the engine's narrow-or-coarse detection. Portrait screens crop the sides to
   make the film larger; landscape screens and wide mouse desktops are unchanged. */
@media (max-width: 860px), (hover: none) and (pointer: coarse) {
  .hf-mobile-film.sw-root {
    --hf-film-top: calc(80px + env(safe-area-inset-top));
    --hf-film-nav-clearance: calc(84px + env(safe-area-inset-bottom));
    --hf-film-width: min(704px, calc(100vw - 32px), calc((100vh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 210px) * 16 / 9));
    --hf-film-width: min(704px, calc(100vw - 32px), calc((100svh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 210px) * 16 / 9));
    --hf-film-height: calc(var(--hf-film-width) * 9 / 16);
    --hf-film-copy-top: calc(var(--hf-film-top) + var(--hf-film-height) + 16px);
  }

  .hf-mobile-film .sw-topbar {
    box-sizing: border-box;
    min-height: calc(64px + env(safe-area-inset-top));
    padding: calc(12px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
    gap: 10px;
    background: var(--sw-bg);
    border-bottom: 1px solid color-mix(in srgb, var(--sw-ink) 10%, transparent);
  }

  .hf-mobile-film .sw-brand { gap: 8px; flex-shrink: 0; }
  .hf-mobile-film .sw-brand__logo { width: 135px; height: 32px; }

  .hf-mobile-film .sw-stage {
    inset: auto;
    top: var(--hf-film-top);
    left: 50%;
    width: var(--hf-film-width);
    height: var(--hf-film-height);
    transform: translateX(-50%);
    background: var(--sw-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 24px color-mix(in srgb, var(--sw-ink) 8%, transparent);
    /* The frame and the copy leave with the last scene, never as an empty card. */
    opacity: var(--sw-shown, 1);
  }

  .hf-mobile-film .sw-scene__video,
  .hf-mobile-film .sw-scene__still {
    object-fit: contain;
    object-position: center;
    transform: none !important;
  }

  .hf-mobile-film .sw-copylayer {
    background: var(--sw-bg);
    top: var(--hf-film-copy-top);
    bottom: var(--hf-film-nav-clearance);
    opacity: var(--sw-shown, 1);
  }
  .hf-mobile-film .sw-copylayer::before { display: none; }
  .hf-mobile-film .sw-copy {
    box-sizing: border-box;
    top: 0;
    bottom: 0 !important;
    left: max(16px, env(safe-area-inset-left));
    right: max(16px, env(safe-area-inset-right));
    width: auto;
    max-width: 704px;
    margin-inline: auto;
    padding: 2px 0 12px;
    transform: none !important;
    /* Short screens scroll overflowing copy in place; a swipe that the copy cannot
       consume (no overflow, or already at its end) must chain to the page, which is
       what scrubs the film. overscroll-behavior: contain would block that even on a
       copy block without overflow. */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    background: var(--sw-bg);
  }

  .hf-mobile-film .sw-copy__num { font-size: .66rem; letter-spacing: .08em; }
  .hf-mobile-film .sw-copy__eyebrow { margin-top: 10px; font-size: .7rem; letter-spacing: .08em; }
  .hf-mobile-film .sw-copy__title {
    margin-top: 8px;
    font-size: clamp(1.45rem, 5.8vw, 2.15rem);
    line-height: 1.16;
    text-shadow: none;
    text-wrap: balance;
  }
  .hf-mobile-film .sw-copy__body {
    margin: 12px 0 0;
    max-width: none;
    font-size: clamp(.9rem, 2.8vw, 1.05rem);
    line-height: 1.55;
    text-shadow: none;
  }
  .hf-mobile-film .sw-copy__tags { margin-top: 16px; }
  .hf-mobile-film .sw-copy__cta { margin-top: 18px; }
  .hf-mobile-film .sw-route,
  .hf-mobile-film .sw-hint,
  .hf-mobile-film .sw-particles { display: none; }
}

/* Fill more of a portrait screen with a centred, up-to-square crop. Retain the
   existing width cap and copy allowance on short screens, so only the sides crop
   and neither the text nor the fixed navigation is covered. */
@media (max-width: 860px) and (orientation: portrait),
       (hover: none) and (pointer: coarse) and (orientation: portrait) {
  .hf-mobile-film.sw-root {
    --hf-film-height: min(var(--hf-film-width), calc(100vh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 210px));
    --hf-film-height: min(var(--hf-film-width), calc(100svh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 210px));
  }
  .hf-mobile-film .sw-scene__video,
  .hf-mobile-film .sw-scene__still { object-fit: cover; }
}

/* A short landscape viewport cannot fit a readable copy block beneath a wide
   film. Keep both unobstructed in two columns, between the fixed navigation. */
@media (max-width: 860px) and (max-height: 500px) and (orientation: landscape),
       (hover: none) and (pointer: coarse) and (max-height: 500px) and (orientation: landscape) {
  .hf-mobile-film.sw-root {
    --hf-film-top: calc(76px + env(safe-area-inset-top));
    --hf-film-nav-clearance: calc(76px + env(safe-area-inset-bottom));
    --hf-film-width: min(calc(48vw - 24px), calc((100vh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 8px) * 16 / 9));
    --hf-film-width: min(calc(48vw - 24px), calc((100svh - var(--hf-film-top) - var(--hf-film-nav-clearance) - 8px) * 16 / 9));
  }
  .hf-mobile-film .sw-stage {
    left: max(16px, env(safe-area-inset-left));
    transform: none;
  }
  .hf-mobile-film .sw-copylayer {
    top: var(--hf-film-top);
    left: calc(max(16px, env(safe-area-inset-left)) + var(--hf-film-width) + 16px);
    right: 0;
  }
  .hf-mobile-film .sw-copy { left: 0; }
  .hf-mobile-film .sw-copy__eyebrow { margin-top: 6px; }
  .hf-mobile-film .sw-copy__title { font-size: clamp(1.25rem, 3.6vw, 1.65rem); }
  .hf-mobile-film .sw-copy__body { font-size: .9rem; margin-top: 10px; }
}
