@font-face {
  font-family: Manrope;
  src: url('assets/Manrope-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url('assets/Manrope-Medium.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url('assets/Manrope-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url('assets/Manrope-Bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #090d14;
  --surface: #101722;
  --line: #263447;
  --text: #edf3fa;
  --muted: #aab9cb;
  --ice: #badaf8;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.65 Manrope, system-ui, sans-serif;
}

button, input, select { font: inherit; }
button, a, summary { touch-action: manipulation; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
a { color: var(--ice); text-decoration: none; }

:where(button, a, input, summary, select, [tabindex]):focus-visible {
  outline: 2px solid var(--ice);
  outline-offset: 3px;
}

button svg {
  display: block;
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wrap {
  width: min(100%, 1440px);
  margin-inline: auto;
  padding-inline: clamp(18px, 4vw, 58px);
}

.tutorial {
  width: min(100%, 1460px);
  padding-bottom: 32px;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: clamp(24px, 3.2vw, 44px) 0 19px;
}

.masthead h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.25;
}

.masthead h1 img { flex: none; object-fit: contain; }
.title-kind { color: var(--muted); font-weight: 500; }

.sim-choice {
  flex: none;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented {
  display: flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #0d1420;
}

.segmented label { position: relative; cursor: pointer; }

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented span {
  display: grid;
  min-height: 36px;
  padding-inline: 13px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: background .3s var(--ease), color .3s var(--ease), border-color .3s var(--ease);
}

.segmented input:checked + span {
  border-color: #3a546f;
  background: #22364c;
  color: #eef6ff;
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--ice);
  outline-offset: -2px;
}

.walkthrough {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(210px, 23vw, 250px);
  grid-template-areas:
    "chapters chapters"
    "player steps"
    "instruction steps";
  align-items: start;
  column-gap: clamp(14px, 1.6vw, 24px);
}

#chapters,
#step-navigation {
  min-width: 0;
  padding: 7px;
  border-radius: 12px;
  background: var(--surface);
}

#chapters {
  grid-area: chapters;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-content: start;
  gap: 3px;
  margin-bottom: 14px;
}

#step-navigation { grid-area: steps; }

.chapter,
.step-button {
  min-height: 44px;
  padding: 8px 11px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  transition: background .28s var(--ease), color .28s var(--ease), border-color .28s var(--ease);
}

.chapter:hover,
.step-button:hover { background: #1b2939; color: var(--text); }

.chapter[aria-current="step"],
.step-button[aria-current="step"] {
  border-color: #395471;
  background: #22364c;
  color: #eef6ff;
}

.chapter:focus-visible,
.step-button:focus-visible { outline-offset: -3px; }

.substeps {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-button {
  width: 100%;
  text-align: left;
}

.player {
  grid-area: player;
  position: relative;
  display: grid;
  grid-template-rows: auto auto;
  align-content: start;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
  background: #0b101a;
}

.player:focus-visible { outline-offset: -3px; }

.screen {
  position: relative;
  display: grid;
  place-items: center;
  align-self: center;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 2;
  background: #0b101a;
}

.screen video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* The clips have an encoded margin around the demonstration. */
  transform: scale(1.045);
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  transition: opacity .28s var(--ease), visibility .28s;
}

.play-overlay.hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.play-overlay:focus-visible { outline-offset: -5px; }

.play-orb {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 1px solid #d9ecff91;
  border-radius: 50%;
  background: #1a2b40bb;
  box-shadow: 0 8px 30px #0006;
  transition: transform .32s var(--ease), background .32s var(--ease);
}

.play-overlay:hover .play-orb {
  transform: scale(1.08);
  background: #314862;
}

.play-orb svg {
  width: 22px;
  height: 22px;
  margin-left: 2px;
  fill: #f0f7ff;
  stroke: none;
}

.player-controls {
  padding: 3px 13px 8px;
  border-top: 1px solid #243549;
  background: #101823;
}

.seek {
  --played: 0%;
  display: block;
  width: 100%;
  height: 24px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}

.seek::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--ice) var(--played), #35465c var(--played));
}

.seek::-moz-range-track {
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--ice) var(--played), #35465c var(--played));
}

.seek::-webkit-slider-thumb {
  width: 12px;
  height: 12px;
  margin-top: -4px;
  appearance: none;
  border: 0;
  border-radius: 50%;
  background: var(--ice);
}

.seek::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--ice);
}

.control-row {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background .25s var(--ease), color .25s var(--ease);
}

.icon-button:hover { background: #25374e; color: var(--text); }

#toggle-play {
  background: #253950;
  color: #e4f2ff;
}

#toggle-play:hover { background: #345273; }
#toggle-play svg { fill: currentColor; stroke: none; }
#toggle-play.playing svg { fill: none; stroke: currentColor; stroke-width: 2.7; }

