/* ── Live-preview modal ──────────────────────────────────────────────
   Shared by /Cards/Gallery (via _DashboardShell's TemplatesShell flag) and
   the public /gallery (fix-the-funnel #5), so it lives in its own file with
   its own keyframe instead of dashboard.css's fade-in.
   Full-viewport overlay; z-index sits above the mobile drawer backdrop
   (dashboard.css uses 55). The frame's aspect-ratio is set inline by template-preview.js
   from the template's own AspectRatio; the stage scrolls if a tall
   portrait preview exceeds the viewport. */
.tpl-preview {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  background: rgba(33, 26, 22, 0.55);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: tpl-preview-in var(--motion-standard) var(--motion-ease);
}
.tpl-preview[hidden] { display: none; }
.tpl-preview__backdrop { position: absolute; inset: 0; }
.tpl-preview__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(92vw, 460px);
  max-height: 92vh;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.tpl-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.tpl-preview__title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--font-size-lg);
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.tpl-preview__close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: var(--color-ink-muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.tpl-preview__close:hover { color: var(--color-ink); }
.tpl-preview__stage {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--color-accent-soft);
}
.tpl-preview__frame {
  width: 100%;
  aspect-ratio: 9 / 16; /* JS overrides inline from the template's AspectRatio */
  border: 0;
  display: block;
  background: var(--color-surface);
}
.tpl-preview__foot {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}

@keyframes tpl-preview-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .tpl-preview { animation: none; }
}
