/* Exhibit: feature clips and screenshots share one stage, picked from a
   mini dock. js/shots.js builds one tile per .ex-clip figure. */

/* ---- Stage: a window playing the selected clip ---- */
.ex {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1080px;
  margin-inline: auto;
}

/* The flex containers below would otherwise override the hidden attribute. */
.ex[hidden],
.ex-dock[hidden] {
  display: none;
}

/* Space is kept but nothing shows until a clip's files check out. */
.ex.is-pending .ex-stage,
.ex.is-pending .ex-rail {
  visibility: hidden;
}

.ex-stage {
  position: relative;
  /* The clip ratio (2:1) keeps the stage from eating the viewport; the cap
     leaves room for the picker dock inside one 900px-tall window. */
  width: min(100%, calc((100svh - 430px) * 2));
  margin-inline: auto;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--r-win);
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(244, 236, 224, .04) inset,
    0 30px 70px -28px rgba(0, 0, 0, .7),
    0 10px 24px -12px rgba(0, 0, 0, .5);
}

/* All items share one grid cell once JS runs; without JS they stack. */
.ex-screen {
  display: grid;
}

.ex-clip {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin: 0;
}

.js .ex-clip {
  grid-area: 1 / 1;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 180ms var(--ease-out),
    visibility 0s linear 180ms;
}

.js .ex-clip.is-on {
  opacity: 1;
  visibility: visible;
  transition: opacity 180ms var(--ease-out);
}

/* Window title bar: clip name + one-line caption. */
.ex-cap {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: .75em;
  row-gap: 2px;
  min-height: 48px;
  padding: 12px 64px 12px 18px;
  border-bottom: 1px solid var(--line);
  font-size: .9375rem;
  line-height: 1.4;
  color: var(--bone-dim);
}

.ex-name {
  font-weight: 600;
  color: var(--bone);
  white-space: nowrap;
}

.ex-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1; /* matches the width/height attributes; no letterbox */
  object-fit: contain;
  background: var(--night);
}

.ex-toggle {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--bone);
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.ex-toggle:hover {
  border-color: var(--blue);
}

.ex-toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.ex-toggle svg {
  width: 16px;
  height: 16px;
}

.ex-toggle[aria-pressed="true"] .ex-i-play,
.ex-toggle[aria-pressed="false"] .ex-i-pause {
  display: none;
}

/* ---- Picker: a mini dock, one app-icon tile per clip ---- */
/* js/shots.js wraps the row in a rail that draws the edge chevrons. */
.ex-rail {
  --ex-tile: 60px;
  position: relative;
  align-self: stretch;
  margin-top: 24px;
}

.ex-dock {
  position: relative; /* offsetParent for tile centres */
  display: flex;
  gap: 6px;
  width: max-content;
  max-width: 100%;
  min-height: calc(var(--ex-tile) + 30px); /* face + indicator + label */
  margin: 0 auto;
  /* Top padding is the headroom a tile grows into. */
  padding: calc(var(--ex-tile) * .35 + 6px) 14px 8px;
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 16px 40px -22px rgba(0, 0, 0, .7);
  touch-action: pan-y pinch-zoom; /* horizontal drags scrub the zoom */
  /* Twelve tiles outgrow even the 1080px stage, so the row scrolls at every
     width; js/shots.js sets is-scroll and the has-more-* fades. */
  --ex-fade: 28px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 14px;
  scrollbar-width: none;
}

.ex-dock::-webkit-scrollbar {
  display: none;
}

/* Fade the edge that still hides tiles, so the row reads as scrollable. */
.ex-dock.has-more-end {
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - var(--ex-fade)), transparent);
  mask-image: linear-gradient(90deg, #000 calc(100% - var(--ex-fade)), transparent);
}

.ex-dock.has-more-start {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--ex-fade));
  mask-image: linear-gradient(90deg, transparent, #000 var(--ex-fade));
}

.ex-dock.has-more-start.has-more-end {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--ex-fade), #000 calc(100% - var(--ex-fade)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--ex-fade), #000 calc(100% - var(--ex-fade)), transparent);
}

/* A chevron sits in each fade while there is more row that way, and lights
   up while the pointer at that edge is gliding the row. */
.ex-rail::before,
.ex-rail::after {
  content: "";
  position: absolute;
  z-index: 1;
  top: calc(var(--ex-tile) * .85 + 7px); /* border + headroom + half a face */
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background-color: var(--bone-dim);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3l5 5-5 5' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 200ms var(--ease-out),
    background-color 200ms var(--ease-out);
}

.ex-rail::before {
  left: 4px;
  scale: -1 1;
}

.ex-rail::after {
  right: 4px;
}

.ex-rail.has-more-start::before,
.ex-rail.has-more-end::after {
  opacity: .6;
}

.ex-rail.is-edge-start::before,
.ex-rail.is-edge-end::after {
  opacity: 1;
  background-color: var(--blue);
}

/* Snapping would pull each small step of a hover, wheel or keyboard glide
   back, then tug the row once a glide ends. Snap is for fingers: a device
   with no touch pointer drops it; elsewhere it pauses while JS glides. */
.ex-dock.is-gliding {
  scroll-snap-type: none;
}

@media (hover: hover) and (pointer: fine) and (not (any-pointer: coarse)) {
  .ex-rail .ex-dock {
    scroll-snap-type: none;
  }
}

.ex-dock.is-scroll {
  touch-action: manipulation; /* the row scrolls natively instead */
}

/* Tiles appear as their files check out, in any order. Snapping before the
   first pick would pin whichever tile was ready first and drag the row to it. */
.ex.is-pending .ex-dock {
  scroll-snap-type: none;
}

