/* Portrait reading edition: readable flow; shared photo crops are in photo-framing.css. */
@media screen and (max-width: 900px) and (orientation: portrait) {
  :root { --deck-controls-height: 104px; }
  html { height: auto !important; overflow: auto !important; scroll-behavior: smooth; }
  body { height: auto !important; overflow: visible !important; }
  #stage { display: block; height: auto; width: 100%; max-width: none; }
  #toolbar, .controls-toggle { display: none !important; }
  #stage > .frame.v2, body.reference-open #stage > .frame.backup { display: block !important; }
  #stage > .frame.backup { display: none !important; }
  #stage > .frame {
    width: 100% !important; aspect-ratio: auto !important;
    height: auto !important; min-height: 100svh;
    overflow: visible;
    scroll-margin-top: 0;
  }
  #stage .v-slide, #stage .slide {
    width: 100% !important; height: auto !important; min-height: 100svh;
    transform: none !important; padding: 32px 24px 48px;
    overflow: visible; display: flex; flex-direction: column; gap: 20px;
  }
  #stage .v-slide h1 { font-size: 36px; line-height: 1.06; }
  #stage .v-slide h2 { font-size: 28px; line-height: 1.08; }
  #stage .v-slide h3 { font-size: 19px; line-height: 1.2; }
  #stage .v-slide p { font-size: 16px !important; line-height: 1.45; max-width: none; }
  #stage .v-slide h2 br { display: none; }
  #stage .v-slide h2 br::after { content: ' '; }
  #stage .v-slide header { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin: 0; }
  #stage .v-slide header > p { max-width: none; }
  #stage .v-slide .v-small, #stage .v-slide figcaption { font-size: 13px !important; line-height: 1.4; }
  #stage .v-slide .v-kicker { font-size: 12px !important; margin: 0; }
  #stage .v-slide .v-number { font-size: 40px; line-height: 1.05; }
  #stage .brand-lockup { width: 176px !important; height: 54px !important; }
  #stage .v-slide .v-photo {
    height: auto !important; min-height: 0; overflow: visible; flex: none;
    display: flex; flex-direction: column; gap: 8px; margin: 0;
  }
  #stage .v-slide .v-photo img {
    width: 100%; height: auto; max-height: 245px; flex: none;
    object-fit: contain !important; object-position: center !important;
  }
  #stage .v-slide .v-photo figcaption { padding: 0; min-height: 0; }
  #stage .v-slide .v-folio { display: none; }
  #stage .v-cover-copy, #stage .v-turn-copy, #stage .v-london-copy, #stage .v-archive-copy {
    position: static; padding: 0; gap: 18px; display: flex; flex-direction: column; justify-content: flex-start;
  }
  #stage .v-cover { gap: 24px; }
  #stage .v-cover h1 { margin: 2px 0 0; }
  #stage .v-cover-copy > div:last-child { position: static; width: auto; height: auto; padding: 0; background: none; }
  #stage .v-cover .v-small { margin: 0; font-size: 15px !important; }
  #stage .v-cover > .v-photo { margin-top: auto; }
  #stage .v-cover > .v-photo img { max-height: 360px; }
  #stage .v-cover::after { left: 24px; bottom: 28px; width: 40px; height: 2px; }
  #stage .v-loss-layout, #stage .v-method-body, #stage .v-evidence-body, #stage .v-saffuriya-body {
    display: flex; flex-direction: column; height: auto; gap: 20px;
  }
  #stage .v-loss-pair { gap: 12px; }
  #stage .v-loss-pair .v-photo img { height: 145px; }
  #stage .v-loss aside { gap: 12px; }
  #stage .v-loss .v-threat { padding-top: 12px; margin-top: 0; }
  #stage .v-method-copy, #stage .v-evidence-list { gap: 12px; }
  #stage .v-process { grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 16px; margin-top: 0; }
  #stage .v-process b { font-size: 15px; }
  #stage .v-process p { font-size: 14px !important; margin-top: 6px; }
  #stage .v-button { font-size: 15px; padding: 11px 14px; min-height: 44px; }
  #stage .v-archive h2 { margin: 0; }
  #stage .v-evidence-list > div { padding-top: 12px; }
  #stage .v-evidence-list p { margin-top: 6px; }
  #stage .v-channels { grid-template-columns: 1fr 1fr; gap: 20px 16px; padding: 16px 0; }
  #stage .v-channels p { margin-top: 8px; font-size: 15px !important; }
  #stage .v-reach-metrics { grid-template-columns: 1fr; gap: 18px; padding-top: 16px; }
  #stage .v-reach-metrics > div { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: center; }
  #stage .v-reach-metrics strong { font-size: 34px; }
  #stage .v-reach-metrics p { margin: 0; font-size: 15px !important; }
  #stage .v-metric-note { margin: 0; font-size: 13px !important; }
  #stage .v-community-photos { grid-template-columns: 1fr 1fr; gap: 18px 12px; height: auto; }
  #stage .v-community-photos img { height: 140px; }
  #stage .v-community-line, #stage .v-output-line, #stage .v-nazareth-line { margin: 0; }
  #stage .v-saffuriya-body > div { gap: 14px; }
  #stage .v-saffuriya-body .v-photo { flex: none; }
  #stage .v-saffuriya-body .v-photo img { max-height: 210px; }
  #stage .v-output-images, #stage .v-nazareth-images { display: flex; flex-direction: column; gap: 20px; height: auto; }
  #stage .v-output-images .v-photo img, #stage .v-nazareth-images .v-photo img { max-height: 210px; }
  #stage .v-nazareth header p { margin-top: 12px; }
  #stage .v-close { justify-content: flex-start; gap: 28px; }
  #stage .v-close .v-brand { padding: 0; }
  #stage .v-close h2 { font-size: 36px; margin: 0; }
  #stage .v-close-bottom { display: flex; flex-direction: column; align-items: stretch; gap: 22px; padding-top: 20px; margin: 0; }
  #stage .v-close-bottom h3 { font-size: 23px; }

  /* The reference slides retain their original grouping and all source material. */
  #stage .slide :is(div, header, aside, figure) {
    position: static !important; width: auto !important; height: auto !important;
    max-width: none !important; min-height: 0 !important; margin: 0 !important;
    padding: 0 !important; overflow: visible; flex: none;
    display: flex; flex-direction: column; gap: 16px;
  }
  #stage .slide :is(h1,h2,h3,p,span,strong,b,a) {
    position: static !important; width: auto !important; height: auto !important;
    max-width: 100% !important; margin: 0 !important; padding: 0 !important;
  }
  #stage .slide h1 { font-size: 36px !important; line-height: 1.08; }
  #stage .slide h2 { font-size: 28px !important; line-height: 1.1; }
  #stage .slide h3 { font-size: 19px !important; line-height: 1.25; }
  #stage .slide p, #stage .slide a, #stage .slide span, #stage .slide b { font-size: 16px !important; line-height: 1.45; }
  #stage .slide strong, #stage .slide .metric, #stage .slide .duration { font-size: 36px !important; line-height: 1.1; }
  #stage .slide .eyebrow, #stage .slide .image-label, #stage .slide .signature { font-size: 13px !important; }
  #stage .slide :is(h1,h2,h3) br { display: none; }
  #stage .slide img { width: 100%; height: auto; max-height: 300px; object-fit: contain !important; object-position: center !important; }
  #stage .slide .brand-accessible { position: absolute !important; width: 1px !important; height: 1px !important; }
  #stage .slide .folio { display: none; }
  #stage .slide :is(.heritage-collage,.comparison-pair,.people,.jaffa-images,.school-photos,.village-strip,.taybe-photos,.taybe-encounter-images,.london-pair,.spreads) {
    display: grid; grid-template-columns: 1fr 1fr !important; grid-template-rows: auto !important; gap: 12px;
  }
  #stage .slide :is(.heritage-collage,.jaffa-images,.taybe-encounter-images) > * { grid-column: auto !important; grid-row: auto !important; }
  #stage .slide :is(.people,.heritage-collage,.village-strip) img { max-height: 150px; }
  #stage .slide .portrait { width: 100% !important; }
  #stage .slide :is(.workflow-stages,.evidence,.reach-channels,.community-settings,.key) { display: grid; grid-template-columns: 1fr 1fr !important; gap: 20px 16px; }
  #stage .slide .partner-logo { max-width: 120px !important; }
  #stage .slide .archive-link { padding: 12px !important; min-height: 44px; }
  #stage .slide.cover::after { left: 24px; bottom: 28px; width: 40px; height: 2px; }
  #toolbar { height: 104px; padding: 6px 12px; flex-wrap: wrap; justify-content: center; gap: 4px; }
  #toolbar > div { justify-content: center; gap: 8px; }
  #toolbar button { font-size: 14px; padding: 8px 10px; }
  #position { min-width: 44px; }
  .controls-toggle { right: max(12px,env(safe-area-inset-right)); }
  dialog { padding: 20px; }
  dialog h2 { font-size: 24px; }
  dialog .index { grid-template-columns: 1fr; }
  .extra-grid { grid-template-columns: 1fr; }
  .extra-grid .v-photo { height: auto; }
  .extra-grid img { height: auto; max-height: 360px; object-fit: contain; }
}
#stage img[data-media]:not(.brand-lockup):not(.partner-logo) { cursor: zoom-in; }
#stage img[data-media]:focus-visible { outline: 3px solid #F28A50; outline-offset: 3px; }
@media screen and (max-width: 360px) and (orientation: portrait) {
  #stage .v-cover { padding: 20px 20px 44px; gap: 18px; }
  #stage .v-cover-copy { gap: 16px; }
  #stage .v-cover h1 { font-size: 32px; }
  #stage .v-cover > .v-photo img { max-height: 180px; }
}