.time {
  margin-left: 4px;
  color: var(--text);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.time span { margin-left: 4px; color: var(--muted); }
.control-spacer { flex: 1; }

#speed {
  min-height: 32px;
  padding: 4px 6px 4px 10px;
  border: 1px solid #33445b;
  border-radius: 7px;
  background: #182434;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.instruction {
  grid-area: instruction;
  min-width: 0;
  padding: 16px clamp(12px, 1.6vw, 22px) 14px;
  border: 1px solid var(--line);
  border-radius: 0 0 14px 14px;
  background: var(--surface);
}

.instruction h2 {
  margin: 0 0 7px;
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
}

.lesson-copy {
  max-inline-size: 67ch;
  margin: 0;
  color: #cfdded;
  font-size: 1rem;
  line-height: 1.6;
  text-wrap: pretty;
}

.lesson-copy a {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.lesson-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 12px;
}

.step-controls {
  display: flex;
  flex: none;
  align-items: stretch;
  gap: 8px;
}

.next-button,
.previous-button {
  min-height: 42px;
  border: 1px solid #39516a;
  border-radius: 8px;
  transition: background .3s var(--ease), border-color .3s var(--ease);
}

.next-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 122px;
  gap: 14px;
  padding: 7px 13px;
  border-color: #b7d3ec;
  background: #d2e5f6;
  color: #111e30;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.next-button:hover {
  border-color: #eef6fc;
  background: #e7f3ff;
}

.next-button span {
  font-size: 16px;
  transition: transform .3s var(--ease);
}

.next-button:hover span { transform: translateX(2px); }

.previous-button {
  width: 42px;
  padding: 0;
  background: #141e2b;
  color: var(--text);
  font-size: 17px;
}

.previous-button:enabled:hover { background: #253950; }
.previous-button:disabled { opacity: .42; }

.help {
  flex: 1;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
}

summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

.help > summary {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.help > summary:hover { color: var(--text); }
.help > summary::after { content: '+'; font-size: 16px; font-weight: 400; }
.help[open] > summary::after { content: '−'; }
.help p { margin: 4px 0 13px; }
.help > details { border-top: 1px solid var(--line); }
.help > details > summary { padding-block: 10px; color: var(--text); }
.help-links { display: flex; flex-wrap: wrap; gap: 9px 14px; padding-block: 11px; }
.help a:hover { text-decoration: underline; }

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

.skip-link { position: fixed; top: -100px; left: 16px; z-index: 10; }
.skip-link:focus { top: 16px; padding: 8px 12px; border-radius: 7px; background: var(--ice); color: var(--bg); }

.video-error {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  background: #111c2b;
}

.video-error p { margin: 0; }
.video-error button { padding: 8px 13px; border: 0; border-radius: 8px; background: var(--ice); color: var(--bg); }

.player:fullscreen {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  background: #0b101a;
}

.player:fullscreen .screen { flex: 1; min-height: 0; aspect-ratio: auto; }
.player:fullscreen video { min-height: 0; transform: none; }

.sources { max-width: 860px; padding-top: 35px; padding-bottom: 60px; }
.sources h1 { font-size: 28px; }
.sources h2 { margin-top: 32px; font-size: 19px; }
.sources p, .sources li { color: var(--muted); }
.sources a { text-decoration: underline; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-block: 24px 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.text-link { font-size: 12px; }

@media (min-width: 1040px) {
  .walkthrough {
    --rail-width: clamp(168px, 15vw, 228px);
    grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--rail-width);
    grid-template-areas:
      "chapters player steps"
      "chapters instruction steps";
  }

  #chapters {
    grid-template-columns: minmax(0, 1fr);
    margin-bottom: 0;
  }

  .chapter { text-align: left; }
}

@media (min-width: 1040px) and (min-height: 900px) {
  .tutorial {
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    min-block-size: 100svh;
    padding-block: 34px;
  }

  .masthead { padding-top: 0; }
}

@media (max-width: 800px) {
  #chapters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 0;
  }

  .walkthrough {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "chapters" "player" "steps" "instruction";
    row-gap: 12px;
  }

  .walkthrough:has(#step-navigation[hidden]) {
    grid-template-areas: "chapters" "player" "instruction";
  }

  .player,
  .instruction { border-radius: 12px; }

  .player { border-bottom: 1px solid var(--line); }
}

@media (max-width: 600px) {
  .masthead {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 24px 0 14px;
  }

  .masthead h1 { font-size: 1.625rem; }
  .masthead h1 img { width: 34px; height: 34px; }
  .segmented span { min-height: 34px; }

  .chapter { padding-inline: 5px; font-size: 12px; }
  .player-controls { padding-inline: 8px; }
  .play-orb { width: 46px; height: 46px; }

  .lesson-actions:has(.help[open]) { flex-wrap: wrap; }
  .lesson-actions .help[open] { flex-basis: 100%; }
  .lesson-actions .step-controls { margin-inline-start: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
