/* The two gates explainer page. The explainer plays in a video-style
   player cut to music, with its headlines drawn on screen and chapters
   underneath; the full explanation is written out below. Canvas drawing
   and the soundtrack live in js/loan-story/. */

.ls-page {
  --ls-paper: #ffffff;
  --ls-line: rgba(26, 54, 93, 0.12);
  --ls-night: #10233f;
  background: var(--brand-light-gray);
  color: var(--brand-dark-gray);
  overflow-x: visible;
  overflow-x: clip;
}

/* Links in the explanation are navy with a gold underline, so they don't
   rely on colour alone. */
.ls-page .lv-transcript a {
  color: var(--brand-navy);
  text-decoration: underline;
  text-decoration-color: var(--brand-gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.ls-page .lv-transcript a:hover {
  text-decoration-color: currentColor;
}

/* Gold focus rings disappear on light backgrounds, so the page uses navy;
   inside the dark player they go back to gold. */
.ls-page main :focus-visible {
  outline: 3px solid var(--brand-navy);
  outline-offset: 3px;
}

.ls-page .ls-close :focus-visible,
.ls-page .lv-player :focus-visible {
  outline-color: #f6cf78;
}

.ls-mark {
  font-style: normal;
  background: linear-gradient(transparent 55%, rgba(244, 193, 79, 0.62) 55%, rgba(244, 193, 79, 0.62) 92%, transparent 92%);
  padding: 0 0.08em;
}

.ls-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* The player */

.lv {
  background: var(--ls-paper);
  border-bottom: 1px solid var(--ls-line);
  padding: 28px 24px 40px;
}

.lv-inner {
  max-width: 1080px;
  margin: 0 auto;
}

.lv h1 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(1.9rem, 3.4vw, 2.7rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
  color: var(--brand-navy);
  text-align: center;
  margin: 0 0 20px;
}

/* The whole player (picture and controls) fits on one screen. */
.lv-player {
  width: min(100%, calc((100vh - 250px) * 16 / 9));
  width: min(100%, calc((100svh - 250px) * 16 / 9));
  min-width: min(100%, 560px);
  margin: 0 auto;
  scroll-margin-top: 81px;
  position: relative;
  background: var(--ls-night);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(16, 35, 63, 0.28);
  overflow: hidden;
  color: #fff;
}

.lv-player:focus-visible {
  outline: 3px solid var(--brand-navy);
  outline-offset: 3px;
}

.lv-screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--brand-navy);
}

.lv-screen canvas {
  position: absolute;
  inset: 0;
  display: block;
}

/* Poster: the opening question fills the top, the play button sits below. */
.lv-start {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 0 7%;
  border: 0;
  background: linear-gradient(rgba(16, 35, 63, 0) 45%, rgba(16, 35, 63, 0.55));
  color: #fff;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
}

.lv-start[hidden] {
  display: none;
}

.lv-start-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--brand-light-gold);
  box-shadow: 0 0 0 8px rgba(244, 193, 79, 0.22), 0 14px 36px rgba(0, 0, 0, 0.3);
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.lv-start-icon::before {
  content: "";
  margin-left: 6px;
  border-top: 15px solid transparent;
  border-bottom: 15px solid transparent;
  border-left: 24px solid var(--brand-navy);
}

.lv-start:hover .lv-start-icon {
  transform: scale(1.06);
  box-shadow: 0 0 0 12px rgba(244, 193, 79, 0.28), 0 14px 36px rgba(0, 0, 0, 0.3);
}

.lv-start-label {
  font-weight: 700;
  font-size: 1.05rem;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.lv-start-time {
  font: 600 0.85rem/1 'Inter', sans-serif;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  padding: 5px 9px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}

/* End card */
.lv-end {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: rgba(16, 35, 63, 0.9);
  text-align: center;
}

.lv-end[hidden] {
  display: none;
}

.lv-replay {
  min-height: 44px;
  padding: 10px 20px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  background: transparent;
  color: #fff;
  font: 600 0.95rem/1 'Poppins', sans-serif;
  cursor: pointer;
}

.lv-replay:hover {
  border-color: #fff;
}

.lv-end-primary {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 12px 22px;
  border-radius: 12px;
  background: var(--brand-light-gold);
  color: var(--brand-navy) !important;
  font: 700 1rem/1.2 'Poppins', sans-serif;
  text-decoration: none;
  box-shadow: 0 6px 0 #c9971f;
}

.lv-end-link {
  color: #fff !important;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--brand-light-gold);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* Captions are drawn in the picture; this copy is for screen readers. */
.lv-caption {
  margin: 0;
}

/* Controls */
.lv-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px 12px;
  background: var(--ls-night);
}

.lv-toggle,
.lv-full,
.lv-sound {
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
}

.lv-toggle {
  border: 0;
  background: var(--brand-light-gold);
  color: var(--brand-navy);
}

.lv-toggle::before {
  content: "";
  margin-left: 3px;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid currentColor;
}

.lv-player.is-playing .lv-toggle::before {
  margin-left: 0;
  width: 10px;
  height: 13px;
  border: 0;
  border-left: 3px solid currentColor;
  border-right: 3px solid currentColor;
  box-sizing: border-box;
}

.lv-sound,
.lv-full {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  color: #fff;
}

.lv-sound svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lv-sound .lv-spk {
  fill: currentColor;
}

.lv-sound .lv-off,
.lv-sound.is-muted .lv-waves {
  display: none;
}

.lv-sound.is-muted .lv-off {
  display: inline;
}

.lv-full[hidden] {
  display: none;
}

.lv-full::before {
  content: "";
  width: 14px;
  height: 14px;
  background:
    linear-gradient(currentColor, currentColor) 0 0 / 5px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 0 / 2px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / 5px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 0 / 2px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 5px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 0 100% / 2px 5px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / 5px 2px no-repeat,
    linear-gradient(currentColor, currentColor) 100% 100% / 2px 5px no-repeat;
}

.lv-track {
  position: relative;
  flex: 1;
  height: 32px;
  cursor: pointer;
  touch-action: none;
}

.lv-track::before,
.lv-fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 6px;
  margin-top: -3px;
  border-radius: 3px;
}

