/* 02 American Enterprise Institute.
   Measurements come from the Figma page of the same name, drawn at 1440x900.

   Two layouts:
   - Composed (window at least 1100px wide and 600px tall): each slide fills
     the window exactly. Text sits above and below a middle "stage" (the video
     on slide 1, the figures on slide 2), and the stage is the part that
     shrinks when the window is shorter than the drawing.
   - Flowing (anything smaller): an ordinary scrolling page, one column. */

.aei-col {
  width: 100%;
  min-width: 0;
}

/* Text: Helvetica Neue Medium, 24px opening line, 20px after it */
.aei-text {
  max-width: 954px;
  font-size: 20px;
  font-weight: 500;
  line-height: 22.4px;
}
.aei-text p {
  max-width: none;
  margin: 0 0 15.2px;
}
.aei-text p:last-child {
  margin-bottom: 0;
}
.aei-text strong {
  font-weight: 700;
}
.aei-text .lede {
  font-size: 24px;
}
.aei-name {
  color: #008ccc; /* the blue of the AEI logo */
}
.aei-text .cue {
  margin-top: 21.2px;
  font-weight: 400;
  font-style: italic;
}

/* Bookmarks: links that jump the video to a moment */
.bookmarks {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5.6px;
}
.bookmarks a[aria-current] {
  color: var(--here); /* the one chosen last */
}

/* The video, with the logo over its bottom-right corner */
.player {
  position: relative;
}
.video {
  aspect-ratio: 16 / 9;
  background: #000;
}
.video iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.aei-logo {
  position: absolute;
  left: 75.52%;
  top: 83.33%;
  width: 32.03%;
  height: auto;
  pointer-events: none; /* clicks reach the player underneath */
  transition: opacity 0.2s;
}
/* Out of the way while the pointer is on the video, or the player has been
   clicked or tapped, so YouTube's own buttons in that corner can be seen */
.video:hover ~ .aei-logo,
.video:focus-within ~ .aei-logo {
  opacity: 0;
}

/* Hung below the frame */
.controls {
  position: absolute;
  top: 100%;
  left: 0;
  margin: 8px 0 0;
}

/* A button that reads as one of the page's blue links */
#sound {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  color: var(--link);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
#sound[hidden] {
  display: none;
}
#sound span {
  text-decoration: underline;
}
/* the same loudspeaker as the music button (.vibes in style.css) */
#sound svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#sound svg .body {
  fill: currentColor;
}

/* Slide 2: two figures from the report and the Survey Center logo,
   overlapping. Placed by percentage so the group scales as one. */
.figures {
  position: relative;
  aspect-ratio: 718 / 510;
}
.figures img {
  position: absolute;
  display: block;
  box-sizing: border-box;
}
.figure-atlas,
.figure-states {
  border: 1px solid var(--ink);
  background: #fff;
  object-fit: cover;
}
.figure-atlas {
  left: 0;
  top: 9.61%;
  width: 58.91%;
  height: 80.2%;
}
.figure-states {
  left: 35.65%;
  top: 31.96%;
  width: 64.35%;
  height: 68.04%;
}
.scal-logo {
  left: 58.77%;
  top: 0;
  width: 38.44%;
  height: 38.82%;
}

/* Composed layout */
@media (min-width: 1100px) and (min-height: 600px) {
  .aei-slide {
    height: 100vh;
    height: 100svh;
    align-items: stretch;
    padding: var(--top) 35px var(--bottom);
  }
  /* Distances as drawn, easing in proportion once the window is under 900px
     tall. --bottom never goes below the room the slide numbers need. */
  #s1 {
    --top: min(75px, 8.33vh);
    --bottom: clamp(48px, 7.62vh, 69px);
    --stage: 432px;
    --before: min(54px, 6.02vh);
    --after: min(77px, 8.56vh);
  }
  #s2 {
    --top: min(68px, 7.56vh);
    --bottom: clamp(48px, 11.62vh, 105px);
    --stage: 510px;
    --before: -3px; /* the logo's clear margin tucks under the text */
    --after: min(33px, 3.67vh);
  }
  .aei-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
  }
  .aei-text {
    flex: none;
  }
  .aei-text .lede {
    min-height: 44.8px; /* two lines, whether or not the sentence needs both */
  }
  /* The stage is a size container, so what is inside it can be sized from
     whatever height is left over (cqh) as well as from the width (cqw). */
  .aei-stage {
    flex: 0 1 var(--stage);
    min-height: 0;
    margin: var(--before) 0 var(--after);
    container-type: size;
  }
  .aei-stage--debate {
    display: flex;
    align-items: flex-start;
  }
  .bookmarks {
    flex: none;
    width: 206px;
    margin-top: -6px;
  }
  .player {
    /* 1.0755: the logo reaches that far past the right edge of the frame */
    width: min(768px, calc((100cqw - 206px) / 1.0755), calc(100cqh * 16 / 9));
  }
  .figures {
    width: min(718px, calc(100cqw - 108px), calc(100cqh * 718 / 510));
    margin-left: min(108px, 11cqw);
  }
}
/* The hand-placed line breaks only suit a wide text column */
@media (max-width: 1279px), (max-height: 599px) {
  .aei-text br {
    display: none;
  }
}

/* Flowing layout */
@media (max-width: 1099px), (max-height: 599px) {
  html:has(.aei-page) {
    scroll-snap-type: none;
  }
  .aei-page .deck-nav,
  .aei-page .cue {
    display: none; /* nothing snaps, so no slide numbers and no cue */
  }
  .aei-slide {
    display: block;
    min-height: 0;
    padding: 40px 32px 24px;
  }
  .aei-text {
    font-size: 17px;
    line-height: 21px;
  }
  .aei-text .lede {
    font-size: 20px;
    line-height: 22.4px;
  }
  .aei-text p {
    margin-bottom: 12px;
  }
  .aei-stage {
    margin: 24px 0;
  }
  .aei-stage--debate {
    margin-bottom: 60px; /* the sound link and the logo hang below the frame */
  }
  .bookmarks {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 12px;
  }
  .player {
    width: min(100%, 768px);
  }
  .aei-logo {
    left: auto;
    right: 0; /* flush with the frame: there is no margin to reach into */
  }
  .figures {
    width: min(100%, 718px);
  }
}
/* No sidebar: the header and the photo row join the flow too */
@media (max-width: 719px), (max-height: 519px) {
  .aei-page .site-head {
    position: static;
    margin: var(--pad-top) var(--pad-side) 0;
  }
  .aei-slide {
    padding: 24px var(--pad-side) 8px;
  }
  .aei-page .about {
    position: static;
    margin: 16px var(--pad-side);
  }
}