.mobile-reference-entry { display: none; }
@media screen and (max-width: 900px) and (orientation: portrait) {
  .mobile-reference-entry { display: block; padding: 32px 24px 48px; background: #FAFAF8; color: #181A18; }
  .reference-disclosure { display: flex; align-items: center; justify-content: space-between; width: 100%; border: 0; border-top: 1px solid #626660; padding: 24px 0 0; background: transparent; color: inherit; text-align: left; font: 600 18px/1.3 var(--sans); cursor: pointer; }
  .reference-disclosure span { font-size: 24px; }
  .reference-disclosure:focus-visible { outline: 3px solid #A13F16; outline-offset: 5px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto !important; } }

/* A quiet reading-position indicator, independent of navigation controls. */
.story-progress { position: fixed; inset: 0 0 auto; height: 3px; z-index: 100; pointer-events: none; }
.story-progress-fill { width: 100%; height: 100%; background: #E66A2C; transform: scaleX(0); transform-origin: left; transition: transform 100ms linear; }
@media (prefers-reduced-motion: reduce) { .story-progress-fill { transition: none; } }
@media print { .story-progress { display: none; } }

/* Landscape phones use the full widescreen canvas without mobile controls. */
@media screen and (orientation: landscape) and (max-height: 600px) and (max-width: 1100px) {
  body { --deck-controls-height: 0px; }
  #toolbar, .controls-toggle { display: none !important; }
  #stage { height: 100dvh; }
  #stage > .frame { width: min(100vw,calc(100dvh * 16 / 9)) !important; }
}

/* Keep the two moving canvases inside the presentation viewport. */
#stage.page-transition { position: relative; overflow: hidden; }
#stage.page-transition > .frame.transition-outgoing {
  display: block !important; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%,-50%); pointer-events: none;
}
