/* The demonstration on the project page (index.html, #demo): the video with its chapters, a list
   of chapters per part beside the player, and controls under the picture. Every rule is scoped to
   .walkthrough, so Bulma and index.css keep the rest of the page; the colours, radius and shadow
   are those of the page. */

.walkthrough {
  --ground: var(--owrt-alt);
  --surface: #ffffff;
  --text: var(--owrt-ink);
  --muted: var(--owrt-muted);
  --faint: #8a94a8;
  --accent: var(--owrt-accent);
  --accent-hover: #1a5fd0;
  --accent-soft: rgba(31, 111, 235, 0.1);
  --focus: rgba(31, 111, 235, 0.5);
  --hairline: #e6e9f0;
  --fill: rgba(20, 33, 61, 0.07);
  --shadow-card: 0 18px 50px rgba(20, 33, 61, 0.16);
  --shadow-raised: 0 1px 2px rgba(20, 33, 61, 0.06), 0 4px 14px rgba(20, 33, 61, 0.08);
  --glass: rgba(20, 33, 61, 0.6);
  --radius: var(--owrt-radius);
  --radius-row: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

.walkthrough :where(img, svg, video) {
  display: block;
}

:where(.walkthrough) button {
  font: inherit;
  color: inherit;
}

.walkthrough :focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.walkthrough .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.walkthrough-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  grid-template-areas: "menu player";
  gap: 26px 28px;
  align-items: start;
  text-align: left;
}

/* The player is one card: the picture, and the controls under it, so they never cover the
   captions the video draws at its foot. */
.walkthrough .player {
  --strip: 58px;
  grid-area: player;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  isolation: isolate;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.walkthrough .screen {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--ground);
}

.walkthrough .screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: var(--ground);
}

/* Without the chapter list the player keeps the browser's own controls. */
.walkthrough.is-fallback .controls,
.walkthrough.is-fallback .screen-play,
.walkthrough.is-fallback .walkthrough-menu {
  display: none;
}

.walkthrough.is-fallback .walkthrough-grid {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "player";
}

.walkthrough-fallback {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  background: #000000;
  box-shadow: var(--shadow-card);
}

/* Full screen shows the video alone, on black, or the video with its chapter list, on the page's
   ground. Both views fill the screen with the grid, so switching between them keeps full screen. */
.walkthrough-grid[data-view="video"]:fullscreen {
  display: flex;
  align-items: stretch;
  padding: 0;
  background: #000000;
}

.walkthrough-grid[data-view="video"]:fullscreen .walkthrough-menu {
  display: none;
}

.walkthrough-grid[data-view="video"]:fullscreen .player {
  flex: 1;
  border-radius: 0;
  background: #000000;
  box-shadow: none;
}

.walkthrough-grid[data-view="video"]:fullscreen .screen {
  flex: 1;
  aspect-ratio: auto;
  background: #000000;
}

.walkthrough-grid[data-view="video"]:fullscreen video {
  object-fit: contain;
  background: #000000;
}

.walkthrough-grid[data-view="video"]:fullscreen .player[data-idle] {
  cursor: none;
}

/* With its chapter list the player stays a card with the controls under the picture, as large as
   the screen allows beside the list. */
