/* =====================================================================
   my-design-kit · Coverflow carousel
   A row of cards in 3D: the centre card faces you, the ones either side
   turn away and recede, and fade a little per step. Drag, flick, use the
   arrow keys, or click a side card to bring it to the centre.
   Needs: tokens.css, coverflow.js
   ===================================================================== */

.kit-coverflow {
  --cf-card: clamp(148px, 22vw, 260px);
  --cf-ratio: 1;             /* card height ÷ width: 1 = square, 1.25 = 4:5 */
  width: 100%;
  font-family: var(--kit-font-sans);
}

.kit-coverflow__wrap { position: relative; isolation: isolate; } /* keeps the arrows under a fixed nav */

.kit-coverflow__frame {
  overflow: hidden;
  padding: 40px 0;           /* keeps the drop shadows clear of the clip */
  cursor: grab;
  outline: none;
  touch-action: pan-y;       /* sideways drag is ours, the page still scrolls */
  border-radius: var(--kit-radius-md);
}
.kit-coverflow__frame:active { cursor: grabbing; }
.kit-coverflow__frame:focus-visible { box-shadow: 0 0 0 2px var(--kit-primary); }

.kit-coverflow__track {
  position: relative;
  height: calc(var(--cf-card) * var(--cf-ratio));
  transform-style: preserve-3d;
  user-select: none;
}

.kit-coverflow__card {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--cf-card);
  height: calc(var(--cf-card) * var(--cf-ratio));
  overflow: hidden;
  border-radius: var(--kit-radius-md);
  background: var(--kit-muted);
  box-shadow: var(--kit-shadow-xl);
  will-change: transform;
}

.kit-coverflow__card img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

/* Arrow buttons (optional) */
.kit-coverflow__arrow {
  position: absolute;
  top: 50%;
  z-index: 200;
  display: flex;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  transform: translateY(-50%);
  background: color-mix(in srgb, var(--kit-background) 70%, transparent);
  color: var(--kit-foreground);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition: background-color 150ms var(--kit-ease-standard);
}
.kit-coverflow__arrow:hover { background: var(--kit-background); }
.kit-coverflow__arrow:focus-visible { outline: 2px solid var(--kit-primary); outline-offset: 2px; }
.kit-coverflow__arrow--prev { left: 12px; }
.kit-coverflow__arrow--next { right: 12px; }
.kit-coverflow__arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Caption under the centre card (optional) */
.kit-coverflow__caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
  padding: 0 24px;
  text-align: center;
}
.kit-coverflow__title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.025em; color: var(--kit-foreground); }
.kit-coverflow__subtitle { margin: 4px 0 0; font-size: 14px; color: var(--kit-muted-foreground); }
.kit-coverflow__meta { width: 100%; max-width: 230px; margin: 40px 0 0; font-size: 14px; }
.kit-coverflow__meta div { display: flex; justify-content: space-between; padding: 5px 0; }
.kit-coverflow__meta dt { color: var(--kit-muted-foreground); }
.kit-coverflow__meta dd { margin: 0; font-weight: 500; color: var(--kit-foreground); }

/* Dots (optional) */
.kit-coverflow__dots { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 24px; }
.kit-coverflow__dot {
  width: 8px; height: 8px; padding: 0; border: 0; border-radius: 50%;
  background: var(--kit-foreground); opacity: .3; cursor: pointer;
  transition: opacity 150ms var(--kit-ease-standard);
}
.kit-coverflow__dot[aria-current="true"] { opacity: 1; }
.kit-coverflow__dot:focus-visible { outline: 2px solid var(--kit-primary); outline-offset: 3px; }

/* Play badge on cards that have data-video */
.kit-coverflow__play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--kit-cream, #fff) 72%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: var(--kit-shadow-lg);
  pointer-events: none;
  opacity: 0;
  visibility: hidden; /* hidden badges skip their blur, which phones pay for every frame */
  transform: scale(.8);
  transition: opacity 200ms var(--kit-ease-standard), transform 400ms var(--kit-ease-spring), visibility 0s 200ms;
}
.kit-coverflow__card.is-center .kit-coverflow__play { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

/* Preview clip on the centre card: shown the moment it is playing (no fade) */
.kit-coverflow__preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.kit-coverflow__preview:not(.is-playing) { visibility: hidden; }
.kit-coverflow__play svg { width: 22px; height: 22px; margin-left: 3px; fill: var(--kit-forest, #111); }

/* Video lightbox (a native <dialog>) */
.kit-lightbox {
  /* covers the whole screen so the video sits dead centre; a click on the
     empty area around the video closes it */
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  overflow: hidden;
  background: transparent;
}
.kit-lightbox[open] { display: grid; place-items: center; }
.kit-lightbox::backdrop {
  background: color-mix(in srgb, var(--kit-forest, #000) 78%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
/* Opens instantly: no fade-in */
.kit-lightbox__video {
  display: block;
  max-width: min(100%, 1100px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  width: auto;
  height: auto;
  border-radius: var(--kit-radius-md);
  background: #000;
  box-shadow: var(--kit-shadow-xl);
}
.kit-lightbox__close {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--kit-cream, #fff);
  color: var(--kit-forest, #111);
  box-shadow: var(--kit-shadow-lg);
  cursor: pointer;
  transition: transform 150ms var(--kit-ease-out);
}
.kit-lightbox__close:hover { transform: scale(1.06); }
.kit-lightbox__close:active { transform: scale(.95); }
.kit-lightbox__close:focus-visible { outline: 2px solid var(--kit-lime, #fff); outline-offset: 3px; }
.kit-lightbox__close svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
