/*
 * .modal — webinar popup, native <dialog>
 * (template-parts/global/modal.php, assets/js/components/modal.js).
 * Figma: D 1574:10781 / 1574:19831 (900 px box on a 50 % navy backdrop),
 * success states 1574:19220 / 1574:19771 (registration-success.css).
 * No mobile design: the box keeps the gutters and scrolls inside when
 * taller than the screen.
 */

/* html:has(.modal[open]) — the page under the popup does not scroll */
html:has(.modal[open]) {
  overflow: hidden;
}

/* .modal — the dialog itself; the browser keeps it hidden until opened.
   margin: auto centres it again (the site reset sets margin: 0 on everything) */
.modal {
  width: calc(100% - 1.875rem);
  max-width: 56.25rem;
  max-height: calc(100dvh - 1.875rem);
  margin: auto;
  overflow-y: auto;
  border: 0;
  border-radius: var(--nv-radius-m);
  padding: 0;
  background-color: var(--nv-ice);
  color: var(--nv-navy);
  overscroll-behavior: contain;

  /* .modal::backdrop */
  &::backdrop {
    background-color: rgba(19, 33, 50, 0.5);
  }
}

/* .modal fade — the box and the backdrop fade in and out in 0.4 s (Pavlo, 2026-10-14);
   display and overlay switch at the end, so the closing fade is visible too */
.modal,
.modal::backdrop {
  opacity: 0;
  transition:
    opacity 0.4s ease,
    display 0.4s allow-discrete,
    overlay 0.4s allow-discrete;
}

/* .modal[open] */
.modal[open],
.modal[open]::backdrop {
  opacity: 1;
}

/* @starting-style .modal[open] — the first frame after showModal() */
@starting-style {
  .modal[open],
  .modal[open]::backdrop {
    opacity: 0;
  }
}

/* @media (prefers-reduced-motion: reduce) .modal — no fade */
@media (prefers-reduced-motion: reduce) {
  .modal,
  .modal::backdrop {
    transition: none;
  }
}

/* .modal__box — 60 → 120 px top and bottom, 20 px sides: titles and success
   texts span the 900 px box (Figma), the form keeps its own 620 px */
.modal__box {
  position: relative;
  isolation: isolate;
  padding: clamp(3.75rem, 2.4170rem + 5.6872vw, 7.5rem) 1.25rem;
}

/* .modal__texture — waves along the top, behind the content; the image is the
   visible 900 × 281 part of the Figma layer (Reserve Your Seat 1574:10781),
   it scales with the box width */
.modal__texture {
  position: absolute;
  z-index: -1;
  top: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
}

/* .modal--recording .modal__texture — Request Recording sits 23 of 281 px higher (Figma 1574:19831) */
.modal--recording .modal__texture {
  transform: translateY(-8.185%);
}

/* .modal--thanks .modal__texture — the form thank-you popup shows 269 of 281 px, 12 px higher (Figma 18:43163) */
.modal--thanks .modal__texture {
  transform: translateY(-4.27%);
}

/* .modal__box:has(success) .modal__texture — both success states sit 36 of 281 px higher (Figma 1574:19220, 1574:19771) */
.modal__box:has([data-registration-success]:not([hidden])) .modal__texture {
  transform: translateY(-12.811%);
}

/* .modal__texture-image */
.modal__texture-image {
  display: block;
  width: 100%;
  height: auto;
}

/* .modal__part — title, date line, form, notes: 30 px apart */
.modal__part {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.875rem;
}

/* .modal__part[hidden] — display: flex above would show it */
.modal__part[hidden] {
  display: none;
}

/* .modal__close — 32 px cross, top right */
.modal__close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 2rem;
  height: 2rem;
  border: 0;
  padding: 0;
  background: none;
  opacity: 0.4;
  cursor: pointer;
  transition: opacity 0.3s ease;

  /* .modal__close::before, .modal__close::after — the two strokes */
  &::before,
  &::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2.5rem;
    height: 0.0625rem;
    background-color: var(--nv-navy);
    transform: translate(-50%, -50%) rotate(45deg);
  }

  /* .modal__close::after */
  &::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  /* .modal__close:focus-visible */
  &:focus-visible {
    outline: 2px solid var(--nv-blue-light);
    outline-offset: 2px;
    opacity: 1;
  }
}

/* @media (hover: hover) .modal__close:hover */
@media (hover: hover) and (pointer: fine) {
  .modal__close:hover {
    opacity: 1;
  }
}

/* .modal__title — 40 → 75 px trimmed to cap / baseline (cap at the 120 px padding, Figma 1574:19831);
   60 px from the baseline to the date line or the form (gap 30 + 30) */
.modal__title {
  margin-top: -0.14em;
  margin-bottom: calc(1.875rem - 0.16em);
  font-weight: 400;
  font-size: clamp(2.5rem, 1.7225rem + 3.3176vw, 4.6875rem);
  line-height: 1;
  letter-spacing: -0.02em;
  text-align: center;
}

/* .modal .event-line — 18 → 23 px, 20 px between items, trimmed to cap / baseline (Figma 1574:10781: 60 px under
   the title's baseline, 30 px to the fields) */
.modal .event-line {
  --event-line-gap: 1.25rem;

  margin-top: -0.14em;
  margin-bottom: -0.16em;

  font-size: clamp(1.125rem, 1.0139rem + 0.4740vw, 1.4375rem);
}

/* .modal__form — 620 px */
.modal__form {
  width: 100%;
  max-width: 38.75rem;
}

/* .modal__note — 70 % navy, centred */
.modal__box .modal__note {
  justify-content: center;
  color: rgba(19, 33, 50, 0.7);
}