.walkthrough-grid[data-view="chapters"]:fullscreen {
  --pad: clamp(16px, 3vw, 48px);
  grid-template-columns: clamp(260px, 26vw, 380px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "menu player";
  gap: clamp(16px, 2.8vw, 48px);
  align-items: center;
  padding: var(--pad);
  background: var(--ground);
}

.walkthrough-grid[data-view="chapters"]:fullscreen .walkthrough-menu {
  align-self: stretch;
  min-height: 0;
  margin: 0;
}

.walkthrough-grid[data-view="chapters"]:fullscreen .walkthrough-panel {
  position: absolute;
}

.walkthrough-grid[data-view="chapters"]:fullscreen .chapters {
  overflow-y: auto;
}

.walkthrough-grid[data-view="chapters"]:fullscreen .player {
  justify-self: center;
  width: min(100%, calc((100vh - 2 * var(--pad) - var(--strip)) * 16 / 9));
}

/* On a screen taller than wide the list goes under the player. */
@media (orientation: portrait) {
  .walkthrough-grid[data-view="chapters"]:fullscreen {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    grid-template-areas:
      "player"
      "menu";
    align-items: start;
  }

  .walkthrough-grid[data-view="chapters"]:fullscreen .player {
    width: 100%;
  }
}

/* The play button sits in the corner the video leaves empty. */
.walkthrough .screen-play {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 36px);
  height: 44px;
  padding: 0 17px 0 15px;
  border: 0;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  color: #ffffff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.45s var(--ease), background 0.2s ease;
}

.walkthrough .screen-play:hover {
  background: rgba(20, 33, 61, 0.74);
}

.walkthrough .screen-play svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.walkthrough .screen-play-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.walkthrough .player[data-playing] .screen-play {
  opacity: 0;
  transform: scale(0.92);
  pointer-events: none;
}

.walkthrough .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(20, 33, 61, 0.14);
  border-top-color: rgba(20, 33, 61, 0.62);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  animation: walkthrough-spin 0.9s linear infinite;
}

.walkthrough .player[data-waiting] .spinner {
  opacity: 1;
}

@keyframes walkthrough-spin {
  to {
    transform: rotate(360deg);
  }
}

.walkthrough .player-message {
  position: absolute;
  inset: auto 24px 24px;
  z-index: 4;
  margin: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-raised);
  font-size: 15px;
}

.walkthrough .player-message a {
  color: var(--accent);
}

.walkthrough .controls {
  --control: var(--text);
  --control-hover: var(--fill);
  --track: rgba(20, 33, 61, 0.12);
  --track-hover: rgba(20, 33, 61, 0.24);
  --played: var(--accent);
  --time: var(--muted);
  position: relative;
  z-index: 4;
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
  height: var(--strip);
  padding: 0 14px;
  border-top: 1px solid var(--hairline);
  background: var(--surface);
  color: var(--control);
  transition: opacity 0.4s var(--ease), transform 0.4s var(--ease);
}

/* With the video alone in full screen the controls float over the picture and fade out while it
   plays. */
.walkthrough-grid[data-view="video"]:fullscreen .controls {
  --control: #ffffff;
  --control-hover: rgba(255, 255, 255, 0.14);
  --track: rgba(255, 255, 255, 0.3);
  --track-hover: rgba(255, 255, 255, 0.5);
  --played: #ffffff;
  --time: rgba(255, 255, 255, 0.86);
  position: absolute;
  right: 24px;
  bottom: 24px;
  left: 24px;
  border: 0;
  border-radius: 18px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}

.walkthrough-grid[data-view="video"]:fullscreen .player[data-idle] .controls {
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
}

.walkthrough .player-control {
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--control);
  cursor: pointer;
  transition: background 0.2s ease;
}

.walkthrough .player-control:hover {
  background: var(--control-hover);
}

.walkthrough .player-control[hidden] {
  display: none;
}

/* The chapter view of full screen, while it is shown. */
.walkthrough .player-control[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.walkthrough .player-control svg {
  width: 20px;
  height: 20px;
}

.walkthrough .control-icon {
  display: grid;
  place-items: center;
}

.walkthrough .control-label {
  display: none;
}

/* After a chapter that "Pause after each chapter" stopped, the play button names the next one,
   in the control bar so the picture and its caption stay clear. */
.walkthrough .player[data-held] .control-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: auto;
  max-width: 46%;
  padding: 0 15px 0 11px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
}

.walkthrough .player[data-held] .control-toggle:hover {
  background: var(--accent-hover);
}

