/* A compact transport leaves the slide visible while listening on a small screen. */
@media screen and (max-width: 899px),
       screen and (max-width: 1023px) and (orientation: landscape) and (max-height: 560px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  :root { --header: 52px; --footer: calc(64px + env(safe-area-inset-bottom) + var(--view-note-height, 0px)); }
  body.has-audio { --footer: calc(64px + env(safe-area-inset-bottom) + var(--view-note-height, 0px)); }
  .topbar { gap: 8px; padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right)); }
  .wordmark { font-size: 15px; }
  .top-actions { gap: 2px; }
  #counter { display: inline; padding: 0 5px; color: var(--muted); font-size: 12px; white-space: nowrap; }
  .top-actions button { padding-inline: 6px; }
  .player {
    padding: 5px max(10px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
    min-height: var(--footer);
    display: grid;
    align-content: center;
  }
  #mobile-view-note {
    width: 100%;
    max-width: 660px;
    margin-inline: auto;
    padding: 6px 0 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: start;
    gap: 4px;
    border-bottom: 1px solid var(--line);
  }
  #mobile-view-note p { margin: 0; padding-inline-start: 4px; font-size: 1rem; line-height: 1.35; }
  #dismiss-view-note { min-height: 44px; padding: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; }
  .player-row {
    display: grid;
    grid-template-columns: 44px auto minmax(0, 1fr) 44px 44px;
    align-items: center;
    gap: clamp(2px, 1vw, 10px);
    width: 100%;
    max-width: 660px;
    margin: auto;
  }
  .player-bottom { display: none; }
  #next { grid-column: 4; }
  #player-options { grid-column: 5; }
  body:not(.has-audio) .audio-status { grid-column: 2 / 4; justify-content: flex-start; }
  body:not(.has-audio) .audio-status .primary:disabled { display: none; }
  body:not(.has-audio) #audio-message { max-width: none; }
  #previous, #next, #player-options { padding: 0; font-size: 19px; min-width: 44px; height: 44px; }
  #previous span, #next span { display: none; }
  #player-options { color: var(--muted); font-size: 14px; letter-spacing: 1px; }
  .audio-status { min-width: 0; }
  .audio-status .primary { min-width: 76px; min-height: 44px; padding: 8px 12px; }
  #audio-controls { order: 0; display: grid; grid-template-columns: minmax(0,1fr); gap: 0; min-width: 0; }
  #seek { width: 100%; min-width: 0; height: 30px; margin: 0; }
  #time { text-align: center; font-size: 11px; line-height: 1.2; font-variant-numeric: tabular-nums; }
  #controls-dialog { width: min(390px,100%); padding: 22px; }
  #mobile-playback-settings { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
  #mobile-playback-settings label[for="speed"] { position: static; width: auto; height: auto; clip: auto; overflow: visible; }
  #mobile-playback-settings #rewind { justify-self: start; border: 1px solid var(--line); }
  #mobile-playback-settings #speed { font-size: 16px; }
  #mobile-playback-settings #follow-label { min-height: 44px; font-size: 15px; }
  #mobile-talk-actions { display: grid; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
  #mobile-talk-actions button { display: block; text-align: left; padding: 10px 0; font-size: 16px; }
}