.ex-tile {
  position: relative;
  flex: none;
  display: none; /* shown once the clip's files check out */
  flex-direction: column;
  align-items: center;
  width: calc(var(--ex-tile) + 24px);
  scroll-snap-align: center;
  padding: 0;
  margin: 0;
  color: var(--bone-dim);
  font: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ex-tile.is-ready {
  display: flex;
}

.ex-tile:focus-visible {
  outline: none;
}

.ex-face {
  position: relative;
  display: block;
  width: var(--ex-tile);
  height: var(--ex-tile);
  overflow: hidden;
  border-radius: var(--r-tile);
  background: linear-gradient(165deg, #533D2F, var(--ink) 78%);
  box-shadow:
    inset 0 1px 0 rgb(244 236 224 / .16),
    0 3px 8px -2px rgb(0 0 0 / .5);
  transform-origin: 50% 100%;
  transition: scale 200ms var(--ease-out), filter 160ms var(--ease-out);
}

/* Specular sweep, like the page dock's icons. */
.ex-face::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgb(255 255 255 / .1), transparent 46%);
  box-shadow: inset 0 0 0 1px rgb(244 236 224 / .08);
  pointer-events: none;
}

.ex-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 100%; /* the dock sits at the bottom of every clip */
  transform: scale(1.7);
  transform-origin: 50% 100%;
}

.ex-dock.is-tracking .ex-face {
  transition: filter 160ms var(--ease-out);
}

.ex-tile:hover .ex-face {
  filter: brightness(1.12);
}

.ex-tile:focus-visible .ex-face {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

/* Indicator: hidden -> running dot (watched) -> active pill (on stage). */
.ex-ind {
  width: 5px;
  height: 5px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--bone-dim);
  opacity: 0;
  scale: .4;
  transition:
    opacity 220ms var(--ease-out),
    scale 220ms var(--ease-out),
    width 220ms var(--ease-out),
    background-color 220ms;
}

.ex-tile.is-running .ex-ind {
  opacity: 1;
  scale: 1;
}

.ex-tile.is-active .ex-ind {
  width: 18px;
  height: 4px;
  opacity: 1;
  scale: 1;
  background: var(--blue);
  box-shadow: 0 0 10px var(--glow), 0 0 2px var(--blue);
}

.ex-label {
  max-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: .75rem;
  line-height: 16px;
}

.ex-tile.is-active .ex-label,
.ex-tile:hover .ex-label {
  color: var(--bone);
}

.ex-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---- Stills: a screenshot on the stage, in the clip's 2:1 frame ---- */
.ex-open {
  display: block;
  border-radius: 0;
  color: inherit;
}

.js .ex-open {
  cursor: zoom-in;
}

.ex-open:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -4px;
}

.ex-img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 1; /* same frame as the clips, so switching never resizes the stage */
  object-fit: contain;
  background: var(--night);
}

.ex-toggle:disabled {
  opacity: .35;
  cursor: default;
}

.ex-toggle:disabled:hover {
  border-color: var(--line);
}

.ex-toggle[hidden] {
  display: none;
}

/* Without JS only the screenshots show; the clips need JS to load. */
html:not(.js) .ex-clip:not(.ex-still) {
  display: none;
}

html:not(.js) .ex-screen {
  gap: 1px;
  background: var(--line);
}

html:not(.js) .ex-stage:not(:has(.ex-still)) {
  display: none;
}

/* ---- Lightbox ---- */
.ex-dialog {
  width: min(96vw, 1680px);
  max-width: none;
  max-height: 94vh;
  padding: 16px 16px 12px;
  background: var(--ink-2);
  color: var(--bone);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7);
  overflow: hidden;
}

.ex-dialog[open] {
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: ex-dialog-in 200ms var(--ease-out);
}

.ex-dialog::backdrop {
  background: rgba(17, 12, 9, .8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ex-dialog img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(94vh - 5.5rem);
  min-height: 0;
  object-fit: contain;
  border-radius: 10px;
}

.ex-dcap {
  margin: 0;
  padding-right: 52px;
  font-size: .9375rem;
  color: var(--bone-dim);
  text-align: center;
}

.ex-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  font: 400 1.5rem/1 var(--font);
  color: var(--bone);
  background: rgba(17, 12, 9, .72);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out);
}

.ex-close:hover {
  background: var(--ink);
  border-color: var(--blue);
}

/* Focus lands here when the lightbox opens; keep the ring clear of the image. */
.ex-close:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  background: var(--ink);
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--night);
}

@keyframes ex-dialog-in {
  from { opacity: 0; transform: scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* ---- Narrow: full-width stage, scrollable dock row ---- */
@media (max-width: 759.98px) {
  .ex-stage {
    align-self: stretch;
    width: auto;
    margin-inline: calc(-1 * var(--pad));
    border-inline: 0;
    border-radius: 0;
  }

  .ex-cap {
    min-height: 44px;
    padding: 10px 56px 10px 14px;
    font-size: .875rem;
  }

  .ex-toggle {
    top: 6px;
    right: 8px;
  }

  .ex-rail {
    --ex-tile: 46px;
    margin-top: 18px;
  }

  .ex-dock {
    gap: 0;
    padding-inline: 6px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline: 6px;
  }

  .ex-tile {
    width: calc(var(--ex-tile) + 22px); /* room for the longest label ("Appearance") */
  }

  .ex-dialog {
    width: 100vw;
    max-height: 100vh;
    padding: 12px 8px 10px;
    border-radius: 0;
  }

  .ex-dialog img {
    max-height: calc(100vh - 6rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ex-close,
  .js .ex-clip,
  .js .ex-clip.is-on,
  .ex-toggle,
  .ex-face,
  .ex-ind,
  .ex-rail::before,
  .ex-rail::after {
    transition: none;
  }

  .ex-dialog[open] {
    animation: none;
  }
}
