/**
 * Scatter thumbnails + paint-reveal lightbox (separate file for cache-safe deploy).
 * Uses ID selectors so overlay stays fixed even if an older cached style.css stops early.
 */

#paint-reveal-lightbox {
  position: fixed;
  inset: 0;
  z-index: 320;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: radial-gradient(
    ellipse at 50% 40%,
    rgba(249, 247, 242, 0.12),
    rgba(45, 45, 45, 0.92)
  );
}

#paint-reveal-lightbox[hidden] {
  display: none !important;
}

#gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(45, 45, 45, 0.88);
}

#gallery-lightbox[hidden] {
  display: none !important;
}

.photo-scatter-section {
  position: relative;
  z-index: 2;
  padding: 0.35rem clamp(0.5rem, 2vw, 1.25rem) 0.75rem;
  overflow: visible;
}

.photo-scatter-section--top {
  padding-top: 0.15rem;
  padding-bottom: 0;
  margin-bottom: 0;
}

.photo-scatter-section--mid,
.photo-scatter-section--low {
  padding: 0.5rem clamp(0.5rem, 2vw, 1.25rem) 1rem;
}

.scatter-eyebrow {
  text-align: center;
  margin-bottom: 0.25rem;
}

.scatter-hint {
  max-width: 42rem;
  margin-bottom: 0.65rem;
}

.photo-scatter-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.55rem 0.75rem;
  max-width: 1180px;
  margin: 0 auto;
}

.photo-scatter-field--galerie {
  gap: 0.65rem 0.85rem;
  padding-bottom: 0.5rem;
}

/* Hero: three tight rows; breathing room on the block (not between rows) */
.photo-scatter-field--three-rows {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.2rem;
  flex-wrap: nowrap;
  padding: clamp(1.35rem, 3.5vw, 2.35rem) clamp(0.5rem, 2vw, 1.25rem);
  margin: 0 auto;
}

.photo-scatter-field--stacked.photo-scatter-field--galerie,
#galerie .photo-scatter-field--stacked {
  gap: 0.1rem;
  padding-top: 0.35rem;
  padding-bottom: 0.5rem;
  max-width: 100%;
}

#galerie .scatter-row {
  gap: clamp(0.25rem, 0.85vw, 0.5rem);
}

.chapter-band--gallery #galerie.section,
.chapter-band--blush #galerie.section {
  padding-top: clamp(1.75rem, 5vw, 3rem);
  padding-bottom: 0.35rem;
}

.chapter-band--gallery #galerie .eyebrow,
.chapter-band--blush #galerie .eyebrow {
  margin-top: 0.25rem;
  margin-bottom: 0.65rem;
}

.chapter-band--gallery #galerie .section-title-deco,
.chapter-band--blush #galerie .section-title-deco {
  margin-bottom: 0.85rem;
}

.chapter-band--gallery #galerie .scatter-hint,
.chapter-band--blush #galerie .scatter-hint {
  margin-bottom: clamp(1.1rem, 3vw, 1.65rem);
  line-height: 1.55;
}

.scatter-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-evenly;
  align-items: center;
  gap: clamp(0.35rem, 1vw, 0.65rem);
  width: 100%;
}

.photo-scatter-field--three-rows .scatter-thumb {
  flex: 1 1 0;
  min-width: 0;
  max-width: clamp(52px, 8.2vw, 88px);
}

@media (max-width: 720px) {
  .scatter-row {
    flex-wrap: wrap;
    justify-content: center;
  }

  .photo-scatter-field--three-rows .scatter-thumb {
    flex: 0 0 auto;
    max-width: clamp(54px, 14vw, 92px);
  }
}

/* Full-page graduated dim; bright hole follows hovered scatter thumb (JS sets vars). */
.scatter-spotlight-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease;
  background: radial-gradient(
    circle at var(--spot-x, 50%) var(--spot-y, 50%),
    rgba(35, 32, 28, 0) 0,
    rgba(35, 32, 28, 0.06) calc(var(--spot-r, 140px) * 0.28),
    rgba(35, 32, 28, 0.48) calc(var(--spot-r, 140px) * 0.72),
    rgba(35, 32, 28, 0.7) 100%
  );
}

.scatter-spotlight-overlay.is-visible {
  opacity: 1;
  visibility: visible;
}

