/* Shared collapsible image gallery (how-it-works + Scale Lab 2 scene assets) */

details.img-gallery-details {
  border-top: 1px solid var(--border);
  margin-top: 0;
}

details.img-gallery-details > summary {
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

details.img-gallery-details > summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform 0.15s;
  display: inline-block;
}

details.img-gallery-details[open] > summary::before {
  transform: rotate(90deg);
}

details.img-gallery-details > summary:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
}

.img-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  padding: 12px 14px 14px;
  background: #080a0e;
  border-top: 1px solid var(--border);
}

.img-gallery-item {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.img-gallery-item:hover,
.img-gallery-item:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  outline: none;
}

.img-gallery-item img {
  display: block;
  width: 100%;
  height: 130px;
  object-fit: cover;
  background: #0b0d11;
}

.img-gallery-caption {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  border-top: 1px solid var(--border);
}

.img-gallery-cost-pill {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  color: #e8f5e9;
  background: rgba(20, 40, 28, 0.88);
  border: 1px solid rgba(100, 180, 120, 0.5);
  pointer-events: none;
}

.img-gallery-call-pill {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  color: hsl(var(--call-hue, 210), 88%, 92%);
  background: hsla(var(--call-hue, 210), 52%, 32%, 0.9);
  border: 1px solid hsla(var(--call-hue, 210), 58%, 52%, 0.55);
  max-width: calc(100% - 56px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-gallery-by-call {
  display: flex;
  flex-direction: column;
}

.img-gallery-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 14px 0;
  background: #080a0e;
  border-top: 1px solid var(--border);
}

.img-gallery-by-call > .img-gallery-call-header:first-child {
  border-top: none;
}

.img-gallery-call-header-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  color: hsl(var(--call-hue, 210), 88%, 92%);
  background: hsla(var(--call-hue, 210), 52%, 32%, 0.92);
  border: 1px solid hsla(var(--call-hue, 210), 58%, 52%, 0.55);
}

.img-gallery-call-header-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.img-gallery-call-header-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.img-gallery-by-call > .img-gallery-grid {
  border-top: none;
  padding-top: 8px;
}

/* how-it-works: json-details spacing */
details.json-details.img-gallery-details {
  margin-top: 8px;
}

/* Fullscreen lightbox — only .open is visible (never rely on [hidden] vs display:flex) */
.img-gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}

.img-gallery-lightbox.open {
  display: flex;
  pointer-events: auto;
}

.img-gallery-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  cursor: pointer;
}

.img-gallery-lb-close {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 2;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.img-gallery-lb-close:hover {
  background: rgba(255, 255, 255, 0.14);
}

.img-gallery-lb-prev,
.img-gallery-lb-next {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  width: 48px;
  height: 72px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 36px;
  line-height: 1;
  cursor: pointer;
}

.img-gallery-lb-prev { left: 12px; }
.img-gallery-lb-next { right: 12px; }

.img-gallery-lb-prev:hover:not(:disabled),
.img-gallery-lb-next:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.16);
}

.img-gallery-lb-prev:disabled,
.img-gallery-lb-next:disabled {
  opacity: 0.25;
  cursor: default;
}

.img-gallery-lb-inner {
  position: relative;
  z-index: 1;
  max-width: min(96vw, 1400px);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 48px 64px 16px;
  pointer-events: none;
}

.img-gallery-lb-stage {
  position: relative;
  width: min(96vw, 1400px);
  height: calc(92vh - 140px);
  overflow: hidden;
  pointer-events: auto;
  cursor: default;
  touch-action: none;
  border-radius: 6px;
}

.img-gallery-lb-stage--zoomed {
  cursor: grab;
}

.img-gallery-lb-stage--panning {
  cursor: grabbing;
}

.img-gallery-lb-transform {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  will-change: transform;
}

.img-gallery-lb-img {
  display: block;
  max-width: min(96vw, 1400px);
  max-height: calc(92vh - 140px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 6px;
  background: #0b0d11;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  user-select: none;
  -webkit-user-drag: none;
}

.img-gallery-lb-cost-pill {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  color: #e8f5e9;
  background: rgba(20, 40, 28, 0.92);
  border: 1px solid rgba(100, 180, 120, 0.55);
  pointer-events: none;
  white-space: nowrap;
  transform-origin: top right;
}

.img-gallery-lb-reset {
  position: absolute;
  top: 12px;
  left: 14px;
  z-index: 2;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.img-gallery-lb-reset:hover {
  background: rgba(255, 255, 255, 0.12);
}

.img-gallery-lb-zoom-hint {
  margin: 0;
  min-height: 1em;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.img-gallery-lb-caption {
  margin: 0;
  max-width: 100%;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  text-align: center;
  word-break: break-word;
}

.img-gallery-lb-counter {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

body.img-gallery-lb-open {
  overflow: hidden;
}

.img-gallery-lb-fal-btn {
  position: absolute;
  top: 12px;
  right: 62px;
  z-index: 2;
  padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--border));
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.92);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  max-width: min(52vw, 320px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-gallery-lb-fal-btn:hover {
  background: color-mix(in srgb, var(--accent) 22%, rgba(12, 14, 18, 0.95));
}

@media (max-width: 640px) {
  .img-gallery-lb-fal-btn {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    max-width: none;
    text-align: center;
  }

  .img-gallery-lb-inner {
    padding-bottom: 56px;
  }
}

.img-gallery-fal-panel {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-gallery-fal-panel[hidden] {
  display: none !important;
}

.img-gallery-fal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  cursor: pointer;
}

.img-gallery-fal-dialog {
  position: relative;
  z-index: 1;
  width: min(92vw, 900px);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.img-gallery-fal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.img-gallery-fal-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.img-gallery-fal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.img-gallery-fal-close:hover {
  background: rgba(255, 255, 255, 0.12);
}

.img-gallery-fal-note {
  margin: 0;
  padding: 10px 14px 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
}

.img-gallery-fal-json {
  margin: 10px 0 0;
  padding: 12px 14px 14px;
  overflow: auto;
  max-height: calc(82vh - 96px);
  font-size: 11px;
  line-height: 1.45;
  color: #d8dee9;
  background: #0b0d11;
  border-top: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
}
