/* Video player component: one look and behaviour for every "Play video(s)" link.
   Change it here and every player on the site changes. Uses the page's colour tokens
   (--ink, --muted, --rule, --paper). Markup and usage: see player.js. */

/* Icon in front of the "Play video" link */
.yt {
  width: 1.15em;
  height: 1.15em;
  margin-right: 0.3em;
  vertical-align: -0.22em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Panel over a white blur */
dialog.player {
  margin: auto;
  padding: 1.25rem;
  /* Almost full width, but never so wide that the video gets taller than the screen. */
  width: min(calc(100vw - 3rem), calc((100vh - 8rem) * 16 / 9 + 24rem));
  width: min(calc(100vw - 3rem), calc((100svh - 8rem) * 16 / 9 + 24rem));
  max-width: none;
  border: 1px solid var(--rule);
  border-radius: 0;
  background: var(--paper);
  color: var(--ink);
}
/* One video: only the video, no panel around it */
dialog.player.single {
  padding: 0;
  border: 0;
  width: min(calc(100vw - 3rem), calc((100vh - 3rem) * 16 / 9));
  width: min(calc(100vw - 3rem), calc((100svh - 3rem) * 16 / 9));
  background: #000;
}
dialog.player.single .pl { display: block; }
dialog.player::backdrop {
  background: color-mix(in srgb, var(--paper) 60%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

/* List on the left, video and Previous / Next on the right */
.pl { display: grid; grid-template-columns: 20rem 1fr; gap: 1.25rem; }
/* The list never makes the panel taller than the player: it scrolls inside the player's height. */
.pl .side { position: relative; min-height: 0; }
.pl .inner { position: absolute; inset: 0; display: flex; flex-direction: column; }
.pl .head { display: flex; justify-content: space-between; font-size: 0.8em; color: var(--muted); margin-bottom: 0.5em; }
.pl h3 { font: inherit; }
.pl ol { list-style: none; flex: 1; overflow-y: auto; scrollbar-width: thin; }
.pl .side::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3em;
  background: linear-gradient(transparent, var(--paper));
  pointer-events: none;
  transition: opacity 150ms;
}
.pl .side.end::after { opacity: 0; }
.pl ol button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6em;
  width: 100%;
  padding: 0.5em 0.55em;
  font: inherit;
  font-size: 0.85em;
  letter-spacing: inherit;
  text-align: left;
  color: var(--muted);
  background: none;
  border: 0;
  cursor: pointer;
  transition: color 120ms, background-color 120ms;
}
.pl ol button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 4%, transparent); }
.pl ol button[aria-current="true"] { color: var(--ink); font-weight: 600; background: color-mix(in srgb, var(--ink) 7%, transparent); }
/* Titles stay on one line; a cut-off title slides left on hover so it can be read in full. */
.pl .t { overflow: hidden; white-space: nowrap; }
.pl .t > span { display: inline-block; transition: transform 0.3s ease; }
.pl ol button:hover .t > span,
.pl ol button:focus-visible .t > span { transform: translateX(var(--shift, 0)); transition: transform var(--dur, 0s) linear 0.25s; }
.pl .t.cut { -webkit-mask-image: linear-gradient(to right, #000 80%, transparent); mask-image: linear-gradient(to right, #000 80%, transparent); }
.pl ol button:hover .t.cut,
.pl ol button:focus-visible .t.cut { -webkit-mask-image: none; mask-image: none; }
.pl .ic { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 1.2; stroke-linejoin: round; stroke-linecap: round; }
.pl .d { font-size: 0.85em; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.pl iframe { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; background: #000; }
/* Own video files: the video, and a thin bar that fades away while it plays. */
.vid { position: relative; aspect-ratio: 16 / 9; background: #000; overflow: hidden; }
.vid video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; cursor: pointer; }
.vid:fullscreen { aspect-ratio: auto; width: 100%; height: 100%; }
.vid .ctl {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 2rem 0.75rem 0.5rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
  color: #fff;
  font-size: 0.8rem;
  transition: opacity 300ms ease;
}
.vid.idle .ctl { opacity: 0; pointer-events: none; }
.vid.idle, .vid.idle video { cursor: none; }
.vid .ctl button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 120ms;
}
.vid .ctl button:hover, .vid .ctl a:hover { opacity: 1; }
.vid .ctl :focus-visible { outline: 1px solid rgba(255, 255, 255, 0.8); outline-offset: 2px; border-radius: 3px; }
.vid .ctl svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.vid .time { font-variant-numeric: tabular-nums; white-space: nowrap; opacity: 0.85; }
.vid .k4 { color: inherit; text-decoration: none; font-size: 0.7rem; letter-spacing: 0.02em; border: 1px solid currentColor; border-radius: 3px; padding: 0.05rem 0.3rem; opacity: 0.85; }
/* Progress: a 2px line, white up to where the video is. */
.vid .seek { flex: 1; min-width: 3rem; height: 1.5rem; margin: 0; background: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.vid .seek::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(to right, #fff var(--p, 0%), rgba(255, 255, 255, 0.35) var(--p, 0%)); }
.vid .seek::-webkit-slider-thumb { -webkit-appearance: none; width: 10px; height: 10px; margin-top: -4px; border-radius: 50%; background: #fff; border: 0; }
.vid .seek::-moz-range-track { height: 2px; background: rgba(255, 255, 255, 0.35); }
.vid .seek::-moz-range-progress { height: 2px; background: #fff; }
.vid .seek::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 0; }
@media (max-width: 30rem) { .vid .time { display: none; } }
.pl .bar { display: flex; align-items: center; justify-content: center; gap: 0.5em; margin-top: 0.6em; font-size: 0.85em; }
.pl .bar[hidden] { display: none; }
.pl .count { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: center; }
.pl .bar button {
  display: grid;
  place-items: center;
  width: 2.2em;
  height: 2.2em;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: color 120ms, background-color 120ms;
}
.pl .bar button svg { width: 1.3em; height: 1.3em; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.pl .bar button:hover:not(:disabled) { color: var(--ink); background: color-mix(in srgb, var(--ink) 6%, transparent); }
.pl .bar button:disabled { opacity: 0.3; cursor: default; }
/* Image gallery: small square thumbnails, the large image in the same panel */
.shots { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75em; }
.shots a { display: block; line-height: 0; border: 1px solid var(--rule); transition: border-color 120ms; }
.shots a:hover, .shots a:focus-visible { border-color: var(--ink); }
.shots img { width: 2.75rem; height: 2.75rem; object-fit: cover; }
dialog.player.gallery { width: min(72rem, calc(100% - 2.5rem)); }
.pl.gallery { display: block; }
.pl.gallery figure { line-height: 0; overflow: hidden; touch-action: pan-y pinch-zoom; }
.pl.gallery figure img { display: block; width: 100%; max-height: calc(100vh - 9rem); max-height: calc(100svh - 9rem); object-fit: contain; object-position: top; background: var(--paper); }
/* Posters: small upright thumbnails at their own shape; the large view fits the poster. */
.shots.posters { gap: 0.6rem; align-items: flex-end; }
.shots.posters img { width: auto; height: 7rem; object-fit: contain; }
dialog.player.gallery.fit { width: fit-content; max-width: calc(100vw - 3rem); }
dialog.player.gallery.fit figure img {
  --h: min(calc(100svh - 9rem), calc((100vw - 5.5rem) / var(--ar, 1)));
  width: calc(var(--h) * var(--ar, 1));
  height: var(--h);
  max-height: none;
  object-fit: contain;
}

/* Narrower windows: video on top, the list below it. The panel stays short enough
   that video, buttons and a few list entries fit on the screen. */
@media (max-width: 60rem) {
  dialog.player:not(.single):not(.gallery) {
    width: min(calc(100vw - 3rem), max(20rem, calc((100vh - 19rem) * 16 / 9)));
    width: min(calc(100vw - 3rem), max(20rem, calc((100svh - 19rem) * 16 / 9)));
  }
  .pl { grid-template-columns: 1fr; }
  .pl .player { order: -1; }
  .pl .inner { position: static; }
  .pl ol { max-height: 12em; }
}