.scatter-thumb {
  position: relative;
  flex: 0 0 auto;
  width: clamp(54px, 10.5vw, 92px);
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  overflow: visible;
  transform: translate(var(--jitter-x, 0px), var(--jitter-y, 0px));
  transition: transform 0.38s ease, filter 0.25s ease;
}

.scatter-thumb-face {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 3px;
  border: 2px solid var(--color-antique-gold);
  border-radius: 3px;
  background: linear-gradient(145deg, var(--color-paper), rgba(226, 180, 180, 0.12));
  box-shadow: var(--shadow-paper);
  overflow: hidden;
  transform: rotate(var(--rot, 0deg));
  transform-origin: center center;
  transition: box-shadow 0.38s ease, filter 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .scatter-thumb.is-spotlight {
    z-index: 100;
    filter: saturate(1.08) brightness(1.03);
    transform: translate(var(--jitter-x, 0px), var(--jitter-y, 0px)) scale(1.5);
  }

  .scatter-thumb.is-spotlight .scatter-thumb-face {
    box-shadow: 0 20px 48px rgba(45, 45, 45, 0.38);
  }
}

.scatter-thumb:hover,
.scatter-thumb:focus-visible {
  z-index: 8;
  filter: saturate(1.05);
}

.scatter-thumb:hover:not(.is-spotlight) .scatter-thumb-face,
.scatter-thumb:focus-visible:not(.is-spotlight) .scatter-thumb-face {
  box-shadow: 0 10px 28px rgba(45, 45, 45, 0.18);
}

.scatter-thumb:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 3px;
}

.scatter-thumb img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  pointer-events: none;
}

/* Close sits on the framed canvas box (not the viewport corner). */
.paint-reveal-stage {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 96vw;
  max-height: 88vh;
  line-height: 0;
}

#paint-reveal-lightbox .paint-reveal-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 5;
  transform: translate(42%, -42%);
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--color-antique-gold);
  border-radius: 50%;
  background: var(--color-paper);
  color: var(--color-slate);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45, 45, 45, 0.35);
}

#paint-reveal-canvas {
  display: block;
  max-width: min(92vw, 100%);
  max-height: 82vh;
  width: auto;
  height: auto;
  border-radius: 0;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

/* Framed artwork lifts upward when closing (~1.1s) */
#paint-reveal-lightbox.is-ascending {
  background: radial-gradient(
    ellipse at 50% 85%,
    rgba(213, 169, 84, 0.18),
    rgba(45, 45, 45, 0.75)
  );
  transition: background 0.9s ease;
}

.paint-reveal-stage.is-ascending {
  animation: paint-reveal-ascend 1.1s cubic-bezier(0.33, 0.02, 0.15, 1) forwards;
  will-change: transform, opacity;
}

@keyframes paint-reveal-ascend {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: drop-shadow(0 18px 48px rgba(0, 0, 0, 0.45));
  }
  35% {
    transform: translateY(-8vh) scale(1.02);
    opacity: 1;
  }
  100% {
    transform: translateY(-118vh) scale(0.9);
    opacity: 0;
    filter: drop-shadow(0 0 24px rgba(213, 169, 84, 0.35));
  }
}

@media (prefers-reduced-motion: reduce) {
  .paint-reveal-stage.is-ascending {
    animation: none;
  }
}

.flying-brush {
  position: fixed;
  z-index: 330;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(197, 160, 89, 0.95) 0%,
    rgba(226, 180, 180, 0.55) 35%,
    rgba(249, 247, 242, 0.15) 55%,
    transparent 70%
  );
  border-radius: 50%;
  filter: blur(0.5px);
  mix-blend-mode: multiply;
}

.flying-brush.is-painting {
  opacity: 1;
  animation: brush-wobble 0.45s ease-in-out infinite alternate;
}

.flying-brush.is-painting::after {
  content: "";
  position: absolute;
  top: 18px;
  left: 38px;
  width: 28px;
  height: 8px;
  background: linear-gradient(90deg, rgba(45, 45, 45, 0.35), transparent);
  border-radius: 4px;
  transform: rotate(-25deg);
}

@keyframes brush-wobble {
  from {
    transform: scale(0.92) rotate(-8deg);
  }
  to {
    transform: scale(1.08) rotate(6deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .scatter-thumb-face {
    transform: rotate(var(--rot, 0deg)) !important;
  }

  .flying-brush.is-painting {
    animation: none;
  }
}
