/*
 * The exhibit — successor to the legacy oversing.com slider.
 *
 * What the old slider got right
 * -----------------------------
 * Its information shape. Every slide carried a category eyebrow and a
 * headline: TASKS / "Distribute Tasks, not Email", CONTEXT / "Work In Context
 * — Not From Memory". That is the same shape as the page-progress rail on
 * runcible.com, which is why the two become one component here rather than
 * two: the rail is the exhibit's index.
 *
 * What it got wrong, and what this fixes
 * --------------------------------------
 *   - Panels were not addressable. You could not link a colleague to one.
 *     Every panel here has an id and updates the URL hash as it becomes
 *     current.
 *   - Panels were invisible to search engines and to anyone without
 *     JavaScript. Here the default rendering -- the one in the HTML, before
 *     any script runs -- is a plain vertical stack with every panel present
 *     and readable. The horizontal deck is an enhancement applied by
 *     oversing-exhibit.js adding .is-enhanced.
 *   - There was no route to richer media. Each panel reserves a media slot
 *     that takes a still today and a <video> later, with no markup change.
 *
 * Advancing uses CSS scroll-snap rather than transforms, so trackpad and touch
 * swipe work natively and correctly on every platform without the script
 * simulating momentum.
 */

/* ------------------------------------------------- baseline: vertical stack */

.exhibit {
  --exhibit-gap: clamp(20px, 3vw, 38px);
  position: relative;
  padding: var(--section-pad-y) 0;
  background: var(--ink);
  color: var(--white);
}

.exhibit-track {
  display: grid;
  gap: var(--exhibit-gap);
  padding: 0 var(--section-pad-x);
  margin: 0;
  list-style: none;
}

.exhibit-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(18px, 2.6vw, 32px);
  align-content: start;
  padding: clamp(24px, 3vw, 40px);
  border: 1px solid rgba(255, 253, 247, .17);
  background: var(--coal);
}

@media (min-width: 900px) {
  .exhibit-panel.has-media {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    align-items: center;
  }
}

.exhibit-panel .eyebrow {
  color: var(--gold);
}

.exhibit-panel h3 {
  margin: 0 0 12px;
  color: var(--white);
  font-size: clamp(1.5rem, 2.6vw, 2.3rem);
}

.exhibit-panel p {
  max-width: 54ch;
  margin: 0 0 12px;
  color: #ddd9d0;
}

.exhibit-panel p:last-child {
  margin-bottom: 0;
}

/* Media slot. Holds a still now and a <video> when the video programme
   begins; both are object-fit: cover inside the same frame, so swapping one
   for the other is a content change and not a rebuild. */
.exhibit-media {
  margin: 0;
  border: 1px solid rgba(255, 253, 247, .2);
  background: #0b0d0c;
}

.exhibit-media img,
.exhibit-media video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.exhibit-media figcaption {
  padding: 10px 14px;
  border-top: 1px solid rgba(255, 253, 247, .2);
  color: var(--muted-on-dark);
  font-family: var(--mono);
  font-size: .58rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.exhibit-media.is-pending {
  display: grid;
  place-items: center;
  min-height: 220px;
  border-style: dashed;
  color: var(--muted-on-dark);
  font-family: var(--mono);
  font-size: .65rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* Controls are useless without the script that drives them, so they are
   hidden in the markup and revealed by it. */
.exhibit-controls[hidden] {
  display: none;
}

/* ------------------------------------------------ enhanced: horizontal deck */

.exhibit.is-enhanced .exhibit-track {
  display: flex;
  gap: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 0;
}

.exhibit.is-enhanced .exhibit-track::-webkit-scrollbar {
  display: none;
}

.exhibit.is-enhanced .exhibit-panel {
  flex: 0 0 100%;
  width: 100%;
  min-height: clamp(360px, 52vh, 560px);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  border: 0;
  background: transparent;
  padding: 0 var(--section-pad-x);
  align-content: center;
}

.exhibit.is-enhanced .exhibit-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  max-width: none;
  margin: clamp(18px, 2.4vw, 28px) 0 0;
  padding: 0 var(--section-pad-x);
}

.exhibit-counter {
  margin-right: auto;
  color: var(--muted-on-dark);
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.exhibit-counter b {
  color: var(--gold);
  font-weight: 600;
}

.exhibit-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 46px;
  min-height: 46px;
  padding: 0 16px;
  border: 1px solid rgba(255, 253, 247, .32);
  color: var(--white);
  background: transparent;
  font-family: var(--mono);
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease;
}

.exhibit-controls button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--white);
  border-color: var(--white);
}

.exhibit-controls button:disabled {
  opacity: .32;
  cursor: default;
}

.exhibit-controls button:focus-visible,
.exhibit.is-enhanced .exhibit-track:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/*
 * Panels off-screen in the deck are still in the accessibility tree and still
 * focusable, which would let a keyboard user tab into content they cannot see.
 * inert would be the right tool but is not universally supported yet, so the
 * script also toggles this class, and the class removes them from the tab
 * order. Content stays in the DOM for search engines either way.
 */
.exhibit.is-enhanced .exhibit-panel:not(.is-current) {
  visibility: hidden;
}

.exhibit.is-enhanced .exhibit-panel.is-current {
  visibility: visible;
}

/* Reduced motion: keep the deck, drop the animated scroll. The script checks
   the same query before choosing smooth or instant scrolling. */
@media (prefers-reduced-motion: reduce) {
  .exhibit.is-enhanced .exhibit-track {
    scroll-behavior: auto;
  }
}

/* Narrow screens: the deck costs more than it gives, so fall back to the
   readable stack even when the script has loaded. */
@media (max-width: 720px) {
  .exhibit.is-enhanced .exhibit-track {
    display: grid;
    overflow-x: visible;
    scroll-snap-type: none;
    gap: var(--exhibit-gap);
    padding: 0 var(--section-pad-x);
  }

  .exhibit.is-enhanced .exhibit-panel {
    flex: none;
    width: auto;
    min-height: 0;
    padding: clamp(20px, 4vw, 28px);
    border: 1px solid rgba(255, 253, 247, .17);
    background: var(--coal);
    visibility: visible;
  }

  .exhibit.is-enhanced .exhibit-controls {
    display: none;
  }
}
