/*
  Layout, stacking & cosmetics for the ring gallery component.
  JS owns only what changes per frame (each slot's transform, width, height, 
  opacity, z-index, and the media's blur) plus the root's perspective.
*/

/* Pre-JS state, so a JS failure leaves readable content. JS adds .rg-ready
   once it has taken over. */
.ring-gallery {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
}
.ring-gallery .gallery-item {
  margin: 0;
  max-width: 320px;
}
.ring-gallery:not(.rg-static) .gallery-item {
  display: none;
}
.ring-gallery .gallery-item img {
  display: block;
  width: 100%;
  height: auto;
}

/* ---- Ring active ------------------------------------------------------- */

/* Column: reel then metadata, centred as one group. JS sizes the slot from
   the content box, so padding here is honoured. */
.rg-root {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 0;
  overflow: hidden;
  user-select: none;
  outline: none;
  cursor: grab;
  touch-action: none;
  min-height: 80vh;
}
.rg-root.rg-dragging {
  cursor: grabbing;
}
.rg-root .gallery-item[hidden] {
  display: none !important;
}
.rg-root .rg-slot,
.rg-root .rg-media,
.rg-root .rg-media img {
  transition: none !important;
  animation: none !important;
}

.rg-root:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* Sized inline by JS. flex-shrink:0 required for correct sizing. */
.rg-reel {
  position: relative;
  flex-shrink: 0;
  overflow: visible;
  transform-style: preserve-3d;
  z-index: 10;
}

/* computeItemState in JS handles transform / translateX. */
.rg-slot {
  position: absolute;
  top: 0;
  left: 50%;
  margin: 0;
  padding: 0;
  border: 0;
  box-sizing: content-box;
  transform-style: preserve-3d;
  pointer-events: auto;
  cursor: pointer;
}

.rg-media {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: transparent;
}

/* !important required to override theme & Bootstrap. */
.rg-media img {
  display: block !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* ---- Metadata ---------------------------------------------------------- */

/* In flow under the reel. JS sets min-height to the tallest item's metadata,
   so a swap never changes its height and shifts the ring. align-items:start
   keeps each layer at its content height for that measurement. */
.rg-meta {
  position: relative;
  margin-top: 1rem;
  display: grid;
  justify-items: center;
  align-items: start;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
}

/* Both layers share one grid cell so neither reflows the other on a swap.
   That also means a faded-out layer is still laid out, and its link would sit
   on top of the live one and swallow clicks. JS makes every layer but the live
   one inert from the start of each swap, and hides the settled one with
   visibility. */
.rg-meta-layer {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  visibility: hidden;
}
.rg-meta-title,
.rg-meta-subtitle {
  margin: 0;
  white-space: nowrap;
}
.rg-meta-title {
  color: var(--color-heading);
}
.rg-meta [hidden] {
  display: none !important;
}

/* The only part of the metadata that takes pointer events, so the rest never
   blocks a drag. */
.rg-meta-link {
  padding-block: 0.25rem;
  pointer-events: auto;
  color: #777;
}

/* ---- Degraded modes ---------------------------------------------------- */

/* JS also stops WRITING the filter, which is the part that matters: an inline
   style would beat this rule. */
.rg-no-blur .rg-media {
  filter: none !important;
}

/* Too few items for a ring: JS bails and the rules above present the static
   markup. */
.rg-static .gallery-item {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  .rg-media {
    filter: none !important;
  }
}