.walkthrough .player[data-held] .control-label {
  display: block;
  overflow: hidden;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.walkthrough .player[data-held] .screen-play {
  opacity: 0;
  pointer-events: none;
}

.walkthrough .player-control[data-action="previous"] svg,
.walkthrough .player-control[data-action="next"] svg {
  width: 18px;
  height: 18px;
}

.walkthrough .scrubber {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  gap: 3px;
  min-width: 0;
  height: 38px;
  margin: 0 10px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
}

.walkthrough .segment {
  position: relative;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--track);
  transition: height 0.25s var(--ease), background 0.2s ease;
}

.walkthrough .segment > i {
  position: absolute;
  inset: 0;
  background: var(--played);
  transform: scaleX(var(--fill, 0));
  transform-origin: left center;
}

.walkthrough .scrubber:hover .segment,
.walkthrough .scrubber.is-dragging .segment,
.walkthrough .scrubber:focus-visible .segment {
  height: 6px;
}

.walkthrough .segment.is-hover {
  background: var(--track-hover);
}

.walkthrough .time {
  padding: 0 6px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
  color: var(--time);
}

.walkthrough .preview {
  position: absolute;
  bottom: calc(var(--strip) + 14px);
  left: 0;
  z-index: 5;
  width: 208px;
  padding: 6px;
  border-radius: 16px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  color: #ffffff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.3s var(--ease);
}

.walkthrough .preview.is-visible {
  opacity: 1;
  transform: none;
}

.walkthrough-grid[data-view="video"]:fullscreen .preview {
  bottom: calc(var(--strip) + 40px);
}

.walkthrough .preview img {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  border-radius: 11px;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.1);
}

.walkthrough .preview-title {
  margin: 8px 5px 0;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.walkthrough .preview-time {
  margin: 1px 5px 3px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.72);
}

/* Chapter list: one list per part. The chapter being played opens to the caption the video shows
   under the recording: what is done, and in blue the design choice behind it. */

.walkthrough .badge {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  border-radius: 50%;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.walkthrough .badge svg.glyph {
  width: 38%;
  height: 38%;
  margin-left: 6%;
}

@keyframes walkthrough-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

.walkthrough .walkthrough-menu {
  grid-area: menu;
  position: relative;
  align-self: stretch;
  min-height: 360px;
}

.walkthrough .walkthrough-panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.walkthrough .segmented {
  position: relative;
  display: grid;
  flex: none;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  padding: 3px;
  border-radius: 12px;
  background: var(--fill);
}

.walkthrough .segmented-thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc((100% - 6px) / var(--count, 4));
  border-radius: 9px;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 33, 61, 0.06), 0 3px 8px rgba(20, 33, 61, 0.08);
  transform: translateX(calc(var(--index, 0) * 100%));
  transition: transform 0.5s var(--ease);
}

.walkthrough .segmented button {
  position: relative;
  z-index: 1;
  height: 34px;
  padding: 0 6px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.25s ease;
}

.walkthrough .segmented button:hover,
.walkthrough .segmented button[aria-pressed="true"] {
  color: var(--text);
}

