/* Home only: header + hero + filing share one viewport, not a viewport each.
   Do not hide document overflow: every link must fit, and other routes still scroll. */
.af-public-shell:has(> .af-home) {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100svh;
  height: 100dvh;
}
.af-public-shell:has(> .af-home) > .af-public-header,
.af-public-shell:has(> .af-home) > .af-public-footer { flex: none; }
.af-public-shell:has(> .af-home) > .af-public-footer {
  gap: 3px 18px;
  padding: 8px 16px max(8px, env(safe-area-inset-bottom));
  font-size: 11px;
  line-height: 20px;
}
.af-public-shell:has(> .af-home) > .af-home {
  flex: 1;
  min-height: 0;
  min-width: 0;
  container-type: size;
}
.af-home > .af-home-hero {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding-block: 20px;
}
.af-home-hero > .af-home-story {
  width: 100%;
  max-width: min(640px, calc(100cqh - 140px));
  margin-inline: auto;
}
.af-home .af-story-playback { z-index: 3; }
.af-home .af-story-stage-label { z-index: 3; pointer-events: none; }
/* Preserve the unreleased product route, but never append a second home page. */
.af-home > [data-testid="public-product-templates"] { display: none; }

@media (max-height: 600px) and (min-width: 700px) {
  .af-public-shell:has(> .af-home) .af-public-header-inner { min-height: 54px; }
  .af-home > .af-home-hero { padding-block: 10px; gap: 24px; }
  .af-home .af-home-hero-copy { padding: 0; }
  .af-home .af-home-hero h1 { font-size: clamp(30px, 4vw, 42px); }
  .af-home .af-home-entry-actions { margin-top: 18px; }
  .af-home .af-home-entry { min-height: 88px; padding: 14px; gap: 10px; }
  .af-home .af-home-entry-title { font-size: 14px; }
  .af-home-hero > .af-home-story { max-width: 460px; height: 100%; min-height: 0; }
  .af-home-hero > .af-home-story > figure { height: 100%; max-width: none; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
  .af-home .af-story-stage { aspect-ratio: auto; min-height: 0; }
  .af-home .af-story-stage-label { top: 10px; left: 12px; padding: 5px 8px; }
  .af-home .af-story-idea { padding: 45px 12% 45px; }
  .af-home .af-story-idea p { font-size: 23px; line-height: 1.4; margin: 6px 0; }
  .af-home .af-story-prompt-label, .af-home .af-story-prompt-line { display: none; }
  .af-home .af-story-playback { bottom: 8px; right: 10px; }
  .af-home .af-story-steps { gap: 8px; margin-top: 6px; }
  .af-home .af-story-steps button { padding-top: 8px; }
  .af-home .af-story-note { margin-top: 0; }
  .af-home .af-story-photo img { object-fit: contain; }
}

@media (max-width: 699px) {
  .af-public-shell:has(> .af-home) .af-public-header-inner { min-height: 54px; padding-inline: 20px; }
  .af-public-shell:has(> .af-home) > .af-public-footer { gap: 2px 14px; padding-top: 6px; padding-bottom: max(6px, env(safe-area-inset-bottom)); font-size: 10px; }
  .af-home > .af-home-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    align-items: stretch;
    gap: 14px;
    padding: 10px 20px 12px;
  }
  .af-home .af-home-hero-copy { padding: 0; }
  .af-home .af-home-hero h1 { max-width: none; font-size: clamp(30px, 8.5vw, 42px); }
  .af-home .af-home-entry-actions { margin-top: 14px; gap: 10px; }
  .af-home .af-home-entry { min-height: 78px; padding: 12px 14px; gap: 8px; border-radius: 14px; }
  .af-home .af-home-entry-top > svg:first-child { width: 20px; height: 20px; }
  .af-home .af-home-entry-title { font-size: 14px; }
  .af-home-hero > .af-home-story { max-width: 460px; height: 100%; min-height: 0; }
  .af-home-hero > .af-home-story > figure { height: 100%; max-width: none; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
  .af-home .af-story-stage { aspect-ratio: auto; min-height: 0; }
  .af-home .af-story-photo img { object-fit: contain; }
  .af-home .af-story-steps { gap: 8px; margin-top: 8px; }
  .af-home .af-story-steps button { padding-top: 8px; }
  .af-home .af-story-note { margin-top: 0; }
}

@media (max-width: 699px) and (max-height: 640px) {
  .af-home > .af-home-hero { gap: 10px; padding-block: 6px 8px; }
  .af-home .af-home-hero h1 { font-size: 30px; }
  .af-home .af-home-entry-actions { margin-top: 10px; }
  .af-home .af-home-entry { min-height: 72px; padding: 10px 12px; }
  .af-home .af-story-stage-label { top: 8px; left: 10px; padding: 5px 7px; }
  .af-home .af-story-playback { top: 8px; bottom: auto; right: 8px; }
  .af-home .af-story-idea { padding: 54px 16px 8px; }
  .af-home .af-story-idea p { font-size: 20px; line-height: 1.35; margin: 0; }
  .af-home .af-story-prompt-label, .af-home .af-story-prompt-line { display: none; }
}

/* Very short / zoomed mobile screens prioritise navigation and legal links.
   The optional demo is omitted rather than clipping controls or locking scroll. */
@media (max-width: 699px) and (max-height: 520px) {
  .af-home > .af-home-hero { grid-template-rows: minmax(0, 1fr); align-items: center; }
  .af-home-hero > .af-home-story { display: none; }
}

@media (max-width: 359px) {
  .af-public-shell:has(> .af-home) .af-public-header-inner { gap: 8px; }
  /* Beta is still stated in the footer; leave room for the full language selector. */
  .af-public-shell:has(> .af-home) .af-public-header .af-public-beta { display: none; }
}
