/* The video player with the glass preview on the bar: the player of a product keynote on a near black page. The
   frames of the film are drawn on a canvas; over them sit the controls and the timeline, made of one segment per
   chapter. Hovering the bar the segments swell, a light sits under the pointer and a frosted glass preview follows it.
   Sizes come from the width and the height of the window, so the player fits a phone box too. */
:root {
  --page: #08080a;            /* the page */
  --shell: #141418;           /* the body of the player */
  --edge: rgba(255, 255, 255, 0.075); /* its 1px edge */
  --ink: #f2f2f4;             /* the words */
  --muted: #8d8d98;           /* the small words */
  --accent: #ff7a45;          /* the played part of the bar and its glow */
  --track: rgba(255, 255, 255, 0.2);  /* the bar not played yet */
  --loaded: rgba(255, 255, 255, 0.34); /* the bar already loaded */
  --glass: rgba(18, 18, 24, 0.44);     /* the glass of the preview */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.035), transparent 60%),
    var(--page);
}

/* the ambient light of the film on the page, behind the player: its colours come from the frame on screen */
.halo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(90vw, 760px);
  height: min(60vh, 420px);
  margin: calc(min(60vh, 420px) / -2) 0 0 calc(min(90vw, 760px) / -2);
  border-radius: 50%;
  background:
    radial-gradient(closest-side at 32% 50%, var(--h1, #3b2bd6), transparent),
    radial-gradient(closest-side at 70% 55%, var(--h2, #ff6a3d), transparent);
  filter: blur(60px);
  opacity: 0;
  pointer-events: none;
}

.player {
  position: relative;
  width: min(92vw, 660px, calc((100vh - 118px) * 1.62));
  padding: clamp(5px, 1.4vw, 7px);
  border-radius: clamp(16px, 3.4vw, 22px);
  background: linear-gradient(180deg, #1a1a1f, var(--shell) 40%, #111114);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 12px 24px -10px rgba(0, 0, 0, 0.7),
    0 40px 80px -30px rgba(0, 0, 0, 0.9);
  opacity: 0;
}

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: clamp(11px, 2.6vw, 16px);
  overflow: hidden;
  background: #0b0a1a;
  isolation: isolate;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6);
}

.screen__frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.screen__frame--next {
  opacity: 0;
}

/* a fine grain over the film, like a real encode */
.screen__grain {
  position: absolute;
  inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.09;
  mix-blend-mode: overlay;
  pointer-events: none;
}

.screen__scrim {
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.22) 55%, transparent);
  pointer-events: none;
}

.screen__chip {
  position: absolute;
  left: clamp(8px, 2.4vw, 14px);
  top: clamp(8px, 2.4vw, 14px);
  padding: 4px 9px 5px;
  border-radius: 999px;
  font-size: clamp(9.5px, 2.4vw, 11px);
  font-weight: 560;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(10, 10, 14, 0.32);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
}

/* ---------------------------------------------------------------- the controls */
.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.8vw, 12px);
  padding: 0 clamp(8px, 2.4vw, 14px) clamp(6px, 1.6vw, 10px);
  z-index: 3;
}

.ctl {
  flex: none;
  width: clamp(24px, 6vw, 30px);
  height: clamp(24px, 6vw, 30px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ctl svg {
  width: 62%;
  height: 62%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.ctl__tri {
  fill: currentColor;
  opacity: 0;
}

.ctl--sound {
  opacity: 0.86;
}

@media (hover: hover) {
  .ctl:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

.ctl:focus-visible,
.bar:focus-visible {
  outline: 1.5px solid rgba(255, 255, 255, 0.7);
  outline-offset: 2px;
}

.clock {
  flex: none;
  font-size: clamp(9.5px, 2.5vw, 11.5px);
  font-weight: 520;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.92);
  white-space: nowrap;
}

.clock__sep {
  margin: 0 3px;
  color: rgba(255, 255, 255, 0.45);
}

/* the timeline: a tall hit area with the thin track in its middle */
.bar {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 24px;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.bar__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 0;
  display: flex;
  align-items: center;
  gap: 3px;
}

.seg {
  position: relative;
  height: 4px;
  min-width: 2px;
  border-radius: 3px;
  overflow: hidden;
  background: var(--track);
  box-shadow: inset 0 0.5px 0 rgba(255, 255, 255, 0.12);
}

.seg__load,
.seg__fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.seg__load {
  background: var(--loaded);
}

.seg__fill {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 80%, #ffffff), #ffffff);
}

/* the light under the pointer, and the thin ghost of a playhead */
.bar__glint {
  position: absolute;
  left: 0;
  top: 50%;
  width: 120px;
  height: 26px;
  margin: -13px 0 0 -60px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.5), color-mix(in srgb, var(--accent) 30%, transparent) 45%, transparent);
  mix-blend-mode: screen;
  opacity: 0;
  pointer-events: none;
}

.bar__ghost {
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 16px;
  margin: -8px 0 0 -0.5px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.9) 35%, rgba(255, 255, 255, 0.9) 65%, transparent);
  opacity: 0;
  pointer-events: none;
}

.bar__knob {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
}

.bar__knob-in {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffffff, #f1f1f3 60%, #d9d9de);
  box-shadow:
    0 0 0 0.5px rgba(0, 0, 0, 0.25),
    0 1px 3px rgba(0, 0, 0, 0.45),
    0 0 14px color-mix(in srgb, var(--accent) 70%, transparent);
  transform: scale(0);
}

/* ---------------------------------------------------------------- the glass preview */
.bubble {
  position: absolute;
  left: 0;
  bottom: calc(clamp(6px, 1.6vw, 10px) + 34px);
  width: clamp(104px, 27%, 172px);
  z-index: 4;
  opacity: 0;
  pointer-events: none;
  transform-origin: 50% 100%;
}

.bubble__tilt {
  position: relative;
  padding: 4px 4px 0;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02) 40%), var(--glass);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.25),
    0 14px 30px -8px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  transform-origin: 50% 100%;
}

/* a short highlight on the top edge of the glass, pushed by the preview's speed */
.bubble__glare {
  position: absolute;
  left: 0;
  top: 0;
  width: 60%;
  height: 1px;
  margin-left: 20%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  pointer-events: none;
}

.bubble__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.bubble__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 4px 6px;
}

.bubble__name {
  position: relative;
  min-width: 0;
  overflow: hidden;
  font-size: clamp(9px, 2.3vw, 11px);
  font-weight: 600;
  font-stretch: 104%;
  color: #ffffff;
  white-space: nowrap;
}

.bubble__name-in {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bubble__time {
  flex: none;
  font-size: clamp(9px, 2.2vw, 10.5px);
  font-weight: 520;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.7);
}

/* ---------------------------------------------------------------- under the film */
.meta {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: clamp(7px, 1.8vh, 11px) clamp(5px, 1.4vw, 9px) clamp(3px, 1vh, 5px);
}

.meta__mark {
  flex: none;
  width: clamp(26px, 6.4vw, 32px);
  height: clamp(26px, 6.4vw, 32px);
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(145deg, #2a2a31, #16161a);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.4);
}

.meta__mark svg {
  width: 52%;
  height: 52%;
  fill: var(--accent);
}

.meta__words {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.meta__title {
  font-size: clamp(11.5px, 3vw, 14px);
  font-weight: 620;
  font-stretch: 106%;
  letter-spacing: -0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta__sub {
  font-size: clamp(9.5px, 2.4vw, 11.5px);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta__hd {
  flex: none;
  padding: 3px 7px;
  border-radius: 6px;
  font-size: clamp(9px, 2.2vw, 10px);
  font-weight: 650;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.74);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
