* { box-sizing: border-box; }

html { font-size: var(--v8-font-size-base); }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--typeface);
}

#player {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  gap: .75rem;
  padding: .7rem 0 16px;
  background: var(--canvas);
}

.journey-back {
  justify-self: start;
  margin-left: 1rem;
  color: var(--navy);
  font-size: .9rem;
  text-underline-offset: .18em;
}

#stage {
  width: min(calc(100% - 2rem), calc((100dvh - 136px) * 16 / 9));
}

canvas { display: block; width: 100%; height: auto; }

#player:has(#chrome[hidden]) { grid-template-rows: auto minmax(0, 1fr); }

#player:has(#chrome[hidden]) #stage {
  width: min(calc(100% - 2rem), calc((100dvh - 68px) * 16 / 9));
}

.chrome {
  position: relative;
  inset: auto;
  transform: none;
  font-size: var(--v8-font-size-base);
}

#chapters-toggle { min-width: 0; }

#settings {
  bottom: auto;
  max-height: calc(100dvh - 105px);
}

.settings-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.settings-actions button { background: var(--canvas); border: 1px solid var(--line-highlight); }
.settings-actions button:hover { background: var(--masthead); }

#show-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  background: var(--canvas);
  box-shadow: 0 3px 16px rgb(0 24 113 / .12);
  z-index: 3;
}

#show-controls[hidden] { display: none; }
#show-controls:hover { background: var(--masthead); }
button:disabled { opacity: .4; cursor: default; }

.video-heading, .video-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

#video-dialog, .status {
  color: var(--ink);
  background: var(--canvas);
  box-shadow: 0 6px 24px rgba(0, 24, 113, .1);
}

.status {
  position: absolute;
  bottom: 94px;
  z-index: 4;
  width: max-content;
  max-width: 90%;
  margin: 0;
  padding: .75rem 1rem;
  border-radius: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

#video-dialog {
  width: min(950px, 94vw);
  border: 1px solid var(--line-highlight);
  border-radius: 16px;
  padding: 1rem;
}

#video-dialog::backdrop { background: rgba(23, 36, 59, .25); }
#video-dialog video { width: 100%; display: block; }
.video-heading h2 { margin: 0 0 .6rem; color: var(--navy); }
.video-footer { margin-top: .6rem; }
.video-footer a { color: var(--navy); }

#player:fullscreen .journey-back { visibility: hidden; }

@media (max-width: 650px) {
  #player { padding-bottom: 8px; }
  #stage { width: min(calc(100% - 1rem), calc((100dvh - 165px) * 16 / 9)); }
  .status { bottom: 130px; }
  #show-controls { right: 10px; bottom: 8px; }
}

@media (max-width: 650px) and (orientation: landscape) {
  #player { padding-bottom: 3px; }
}

@media (max-width: 720px) and (orientation: portrait) {
  #accessible-caption[data-visible=true], #accessible-glossary[data-active=true] {
    position: static;
    width: auto;
    height: auto;
    margin: .65rem .5rem 0;
    padding: .65rem .8rem;
    clip-path: none;
    white-space: pre-line;
    background: var(--panel);
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 24, 113, .1);
  }

  #accessible-glossary::first-line { color: var(--navy); font-weight: 700; }
}