/* Mobile figures reserve their actual aspect ratio while loading. Every figure can be enlarged. */
@media screen and (max-width: 899px) {
  .scene { padding: clamp(18px,3vh,32px) clamp(16px,5vw,32px) 12px; }
  .mobile-slide {
    display: grid;
    align-content: start;
    gap: clamp(12px,2.2svh,19px);
    min-width: 0;
    --figure-height: clamp(150px,32svh,320px);
  }
  .mobile-slide :is(.mobile-block,.mobile-disciplines),
  .mobile-slide .mobile-block p { margin: 0 !important; }
  .mobile-slide .mobile-block { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
  .mobile-slide .mobile-heading {
    font-size: clamp(25px,6.2vw,36px);
    line-height: 1.14;
    letter-spacing: -.025em;
  }
  .mobile-slide .mobile-heading p { line-height: 1.14 !important; }
  .mobile-slide .mobile-text { font-size: clamp(16px,4vw,20px); }
  .mobile-slide .mobile-caption, .mobile-figure .mobile-text { font-size: 14px; }
  .mobile-slide .mobile-block p + p { margin-top: .18em !important; }
  .mobile-slide .mobile-takeaway { font-size: clamp(19px,4.6vw,24px); }
  .mobile-slide .mobile-takeaway p { line-height: 1.25 !important; }
  .mobile-slide .colored-tag { max-width: 100%; font-size: 14px; }
  .mobile-slide .mobile-picture {
    position: relative;
    width: min(100%, var(--design-width), calc(var(--figure-height) * var(--image-ratio)));
    height: auto;
    aspect-ratio: var(--image-ratio);
    min-height: 0;
    justify-self: start;
  }
  .mobile-slide .mobile-picture img { position: absolute; display: block; max-height: none; max-width: none; }
  .mobile-slide .mobile-picture.round { width: min(26vw,110px); aspect-ratio: 1; border-radius: 50%; }
  .mobile-slide .mobile-picture.round img { object-fit: cover; }
  .mobile-pair { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: clamp(12px,4vw,24px); }
  .mobile-pair > div, .mobile-figure { display: grid; grid-template-columns: minmax(0,1fr); min-width: 0; align-content: start; gap: 6px; }
  .mobile-pair .mobile-picture { --figure-height: clamp(108px,23svh,210px); }
  .mobile-slide .mobile-figure .mobile-caption { font-size: 14px; }
  .mobile-slide .source-badge { font-size: 12px; line-height: 1; padding: 6px; }
  .scene-tools { margin-top: 20px; padding-top: 5px; }
  .scene-tools button { font-size: 14px; }
  .scene-tools button:first-child { padding-left: 0; }
  .mobile-slide .mobile-demo { width: 100%; }
  .mobile-figure.narrated-focus { box-shadow: 0 0 0 3px #6b9f968c; }
  .mobile-demo video { width: 100%; height: auto; max-height: 38svh; object-fit: contain; }
  .mobile-slide .demo-caption { margin-top: 4px !important; font-size: 13px; }
  .demo-links { flex-wrap: wrap; gap: 4px; }
  .demo-links > a:last-child { padding-block: 8px; }
  .slide-1 .mobile-slide { justify-items: center; align-content: center; min-height: min(64svh,550px); padding-top: 0; }
  .slide-1 .mobile-slide .mobile-picture { justify-self: center; }
  .slide-1 .mobile-heading { font-size: clamp(42px,9vw,60px); }
  .slide-1 .mobile-block[data-item="3"] { font-size: clamp(20px,4.8vw,27px); }
  .slide-1 .mobile-block[data-item="4"], .slide-1 .mobile-block[data-item="5"] { font-size: 16px; }
  .slide-2 .mobile-slide, .slide-divider .mobile-slide, .slide-39 .mobile-slide {
    align-content: center; min-height: clamp(180px,55svh,480px); padding: 0; gap: 20px;
  }
  .slide-2 .mobile-slide .mobile-block { font-size: clamp(24px,5.7vw,32px); }
  .slide-divider .mobile-slide .mobile-block:nth-child(2) { font-size: clamp(30px,6.8vw,40px); }
  .slide-17 .mobile-figure [data-item="7-2"] { font-size: 16px; }
  .slide-18 .mobile-slide .mobile-picture[data-item="3"] { --figure-height: clamp(130px,24svh,245px); }
  .slide-18 .mobile-slide [data-item="4"], .slide-18 .mobile-slide [data-item="5"] { font-size: clamp(16px,4.3vw,21px); }
  .slide-18 .mobile-slide [data-item="11"] { width: 100%; }
  .slide-18 .mobile-pair:has([data-item="11"]) .mobile-picture { --figure-height: 110px; }
  .slide-18 .mobile-disciplines { line-height: 1.4; }
  .slide-29 .mobile-pair { grid-template-columns: clamp(60px,18vw,90px) minmax(0,1fr); align-items: center; }
  .slide-29 .mobile-pair .mobile-picture { width: 100%; }
  .slide-29 .mobile-slide .mobile-takeaway p { text-wrap: pretty; }
  .slide-38 .mobile-block[data-item="2"] { padding-top: 0; }
  .slide-38 .mobile-block[data-item="2"] p { font-size: clamp(18px,4vw,24px); }
  .slide-38 .mobile-block[data-item="2"] p:empty { display: none; }
  .scene-anchor { scroll-margin-top: calc(var(--header) + 10px); }
}

/* On a sideways phone, use the authored slide and give its full height to the canvas. */
@media screen and (max-width: 1023px) and (orientation: landscape) and (max-height: 560px) {
  body:not(.read-mode) { --rail: calc(102px + env(safe-area-inset-right)); }
  body:not(.read-mode) .topbar, body:not(.read-mode) .player {
    position: fixed; inset-inline: auto 0; width: var(--rail);
    border: 0; border-left: 1px solid var(--line); background: var(--surface);
    padding: 4px max(5px,env(safe-area-inset-right)) 4px 5px;
  }
  body:not(.read-mode) .topbar { top: 0; height: 40%; min-height: 0; justify-content: center; }
  body:not(.read-mode) .wordmark { display: none; }
  body:not(.read-mode) .top-actions { display: grid; justify-items: center; gap: 0; }
  body:not(.read-mode) #counter { padding: 4px; }
  body:not(.read-mode) .top-actions button { min-height: 36px; }
  body:not(.read-mode) .player { bottom: 0; height: 60%; min-height: 0; align-content: center; }
  body:not(.read-mode) .player-row { grid-template-columns: 1fr 1fr; gap: 1px; }
  body:not(.read-mode) .audio-status { grid-area: 1 / 1 / 2 / 3; }
  body:not(.read-mode) #audio-controls { grid-area: 2 / 1 / 3 / 3; }
  body:not(.read-mode) #previous { grid-area: 3 / 1; }
  body:not(.read-mode) #next { grid-area: 3 / 2; }
  body:not(.read-mode) #player-options { grid-area: 4 / 1 / 5 / 3; }
  body:not(.read-mode) #main { margin-right: var(--rail); min-height: 100svh; padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left); }
  body:not(.read-mode) .scene.active { display: grid; align-content: center; max-width: none; min-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom)); padding: 0; }
  body:not(.read-mode) .slide-shell { display: block; overflow: clip; min-width: 0; width: min(100%, calc((100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 16 / 9)); }
  body:not(.read-mode) :is(.mobile-slide,.scene-tools) { display: none; }

  /* Give the tip room above the controls in the landscape rail. */
  body:not(.read-mode):has(#mobile-view-note:not([hidden])) {
    --rail: calc(clamp(260px, 34vw, 330px) + env(safe-area-inset-right));
  }
  body:not(.read-mode):has(#mobile-view-note:not([hidden])) .topbar { height: 48px; }
  body:not(.read-mode):has(#mobile-view-note:not([hidden])) .top-actions { display: flex; }
  body:not(.read-mode) .player:has(#mobile-view-note:not([hidden])) {
    top: 48px;
    height: auto;
    padding-inline-start: 10px;
  }
  body:not(.read-mode) .player:has(#mobile-view-note:not([hidden])) .player-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  body:not(.read-mode) .player:has(#mobile-view-note:not([hidden])) .audio-status { flex: 0 0 auto; }
  body:not(.read-mode) .player:has(#mobile-view-note:not([hidden])) #audio-controls { order: 1; flex: 0 0 100%; }
}

/* Keep short desktop windows within both dimensions as well. */
@media screen and (min-width: 900px) and (max-height: 680px) {
  body:not(.read-mode) .slide-shell { min-width: 0; }
}
@media screen and (min-width: 1024px) and (max-height: 680px),
       screen and (min-width: 900px) and (min-height: 561px) and (max-height: 680px) {
  body:not(.read-mode) .slide-shell { width: min(100%, calc((100svh - var(--header) - var(--footer) - 80px) * 16 / 9)); }
}

/* Closing slide contact rows follow the two columns in the presentation. */
.contact-link {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  text-decoration: none;
}
.contact-icon {
  position: relative;
  flex: none;
  width: var(--icon-width);
  height: var(--icon-height);
  overflow: hidden;
  border-radius: 5px;
}
.contact-icon img { position: absolute; max-width: none; }
.canvas .contact-link { position: absolute; font-size: 32px; line-height: 1.2; white-space: nowrap; }
#thank-you [data-item="9"] a { color: var(--teal); text-decoration: none; }
#thank-you a:hover, #thank-you a:focus-visible { text-decoration: underline; }
#thank-you .mobile-slide { gap: 8px; }
#thank-you .mobile-slide .contact-link { min-height: 44px; gap: 11px; font-size: clamp(15px,4vw,19px); }
#thank-you .mobile-slide .contact-icon { width: 32px; height: 32px; }
#thank-you .mobile-slide [data-item="9"] { font-size: 25px; padding-bottom: 10px; }
#thank-you .mobile-slide [data-item="6"] { font-size: 18px; padding-top: 14px; }