.walkthrough .segmented button.is-playing::after {
  content: "";
  position: absolute;
  top: 7px;
  right: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.walkthrough .chapters {
  flex: 1;
  min-height: 0;
  margin: 0 -6px;
  padding: 2px 6px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(20, 33, 61, 0.18) transparent;
}

.walkthrough .chapter-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.walkthrough .chapter-list[hidden] {
  display: none;
}

.walkthrough .chapter-list.is-entering {
  animation: walkthrough-rise 0.5s var(--ease);
}

.walkthrough .chapter-item {
  border-radius: var(--radius-row);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.walkthrough .chapter-item:hover {
  background: rgba(255, 255, 255, 0.72);
}

.walkthrough .chapter-item.is-current {
  background: var(--surface);
  box-shadow: var(--shadow-raised);
}

.walkthrough .chapter {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 50px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-row);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

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

/* The focus ring goes round the whole chapter, its open text included. */
@supports selector(:has(*)) {
  .walkthrough .chapter:focus-visible {
    outline: none;
  }

  .walkthrough .chapter-item:has(.chapter:focus-visible) {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
  }
}

.walkthrough .chapter-detail {
  display: grid;
  grid-template-rows: 0fr;
  visibility: hidden;
  transition: grid-template-rows 0.5s var(--ease), visibility 0s linear 0.5s;
}

.walkthrough .is-current .chapter-detail {
  grid-template-rows: 1fr;
  visibility: visible;
  transition: grid-template-rows 0.5s var(--ease), visibility 0s;
}

.walkthrough .chapter-detail > div {
  min-height: 0;
  overflow: hidden;
}

.walkthrough .chapter-detail p {
  margin: 0;
  padding: 0 16px 0 55px;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: -0.006em;
  color: var(--text);
}

.walkthrough .chapter-detail p:last-child {
  padding-bottom: 14px;
}

.walkthrough .chapter-detail .chapter-note {
  margin-top: 5px;
  color: var(--accent);
}

.walkthrough .chapter .badge {
  width: 30px;
  height: 30px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  transition: background 0.25s ease, color 0.25s ease;
}

.walkthrough .chapter[aria-current="true"] .badge {
  background: var(--accent);
  color: #ffffff;
}

.walkthrough .ring {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  overflow: visible;
  opacity: 0;
  transform: rotate(-90deg);
  transition: opacity 0.3s ease;
}

.walkthrough .ring circle {
  fill: none;
  stroke-width: 2;
}

.walkthrough .ring-track {
  stroke: rgba(31, 111, 235, 0.16);
}

.walkthrough .ring-bar {
  stroke: var(--accent);
  stroke-dasharray: 100;
  stroke-dashoffset: calc(100 - var(--progress, 0) * 100);
}

.walkthrough .chapter[aria-current="true"] .ring {
  opacity: 1;
}

.walkthrough .chapter-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.012em;
  color: var(--text);
}

.walkthrough .chapter[aria-current="true"] .chapter-title {
  font-weight: 600;
}

.walkthrough .chapter-time {
  flex: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--faint);
}

.walkthrough .option {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 0;
  border-top: 1px solid var(--hairline);
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}

.walkthrough .switch {
  position: relative;
  flex: none;
  width: 42px;
  height: 25px;
  margin: 0;
  border-radius: 13px;
  background: rgba(20, 33, 61, 0.2);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background 0.3s ease;
}

.walkthrough .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18), 0 0 1px rgba(0, 0, 0, 0.12);
  transition: transform 0.35s var(--ease);
}

.walkthrough .switch:checked {
  background: var(--accent);
}

.walkthrough .switch:checked::after {
  transform: translateX(17px);
}

/* Layouts. Two columns need the 1152 px container Bulma gives from 1216 px on. */

@media (max-width: 1215px) {
  .walkthrough-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "player"
      "menu";
  }

  .walkthrough .walkthrough-menu {
    min-height: 0;
    margin-top: 8px;
  }

  .walkthrough .walkthrough-panel {
    position: static;
  }

  .walkthrough .chapters {
    overflow: visible;
  }
}

@media (max-width: 734px) {
  .walkthrough .screen-play {
    right: 10px;
    bottom: 10px;
    max-width: calc(100% - 20px);
    height: 38px;
    padding: 0 14px 0 12px;
    font-size: 14px;
  }

  .walkthrough .player {
    --strip: 50px;
  }

  .walkthrough .controls {
    padding: 0 6px;
  }

  .walkthrough .player-control {
    width: 34px;
    height: 34px;
  }

  .walkthrough .player-control[data-action="previous"],
  .walkthrough .player-control[data-action="next"] {
    display: none;
  }

  .walkthrough .scrubber {
    margin: 0 6px;
  }

  .walkthrough .time .time-total {
    display: none;
  }

  .walkthrough .preview {
    display: none;
  }

  .walkthrough .chapter-detail p {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .walkthrough *,
  .walkthrough *::before,
  .walkthrough *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
