/* See it work page. Load after tokens.css and site.css. Tokens only; breakpoint 768px. */

.section-head .small {
  margin-top: var(--space-4);
  color: var(--color-text-muted);
}

/* Reels: silent phone-shaped players, stacked on phones and side by side from 768px. */
.reel-row {
  display: grid;
  gap: var(--space-8);
  justify-items: center;
  margin-top: var(--space-8);
  padding: 0;
  list-style: none;
}

@media (min-width: 768px) {
  .reel-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.reel-row > li {
  display: grid;
  justify-items: center;
  width: 100%;
}

.reel {
  display: grid;
  gap: var(--space-5);
  justify-items: center;
  width: 100%;
  margin: 0;
}

.phone-frame {
  width: min(100%, 300px);
  padding: 10px;
  border-radius: 44px;
  background: var(--color-accent);
  box-shadow: var(--shadow-window);
}

@media (min-width: 768px) {
  .phone-frame {
    width: min(100%, 320px);
  }
}

.reel-video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 9 / 16;
  border-radius: 34px;
  object-fit: cover;
  background: var(--color-accent);
}

/* Reel control: reel-player.js reveals one button over the whole screen and a progress line.
   Without the script they stay hidden and the native controls work. */
.reel-screen {
  position: relative;
  border-radius: 34px;
  overflow: hidden;
}

.reel-toggle[hidden],
.reel-progress[hidden] {
  display: none;
}

.reel-toggle {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--color-on-dark);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.reel-toggle:focus,
.reel-toggle:focus-visible {
  outline: none;
}

.reel-toggle::before {
  content: "";
  grid-area: 1 / 1;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--color-accent) 64%, transparent);
  box-shadow: inset 0 0 0 1px var(--color-on-dark);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.reel-icon {
  grid-area: 1 / 1;
  width: 28px;
  height: 28px;
  transition: opacity var(--dur-fast) var(--ease-out);
}

.reel-icon--play {
  margin-left: 3px;
}

.reel-icon--pause,
.is-playing .reel-icon--play {
  display: none;
}

.is-playing .reel-icon--pause {
  display: block;
}

.is-playing .reel-toggle::before,
.is-playing .reel-icon--pause {
  opacity: 0;
}

.is-playing .reel-toggle:hover::before,
.is-playing .reel-toggle:hover .reel-icon--pause,
.is-playing .reel-toggle:focus-visible::before,
.is-playing .reel-toggle:focus-visible .reel-icon--pause {
  opacity: 1;
}

.reel-toggle:hover::before {
  transform: scale(1.06);
}

.phone-frame:has(.reel-toggle:focus-visible) {
  outline: 2px solid var(--color-link);
  outline-offset: 4px;
}

/* Without :has() the button keeps its own ring inside the screen. */
@supports not selector(:has(*)) {
  .reel-toggle:focus-visible {
    outline: 2px solid var(--color-link);
    outline-offset: -6px;
  }
}

.reel-progress {
  position: absolute;
  right: 22px;
  bottom: 16px;
  left: 22px;
  height: 3px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: color-mix(in srgb, var(--color-on-dark) 28%, transparent);
  pointer-events: none;
}

.reel-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--color-on-dark);
  transform: scaleX(0);
  transform-origin: left;
}

.reel-caption {
  max-width: 30ch;
  color: var(--color-text-muted);
  text-align: center;
  text-wrap: pretty;
}

/* Gallery: composed Northwind graphics that open a larger view. */
.gallery-grid {
  display: grid;
  gap: var(--space-6);
  margin-top: var(--space-8);
  padding: 0;
  list-style: none;
}

@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gallery-item--wide {
    grid-column: 1 / -1;
  }
}

.gallery-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-card);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-card);
  color: inherit;
  font: inherit;
  cursor: zoom-in;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.gallery-open:hover,
.gallery-open:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-window);
}

.gallery-open:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: 4px;
}

.gallery-open picture,
.gallery-view picture {
  display: block;
}

.gallery-open img {
  width: 100%;
  height: auto;
}

.gallery-caption {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
}

/* Larger view: a native popover, closed by its Close button, Escape or a click outside. */
.gallery-view {
  display: none;
}

.gallery-view:popover-open {
  display: grid;
  gap: var(--space-4);
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(92vw, 1600px);
  height: fit-content;
  max-height: 92dvh;
  overflow: auto;
  padding: var(--space-5);
  border: 0;
  border-radius: var(--radius-tray);
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-window);
  animation: fade var(--dur-fast) var(--ease-out);
}

.gallery-view img {
  width: 100%;
  height: auto;
  max-height: calc(92dvh - 160px);
  object-fit: contain;
  border-radius: var(--radius-window);
}

.gallery-close {
  justify-self: end;
}

.gallery-view-caption {
  color: var(--color-text-muted);
}

.gallery-view::backdrop {
  background: color-mix(in srgb, var(--color-text) 72%, transparent);
}

/* On phones the view keeps a narrow side margin, so a phone picture shows at least 335px wide.
   A tall picture keeps its full width and the view scrolls. */
@media (max-width: 767.98px) {
  .gallery-view:popover-open {
    width: calc(100% - var(--space-4));
    padding: var(--space-4) var(--space-3);
  }

  .gallery-view img {
    max-height: none;
  }
}

/* Closing: two buttons in one row; the row carries the space above them. */
.hiw-closing .btn-row {
  margin-top: var(--space-6);
}

.hiw-closing .btn-row .btn {
  margin-top: 0;
}
