/* stage-carousel.css — long-horizon stage player (see static/js/stage-carousel.js).
   Reads the page tokens from attacca.css (--primary-color, --text-*, --border-*), with fallbacks. */

.stage-carousel {
  --sc-slide-ms: 380ms;
  --sc-accent: var(--primary-color, #2563eb);
  --sc-muted: var(--text-secondary, #64748b);
  --sc-radius: var(--border-radius, 12px);
  position: relative;
  outline: none;
}
.stage-carousel[hidden] { display: none; }

/* ---- player ---------------------------------------------------------------------------------- */

.sc-viewport {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0b0f17;
  border-radius: var(--sc-radius);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgb(0 0 0 / 0.1));
  isolation: isolate;
}
@supports not (aspect-ratio: 16 / 9) {
  .sc-viewport { height: 0; padding-bottom: 56.25%; }
  .sc-track { position: absolute; inset: 0; }
}

.sc-track {
  display: flex;
  width: 100%;
  height: 100%;
  transform: translate3d(0, 0, 0);
  transition: transform var(--sc-slide-ms) cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.sc-slide {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  margin: 0;
}

/* the clip's video layer is transparent where it has no frame (the viewport colour, or the underlay) */
.sc-slide video {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
}

/* underlay: the clip's poster (= its first frame = the hand-off frame) painted under the video, in the
   video's box and fit, so a moment without a video frame (a re-entered clip at a cut) shows that frame
   instead of an empty player; hidden once the clip has played past its opening hold */
.sc-under {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}
.sc-slide.sc-past-start .sc-under { visibility: hidden; }

/* crossfade still (a canvas copy of the outgoing frame, or its poster), faded out over the next clip;
   the duration is set inline by stage-carousel.js */
.sc-fade {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  opacity: 1;
  transition-property: opacity;
  transition-timing-function: ease-out;
}
.sc-fade.is-out { opacity: 0; }

/* arrows sit at mid-height: the phase chip is top-left and the goal inset top-right in every clip */
.sc-arrow,
.sc-playpause {
  position: absolute;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.2s, background-color 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.sc-arrow { top: 50%; width: 44px; height: 44px; transform: translateY(-50%); }
.sc-prev { left: 10px; }
.sc-next { right: 10px; }
.sc-playpause { left: 10px; bottom: 10px; width: 36px; height: 36px; }
.sc-arrow svg { width: 22px; height: 22px; }
.sc-playpause svg { width: 16px; height: 16px; }
.sc-arrow:hover,
.sc-playpause:hover { opacity: 1; background: rgba(15, 23, 42, 0.8); }
.sc-arrow:focus-visible,
.sc-playpause:focus-visible,
.sc-step:focus-visible {
  outline: 3px solid #facc15;
  outline-offset: 2px;
  opacity: 1;
}
.sc-playpause .sc-icon-play { display: none; }
.sc-playpause.is-paused .sc-icon-play { display: block; }
.sc-playpause.is-paused .sc-icon-pause { display: none; }

/* ---- stage title under the player ------------------------------------------------------------ */

.sc-caption {
  margin: 0.9rem 0 0.75rem;
  text-align: center;
  line-height: 1.45;
  min-height: 2.9em;           /* one-line and two-line titles keep the stepper in place */
}
.sc-count {
  color: var(--sc-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.sc-sep { color: var(--sc-muted); padding: 0 0.35em; }
.sc-name {
  color: var(--text-primary, #1e293b);
  font-weight: 700;
}
.sc-note {
  display: block;
  font-size: 0.875rem;
  color: var(--sc-muted);
}
.sc-note[hidden] { display: none; }

/* ---- stepper of stage goal thumbnails -------------------------------------------------------- */

.sc-stepper {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}
.sc-stepper li {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 150px;
  margin: 0;
}
/* hand-off chevrons between consecutive stages */
.sc-stepper li + li::before {
  content: '';
  position: absolute;
  left: -0.47rem;
  top: calc((100% - 1.4rem) / 2 - 0.2rem);
  width: 0.34rem;
  height: 0.34rem;
  border-top: 2px solid #94a3b8;
  border-right: 2px solid #94a3b8;
  transform: rotate(45deg);
}

.sc-step {
  display: block;
  width: 100%;
  padding: 3px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
  opacity: 0.62;
  transition: opacity 0.2s, border-color 0.2s, background-color 0.2s;
}
.sc-step:hover { opacity: 0.9; background: var(--background-accent, #f1f5f9); }
.sc-step[aria-current='step'] {
  opacity: 1;
  border-color: var(--sc-accent);
  background: var(--background-secondary, #f8fafc);
}
.sc-step.is-done { opacity: 0.85; }

.sc-step-thumb {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 6px;
  background: #0b0f17;
}
.sc-step-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}
.sc-step-num {
  position: absolute;
  top: 4px;
  left: 4px;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.35rem;
  text-align: center;
}
.sc-step[aria-current='step'] .sc-step-num { background: var(--sc-accent); }

.sc-step-bar {
  display: block;
  height: 3px;
  margin: 4px 1px 0;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border-color, #e2e8f0);
}
.sc-step-bar i {
  display: block;
  height: 100%;
  background: var(--sc-accent);
  transform: scaleX(0);
  transform-origin: left center;
}
.sc-step.is-done .sc-step-bar i { background: #94a3b8; }

.sc-step-label {
  display: block;
  margin-top: 0.3rem;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--text-primary, #1e293b);
}

/* ---- chain tabs (Bulma .tabs.is-toggle, recoloured to the template's dark buttons) ----------- */

.lh-tabs.tabs { margin-bottom: 0.5rem; overflow: visible; }
.lh-tabs.tabs ul { flex-wrap: wrap; flex-shrink: 1; min-width: 0; justify-content: center; border-bottom: 0; }
.lh-tabs.tabs.is-toggle a {
  border-color: var(--border-color, #dbdbdb);
  color: var(--text-primary, #1e293b);
  font-weight: 600;
  white-space: nowrap;
}
.lh-tabs.tabs.is-toggle a:hover { background: var(--background-accent, #f1f5f9); }
.lh-tabs.tabs.is-toggle li.is-active a {
  background: var(--text-primary, #1e293b);
  border-color: var(--text-primary, #1e293b);
  color: #fff;
}
.lh-tabs.tabs.is-toggle a:focus-visible { outline: 3px solid #facc15; outline-offset: 2px; z-index: 2; }
.lh-tabs.tabs.is-toggle a:focus:not(:focus-visible),
.sc-step:focus:not(:focus-visible),
.sc-arrow:focus:not(:focus-visible),
.sc-playpause:focus:not(:focus-visible) { outline: none; }
.lh-chain-sub {
  margin: 0 0 1rem;
  text-align: center;
  font-size: 0.92rem;
  color: var(--sc-muted, #64748b);
}

/* ---- small screens --------------------------------------------------------------------------- */

@media screen and (max-width: 600px) {
  .sc-arrow { width: 36px; height: 36px; }
  .sc-arrow svg { width: 18px; height: 18px; }
  .sc-prev { left: 6px; }
  .sc-next { right: 6px; }
  .sc-playpause { left: 6px; bottom: 6px; width: 30px; height: 30px; }
  .sc-stepper { gap: 0.35rem; }
  .sc-stepper li + li::before { left: -0.3rem; width: 0.22rem; height: 0.22rem; border-width: 1.5px; top: calc(50% - 0.2rem); }
  .sc-step { padding: 2px; border-radius: 8px; }
  .sc-step-label { display: none; }
  .sc-step-num { top: 2px; left: 2px; min-width: 1.1rem; height: 1.1rem; line-height: 1.1rem; font-size: 0.65rem; padding: 0 0.2rem; }
  .sc-caption { font-size: 0.95rem; }
}
/* three equal tabs that may wrap their own text on phones */
@media screen and (max-width: 640px) {
  .lh-tabs.tabs ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: stretch; width: 100%; }
  .lh-tabs.tabs.is-toggle li + li { margin-left: -1px; }
  .lh-tabs.tabs.is-toggle a {
    height: 100%;
    padding: 0.45em 0.4em;
    font-size: 0.82rem;
    line-height: 1.25;
    white-space: normal;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-track,
  .sc-fade,
  .sc-step,
  .sc-arrow,
  .sc-playpause { transition: none !important; }
}