.lv-track::before {
  content: "";
  right: 0;
  background: rgba(255, 255, 255, 0.2);
}

.lv-fill {
  width: 0;
  background: var(--brand-light-gold);
}

.lv-fill::after {
  content: "";
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--brand-light-gold);
  box-shadow: 0 0 0 3px var(--ls-night);
}

.lv-mark {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 8px;
  margin: -4px 0 0 -1px;
  background: var(--ls-night);
  pointer-events: none;
}

.lv-time {
  flex: none;
  min-width: 84px;
  text-align: right;
  font: 500 0.88rem/1 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.78);
}

/* Full screen fills the display, with the picture taking the spare room. */
.lv-player:fullscreen {
  display: flex;
  flex-direction: column;
  border-radius: 0;
}

.lv-player:fullscreen .lv-screen {
  flex: 1;
  aspect-ratio: auto;
}

/* Chapters */
.lv-chapters {
  list-style: none;
  max-width: 1080px;
  margin: 18px auto 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.lv-chapters button {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(26, 54, 93, 0.14);
  border-radius: 14px;
  background: var(--ls-paper);
  color: var(--brand-navy);
  text-align: left;
  cursor: pointer;
  font: 500 0.92rem/1.25 'Poppins', sans-serif;
}

.lv-chapters button:hover {
  border-color: var(--brand-navy);
}

.lv-chapters button[aria-current="true"] {
  border-color: var(--brand-navy);
  box-shadow: inset 0 0 0 1px var(--brand-navy);
}

.lv-ch-n {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(26, 54, 93, 0.08);
  font: 600 0.8rem/1 'Poppins', sans-serif;
}

.lv-chapters button[aria-current="true"] .lv-ch-n {
  background: var(--brand-light-gold);
}

.lv-ch-time {
  font: 500 0.8rem/1 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  color: #545d6b;
}

/* The full explanation */

.lv-transcript {
  max-width: 44rem;
  margin: 0 auto;
  padding: 64px 24px 72px;
}

.lv-transcript h2 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1.15;
  color: var(--brand-navy);
  margin: 0 0 8px;
}

.lv-part h3 {
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--brand-navy);
  margin: 40px 0 14px;
}

.lv-part p {
  font-size: 1.06rem;
  line-height: 1.72;
  margin: 0 0 1em;
}

.ls-voice {
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  font-size: 1.15rem !important;
  line-height: 1.5 !important;
  color: var(--brand-navy);
  border-left: 3px solid var(--brand-gold);
  padding-left: 16px;
}

/* Close */

.ls-close {
  background: linear-gradient(135deg, var(--brand-navy) 0%, var(--brand-secondary-blue) 100%);
  color: #fff;
}

.ls-close-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 88px 24px 96px;
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  gap: 48px;
  align-items: center;
}

.ls-close h2 {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  line-height: 1.15;
  margin: 0;
  color: #fff;
}

.ls-close-links {
  display: grid;
  gap: 12px;
}

.ls-close-links a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 16px 20px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff !important;
  text-decoration: none;
  font-family: 'Poppins', sans-serif;
  font-weight: 500;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.ls-close-links a:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(244, 193, 79, 0.6);
}

.ls-close-links a.ls-primary {
  background: linear-gradient(135deg, var(--brand-gold) 0%, #e7c675 100%);
  border-color: transparent;
  color: var(--brand-navy) !important;
}

.ls-disclaimer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 40px;
  font-size: 0.84rem;
  line-height: 1.6;
  color: #545d6b;
}

/* Without JavaScript there is no player, so the page opens on the words. */
html:not(.ls-js) .lv-player,
html:not(.ls-js) .lv-chapters {
  display: none;
}

/* Phones: the player runs edge to edge in a taller frame, and the chapter
   list becomes a row you can swipe along. */
@media (max-width: 640px) {
  .lv {
    padding: 22px 0 28px;
  }

  .lv h1 {
    padding: 0 20px;
    margin-bottom: 16px;
    text-align: left;
  }

  .lv-player {
    width: 100%;
    min-width: 0;
    border-radius: 0;
    box-shadow: none;
  }

  /* The picture takes the height left once the controls fit, up to a
     4:5 frame like a social video. */
  .lv-screen {
    aspect-ratio: auto;
    height: min(125vw, max(260px, calc(100vh - 73px - 64px)));
    height: min(125vw, max(260px, calc(100svh - 73px - 64px)));
  }

  /* The tall frame has room for the play button in the middle, clear of
     the question above and the house below. */
  .lv-start {
    justify-content: center;
    padding: 12% 0 0;
  }

  .lv-start-icon {
    width: 68px;
    height: 68px;
  }

  .lv-controls {
    gap: 10px;
    padding: 8px 12px 10px;
  }

  .lv-time {
    min-width: 74px;
    font-size: 0.8rem;
  }

  .lv-chapters {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding: 0 20px 4px;
    gap: 8px;
  }

  .lv-chapters li {
    flex: none;
    width: 172px;
    scroll-snap-align: start;
  }

  .lv-transcript {
    padding: 48px 20px 56px;
  }

  .ls-close-inner {
    grid-template-columns: minmax(0, 1fr);
    padding: 64px 20px 72px;
  }
}

@media (max-width: 899px) and (min-width: 641px) {
  .ls-close-inner {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }

  .lv-start-icon {
    transition: none;
  }
}
