/* ============================================
   OZYDE — Shared modal (js/modal.js)
   Backdrop and open/close behaviour follow .lightbox in components.css. z-index
   205 puts it above the lightbox (200) and below the gallery video viewer (210).
   ============================================ */

/* Page scroll lock. Applied to <html> rather than written inline on <body>, so
   it can't collide with the mobile drawer and gallery lightbox, which set
   body.style.overflow directly. (No scrollbar-gutter here: it would leave a
   bare strip of page showing beside the full-screen overlay on desktop.) */
html.oz-scroll-locked,
html.oz-scroll-locked body {
  overflow: hidden;
}

.oz-modal {
  position: fixed; inset: 0; z-index: 205;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px;
  background: rgba(11,9,6,0.92);
  opacity: 0; visibility: hidden;
  /* visibility waits for the fade-out to finish when closing, and flips
     immediately when opening (see .is-open), so focus can move in at once. */
  transition: opacity var(--dur-fast) var(--ease), visibility 0s linear var(--dur-fast);
  overscroll-behavior: contain;
}
.oz-modal.is-open {
  opacity: 1; visibility: visible;
  transition: opacity var(--dur-fast) var(--ease), visibility 0s;
}

.oz-modal__panel {
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  transform: translateY(16px) scale(0.98);
  transition: transform var(--dur-med) var(--ease);
}
.oz-modal.is-open .oz-modal__panel { transform: none; }
/* Focus lands on the panel itself when a dialog opens; the ring belongs on the
   controls inside it, not on the whole card. */
.oz-modal__panel:focus,
.oz-modal__panel:focus-visible { outline: none; }

.oz-modal__head {
  flex: none;
  /* right padding clears the close button */
  padding: 28px 68px 4px 28px;
}
.oz-modal__title { font-size: clamp(22px, 3vw, 27px); line-height: 1.18; }

/* Only the body scrolls, so the title and the buttons stay in view however
   tall the content gets. */
.oz-modal__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 28px 8px;
  font-size: 14.5px;
  line-height: 1.65;
  /* a long email address must wrap rather than push the card wider */
  overflow-wrap: break-word;
}
.oz-modal__body > * + * { margin-top: 14px; }
.oz-modal__body a:not(.btn) {
  color: var(--gold-deep);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.oz-modal__body a:not(.btn):hover { color: var(--jewel); }

.oz-modal__actions {
  flex: none;
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end;
  padding: 18px 28px max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.oz-modal__close {
  position: absolute; top: 14px; right: 14px;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream-deep); color: var(--ink);
  transition: background var(--dur-fast) var(--ease);
}
.oz-modal__close:hover { background: var(--gold-light); }
.oz-modal__close svg { width: 16px; height: 16px; }

/* Phones: a bottom sheet — full width, anchored to the bottom edge, scrolling
   inside itself, buttons stacked with the primary action on top. */
@media (max-width: 640px) {
  .oz-modal { align-items: flex-end; padding: 0; }
  .oz-modal__panel {
    max-width: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    transform: translateY(100%);
  }
  .oz-modal__head { padding: 24px 64px 4px 20px; }
  .oz-modal__body { padding: 12px 20px 8px; }
  .oz-modal__actions {
    flex-direction: column-reverse;
    padding-inline: 20px;
  }
  .oz-modal__actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .oz-modal,
  .oz-modal.is-open,
  .oz-modal__panel { transition: none; }
}
