/* Czech Closet – square flashing photo gallery
   Variants: fade | flash | wipe | tiles | stories  (set via data-variant) */

.cc-gallery {
  --cc-red: #e1161c;
  --cc-radius: 0px;
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: var(--cc-radius);
  background: #f1f0ee;
  container-type: inline-size;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.cc-gallery > img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  pointer-events: none;
}
.cc-gallery > img.is-prev   { opacity: 1; z-index: 1; }
.cc-gallery > img.is-active { opacity: 1; z-index: 2; }

/* Pause (offscreen, hidden tab, press-and-hold on stories) */
.cc-gallery.is-paused > img,
.cc-gallery.is-paused .cc-bar i { animation-play-state: paused !important; }


/* 1 — FADE: soft crossfade + slow Ken Burns zoom */
.cc-gallery[data-variant="fade"] > img { transition: opacity 1s ease; }
.cc-gallery[data-variant="fade"] > img:is(.is-active, .is-prev) {
  animation: cc-kenburns calc(var(--cc-interval) + 1.5s) ease-out forwards;
}
.cc-gallery[data-variant="fade"] > img:nth-of-type(odd)  { transform-origin: 30% 30%; }
.cc-gallery[data-variant="fade"] > img:nth-of-type(even) { transform-origin: 70% 70%; }
@keyframes cc-kenburns { from { transform: scale(1); } to { transform: scale(1.08); } }


/* 2 — FLASH: hard cut behind a camera-flash burst + zoom punch */
.cc-flash {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
.cc-flash.is-on { animation: cc-flash var(--cc-fx) ease-out; }
@keyframes cc-flash { 0% { opacity: 0; } 12% { opacity: .95; } 100% { opacity: 0; } }

.cc-gallery[data-variant="flash"] > img.is-active {
  animation: cc-punch .7s cubic-bezier(.16, 1, .3, 1);
}
@keyframes cc-punch { from { transform: scale(1.12); } to { transform: scale(1); } }


/* 3 — WIPE: brand-red panel sweeps across and reveals the next photo */
.cc-wipe {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -20%;
  width: 140%;
  z-index: 5;
  display: grid;
  place-items: center;
  background: var(--cc-red);
  transform: translateX(-120%) skewX(-10deg);
  pointer-events: none;
}
.cc-wipe.is-on { animation: cc-wipe var(--cc-fx) cubic-bezier(.7, 0, .3, 1) both; }
@keyframes cc-wipe {
  0%       { transform: translateX(-120%) skewX(-10deg); }
  45%, 55% { transform: translateX(0)     skewX(-10deg); }
  100%     { transform: translateX(120%)  skewX(-10deg); }
}
.cc-wipe__label {
  transform: skewX(10deg);
  color: #fff;
  font: 800 clamp(12px, 5cqi, 30px)/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  letter-spacing: .32em;
  text-transform: uppercase;
  white-space: nowrap;
}


/* 4 — TILES: next photo assembles from a 3×3 grid, diagonal stagger */
.cc-tiles {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  pointer-events: none;
}
.cc-tiles > span {
  margin: -.5px; /* hide sub-pixel seams */
  background-size: 300% 300%;
  animation: cc-tile .6s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes cc-tile {
  from { opacity: 0; transform: scale(.4) rotate(-8deg); border-radius: 30%; }
  to   { opacity: 1; transform: none; border-radius: 0; }
}


/* 5 — STORIES: Instagram-style progress bars, tap left/right, hold to pause */
.cc-gallery[data-variant="stories"] { cursor: pointer; outline-offset: 3px; }
.cc-gallery[data-variant="stories"] > img { transition: opacity .3s ease; }
.cc-gallery[data-variant="stories"]::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 24%;
  z-index: 3;
  background: linear-gradient(rgba(0, 0, 0, .38), transparent);
  pointer-events: none;
}
.cc-bars {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 4;
  display: flex;
  gap: 4px;
}
.cc-bar {
  flex: 1;
  height: 3px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, .4);
}
.cc-bar i {
  display: block;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}
.cc-bar.is-done i   { transform: scaleX(1); }
.cc-bar.is-active i { animation: cc-fill var(--cc-interval) linear forwards; }
@keyframes cc-fill { to { transform: scaleX(1); } }

.cc-story-head {
  position: absolute;
  top: 26px;
  left: 12px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  pointer-events: none;
}
.cc-story-head::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--cc-red);
  box-shadow: 0 0 0 2px #fff;
}


@media (prefers-reduced-motion: reduce) {
  .cc-gallery > img { transition: opacity .6s ease !important; animation: none !important; }
}
