/* The reading layout is a second presentation of the same twelve chapters.
   Slides keep their original 1920x1080 composition on larger screens. */
.reader-figure {
  flex: 1 1 260px;
  min-width: 0;
  margin: 0;
}

.reader-figure figcaption {
  margin-top: 10px;
  color: #aeb9c7;
  font-size: 13px;
  line-height: 1.4;
}

.reader-media:not(.services-reader) > .reader-figure:only-child {
  flex-basis: 100%;
}

.reader-media:not(.services-reader) .reader-image img {
  max-height: 560px;
  object-fit: contain;
}

.services-reader .reader-figure {
  width: 100%;
}

.reader-media.devices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.reader-media.devices .reader-figure {
  width: 100%;
}

@media (max-width: 700px) {
  /* On phones, the actual slide is the lead visual; its text follows below. */
  body[data-mode="slides"] .slide-stage {
    position: relative;
    inset: auto;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    margin-top: calc(58px + env(safe-area-inset-top));
  }

  body[data-mode="slides"] .reader {
    margin-top: 0;
  }

  body[data-mode="slides"] .reader-slide {
    padding-top: 24px;
    border-bottom: 0;
  }

  body[data-mode="slides"] .reader-media {
    display: none;
  }

  body[data-mode="slides"] .services-reader {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    margin-top: 12px;
  }

  body[data-mode="slides"] .services-reader .reader-figure {
    display: none;
  }

  body[data-mode="slides"] .services-reader article {
    padding: 14px 0;
    border-top: 1px solid var(--line);
  }

  body[data-mode="slides"] .services-reader h3 {
    margin: 0 0 4px;
  }

  .reader {
    padding: 0 20px calc(76px + env(safe-area-inset-bottom));
    margin-bottom: 0;
  }

  .reader-slide {
    padding: 48px 0 56px;
    scroll-margin-top: 64px;
  }

  .reader-slide:first-child {
    padding-top: 34px;
  }

  .reader h2 {
    max-width: 22ch;
    font-size: clamp(28px, 8vw, 36px);
    line-height: 1.12;
  }

  .reader-intro {
    font-size: 17px;
    line-height: 1.5;
  }

  .reader-media {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .reader-figure {
    width: 100%;
  }

  .reader-image {
    width: 100%;
    border-radius: 12px;
  }

  .reader-media:not(.services-reader) .reader-image img {
    max-height: none;
    width: 100%;
    height: auto;
  }

  .reader-figure figcaption {
    font-size: 12px;
  }

  .reader-points {
    margin-top: 26px;
  }

  .reader-points article {
    padding-top: 14px;
  }

  .reader-points h3 {
    color: #f0f3f7;
  }

  .reader-media.devices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .reader-media.devices .reader-figure:first-child {
    grid-column: 1 / -1;
  }

  .reader-media.devices .reader-figure:not(:first-child) img {
    max-height: 350px;
    object-fit: contain;
  }

  .presentation-header {
    padding-top: env(safe-area-inset-top);
    height: calc(58px + env(safe-area-inset-top));
  }

  .reader {
    margin-top: calc(58px + env(safe-area-inset-top));
  }

  .presentation-controls {
    height: calc(62px + env(safe-area-inset-bottom));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .presentation-controls button,
  .header-actions button {
    min-height: 44px;
  }

  .progress {
    bottom: calc(60px + env(safe-area-inset-bottom));
  }

  .slide-stage {
    top: calc(58px + env(safe-area-inset-top));
    bottom: calc(62px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .presentation-brand {
    font-size: 0;
  }

  .presentation-brand > span {
    font-size: 12px;
  }

  .presentation-controls #share {
    display: grid;
    place-items: center;
    min-width: 44px;
    padding: 0;
    font-size: 0;
  }

  .presentation-controls #share::before {
    content: '↗';
    font-size: 23px;
  }

  .reader {
    padding-right: 16px;
    padding-left: 16px;
  }
}
