@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@import '/assets/f47cf25678047dc1d0c5372c25b330b4ffdf35604610caa62c68ff9ad26b877e/components/_internal/media-controls.css';
@layer cinder.components {
  .cinder-video-player {
    display: grid;
    gap: var(--cinder-space-2);
    max-inline-size: 100%;
  }

  .cinder-video-player__media {
    display: block;
    inline-size: 100%;
    max-inline-size: 100%;
    border-radius: var(--cinder-radius-md);
    background-color: var(--cinder-surface-inset);
  }

  .cinder-video-player__controls {
    inline-size: 100%;
  }

  /* Markers lie over the seek slider, inset by half its thumb so a marker and the thumb at the
     same time line up. The layer lets the slider take a press between markers. */
  .cinder-video-player__markers {
    position: absolute;
    inset-block: 0;
    inset-inline: var(--_cinder-media-controls-thumb-half);
    pointer-events: none;
  }

  /* A numbered badge centred on its moment. Close markers overlap: the later one paints over the
     earlier, and the tab order reaches both. */
  .cinder-video-player__marker {
    position: absolute;
    inset-block-start: 50%;
    translate: -50% -50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-inline-size: var(--cinder-space-5);
    block-size: var(--cinder-space-5);
    padding-inline: var(--cinder-space-1);
    border: 2px solid var(--cinder-surface);
    border-radius: var(--cinder-radius-full, 9999px);
    background-color: var(--cinder-accent-solid);
    color: var(--cinder-accent-contrast);
    font: inherit;
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-semibold);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    cursor: pointer;
    pointer-events: auto;
  }
  .cinder-video-player__marker:where(
    :not([dir='rtl'], [dir='rtl'] *),
    [dir='rtl'] [dir='ltr'],
    [dir='rtl'] [dir='ltr'] *
  ) {
    left: var(--_cinder-video-player-marker-position);
  }
  .cinder-video-player__marker:where(
    :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
  ) {
    right: var(--_cinder-video-player-marker-position);
  }

  .cinder-video-player__marker:is([dir='rtl'], [dir='rtl'] *):where(
      :not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    translate: 50% -50%;
  }

  /* The marker reaches 24px under a mouse and 44px under a coarse pointer through a pseudo-element
     that takes no layout space. */
  .cinder-video-player__marker::after {
    content: '';
    position: absolute;
    inset-block: min(0px, calc((100% - var(--_cinder-video-player-marker-target)) / 2));
    inset-inline: min(0px, calc((100% - var(--_cinder-video-player-marker-target)) / 2));
  }

  .cinder-video-player {
    --_cinder-video-player-marker-target: var(--cinder-space-6);
  }

  /* The playback position, drawn over the markers as a bar taller than a badge, so the thumb
     under a marker at the current time still shows. It lies at the same arithmetic as a marker
     and takes no pointer, so the marker under it still takes a press. */
  .cinder-video-player__playhead {
    position: absolute;
    z-index: 1;
    inset-block-start: 50%;
    translate: -50% -50%;
    inline-size: var(--cinder-space-1);
    block-size: var(--cinder-space-7);
    border-radius: var(--cinder-radius-full, 9999px);
    background-color: var(--cinder-text-default);
    box-shadow: 0 0 0 2px var(--cinder-surface);
    pointer-events: none;
  }
  .cinder-video-player__playhead:where(
    :not([dir='rtl'], [dir='rtl'] *),
    [dir='rtl'] [dir='ltr'],
    [dir='rtl'] [dir='ltr'] *
  ) {
    left: var(--_cinder-video-player-marker-position);
  }
  .cinder-video-player__playhead:where(
    :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
  ) {
    right: var(--_cinder-video-player-marker-position);
  }

  .cinder-video-player__playhead:is([dir='rtl'], [dir='rtl'] *):where(
      :not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    translate: 50% -50%;
  }

  /* Once the playhead is drawn it is the one mark of the position: the slider's own thumb turns
     invisible but keeps its size, so the input's travel, value, pointer and keys are unchanged.
     Each engine's thumb takes its own rule, since one unknown pseudo-element drops a whole list. */
  .cinder-video-player
    .cinder-media-controls__track:has(.cinder-video-player__playhead)
    .cinder-media-controls__seek::-webkit-slider-thumb {
    opacity: 0;
  }

  .cinder-video-player
    .cinder-media-controls__track:has(.cinder-video-player__playhead)
    .cinder-media-controls__seek::-moz-range-thumb {
    opacity: 0;
  }

  /* With no visible thumb, the slider's focus shows on the whole track instead of the input. */
  .cinder-video-player .cinder-media-controls__track {
    border-radius: var(--cinder-radius-md);
  }

  .cinder-video-player .cinder-media-controls__track .cinder-media-controls__seek:focus-visible {
    outline: none;
  }

  .cinder-video-player
    .cinder-media-controls__track:has(.cinder-media-controls__seek:focus-visible) {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
      0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width)) var(--cinder-ring-color);
  }

  @media (forced-colors: active) {
    .cinder-video-player
      .cinder-media-controls__track:has(.cinder-media-controls__seek:focus-visible) {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: var(--cinder-ring-offset);
      box-shadow: none;
    }
  }

  /* A coarse pointer reaches each marker through a 44px target that takes no layout space. The
     player keeps its fine-pointer gap. */
  @media (any-pointer: coarse) {
    .cinder-video-player {
      --_cinder-video-player-marker-target: var(--cinder-touch-target-min);
    }
  }

  .cinder-video-player__marker:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
      0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width)) var(--cinder-ring-color);
  }

  @media (forced-colors: active) {
    .cinder-video-player__marker {
      border-color: ButtonBorder;
    }

    .cinder-video-player__marker:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 3px;
      box-shadow: none;
    }

    .cinder-video-player__playhead {
      background-color: CanvasText;
      box-shadow: 0 0 0 2px Canvas;
    }
  }

  /* Chapters: a flat wrapping row of start times and titles, none marked active. */
  .cinder-video-player__chapters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--cinder-space-2);
  }

  .cinder-video-player__chapter {
    display: inline-flex;
    align-items: center;
    gap: var(--cinder-space-2);
    /* The painted small height on every pointer: a coarse pointer raises the control heights to
       44px, and the chapter reaches 44px through its no-space hit area instead. */
    min-block-size: var(--_cinder-painted-height-sm);
    padding-inline: var(--cinder-space-2);
    border: 0;
    border-radius: var(--cinder-radius-md);
    background-color: transparent;
    color: var(--cinder-text-default);
    font: inherit;
    font-size: var(--cinder-text-sm);
    cursor: pointer;
    transition: background-color var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  @media (hover: hover) {
    .cinder-video-player__chapter:hover {
      background-color: var(--cinder-accent-background);
    }
  }

  .cinder-video-player__chapter:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
      0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width)) var(--cinder-ring-color);
  }

  @media (forced-colors: active) {
    .cinder-video-player__chapter:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 2px;
      box-shadow: none;
    }
  }

  .cinder-video-player__chapter-time {
    color: var(--cinder-text-muted);
    font-variant-numeric: tabular-nums;
  }

  /* A coarse pointer reaches each chapter through a 44px hit area that takes no layout space. Two
     44px targets meet when their centres stand 44px apart: wrapped chapter rows step by that, and
     the chapters stand a further gap below the controls so the last controls row (a 28px small
     Button at its shortest) and the first chapter row stand 44px apart too. */
  @media (any-pointer: coarse) {
    .cinder-video-player__chapters {
      row-gap: calc(var(--cinder-touch-target-min) - var(--_cinder-painted-height-sm));
      margin-block-start: var(--cinder-space-2);
    }

    .cinder-video-player__chapter {
      position: relative;
    }

    .cinder-video-player__chapter::after {
      content: '';
      position: absolute;
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }
  }

  /* Full screen holds the whole player: the video takes the free height and the controls stay
     under it on the page surface rather than the browser's black backdrop. */
  .cinder-video-player:fullscreen {
    grid-template-rows: minmax(0, 1fr) auto;
    padding: var(--cinder-space-4);
    background-color: var(--cinder-surface);
  }

  .cinder-video-player:fullscreen .cinder-video-player__media {
    block-size: 100%;
    object-fit: contain;
  }
}
