/* popup.css — the pop-up form and floating button, shared by the opt-in page
 * and the landing page (Bryan, 14 Sept: "the same principle across the board").
 * Every CTA opens the pop-up instead of scrolling to a form at the bottom.
 * The pop-up is WIDE: the section's pitch on the left, just the form on the
 * right, on both pages. Stacks to one column on phones.
 */

/* ---- Floating button ---------------------------------------------------- */
.popup-fab {
  position: fixed;
  right: clamp(var(--s-4), 2.5vw, var(--s-6));
  bottom: calc(clamp(var(--s-4), 2.5vw, var(--s-6)) + env(safe-area-inset-bottom, 0px));
  z-index: 40; /* above the sticky masthead (20), below the dialog (top layer) */
  display: inline-flex;
  align-items: center;
  gap: var(--s-4);
  min-height: 52px;
  padding: var(--s-3) var(--s-5);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--c-amber);
  color: #14160F;
  font-family: var(--f-body);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.85);
  /* `backwards`, not `both`: a fill that persists after the entrance would
     pin opacity at 1 and stop the button hiding while the pop-up is open. */
  animation: fab-in 600ms var(--e-out) 700ms backwards;
  transition:
    background 120ms linear, /* short: amber→mint midway reads as olive */
    color 120ms linear,
    opacity 200ms var(--e-out),
    visibility 0s;
}
.popup-fab:hover { background: var(--c-amber-lift); }
.popup-fab:active { transform: scale(0.97); }
/* The ↗ motif, set tight after the label so the two read as one unit
   (Bryan, 29 Sept: never a label at one end and its arrow at the other). Drawn to Bryan's reference: full-length arms meeting in a sharp
   corner, square-cut ends. Same hover nudge as mulhollandbrand.com. */
.popup-fab__arrow {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 180ms var(--e-out);
}
.popup-fab__arrow path { stroke-width: 2; }
.popup-fab:focus-visible .popup-fab__arrow { transform: translate(2px, -2px); }
@media (hover: hover) and (pointer: fine) {
  .popup-fab:hover .popup-fab__arrow { transform: translate(2px, -2px); }
}

@keyframes fab-in {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: none; }
}

/* Scrolling: the button turns mint and a ring pulses out of it. The class is
   removed ~250ms after scrolling stops, so it settles back to amber. */
.popup-fab.is-flashing {
  background: var(--c-mint);
  color: #04231E;
}
.popup-fab::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(0, 235, 199, 0.55);
  opacity: 0;
  pointer-events: none;
}
.popup-fab.is-flashing::after {
  opacity: 1;
  animation: fab-ring 900ms var(--e-out) infinite;
}
@keyframes fab-ring {
  0%   { box-shadow: 0 0 0 0 rgba(0, 235, 199, 0.55); }
  100% { box-shadow: 0 0 0 16px rgba(0, 235, 199, 0); }
}

/* Out of the way while the pop-up is open. */
/* Also parked while a section with its own button is on screen (landing page). */
.popup-fab.is-parked,
.popup-is-open .popup-fab {
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms var(--e-out), visibility 0s linear 200ms;
}

/* Phone: a wide pill across the bottom, in thumb reach, label + arrow centred. The page gets bottom
   padding so the pill never sits over the footer links at the end. */
@media (max-width: 640px) {
  .popup-fab {
    left: var(--s-4);
    right: var(--s-4);
    bottom: calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
    justify-content: center;
    gap: var(--s-3);
    padding-inline: var(--s-5);
  }
  body:has(.popup-fab) { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  /* One button on phones (Jordan, approved by Bryan 12 Oct). The in-section
   * buttons go; the pill does the asking and takes each section's own button
   * wording (data-fab-label, swapped in funnel.js). The masthead and the
   * "Get directions" link are not in-section sign-up buttons and stay. */
  main section .btn[data-popup-open] { display: none; }
  .popup-fab__label { transition: opacity 150ms var(--e-out); }
  .popup-fab.is-swapping .popup-fab__label { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .popup-fab { animation: none; }
  .popup-fab.is-flashing { background: var(--c-amber); color: #14160F; }
  .popup-fab.is-flashing::after { animation: none; opacity: 0; }
  .popup-fab__label { transition: none; }
}

/* ---- Pop-up ------------------------------------------------ */
.popup {
  /* The reset zeroes margins; without margin:auto a showModal() dialog pins
     to the top-left instead of centring (Mulholland QuoteModal note). */
  margin: auto;
  width: min(960px, calc(100vw - 2 * var(--s-4)));
  max-height: calc(100dvh - 2 * var(--s-4));
  overflow-y: auto;
  padding: clamp(var(--s-5), 4vw, var(--s-7));
  border: 1px solid var(--c-line-str);
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--c-surface-2), var(--c-surface));
  color: var(--c-text);
  box-shadow: 0 40px 90px -25px rgba(0, 0, 0, 0.95);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition:
    opacity 220ms var(--e-out),
    transform 220ms var(--e-out),
    overlay 220ms allow-discrete,
    display 220ms allow-discrete;
}
.popup[open] { opacity: 1; transform: none; }
@starting-style {
  .popup[open] { opacity: 0; transform: translateY(8px) scale(0.98); }
}
.popup::backdrop {
  background: rgba(5, 6, 8, 0);
  transition:
    background 220ms var(--e-out),
    overlay 220ms allow-discrete,
    display 220ms allow-discrete;
}
.popup[open]::backdrop {
  background: rgba(5, 6, 8, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
@starting-style {
  .popup[open]::backdrop { background: rgba(5, 6, 8, 0); }
}
@media (prefers-reduced-motion: reduce) {
  .popup, .popup[open] { transform: none; }
}

.popup__title {
  font-size: var(--t-xl);
  margin-bottom: var(--s-2);
  padding-right: var(--s-7); /* clear of the close button */
}
.popup__sub {
  color: var(--c-text-mut);
  font-size: var(--t-sm);
  margin: 0 0 var(--s-5);
}
.popup__close {
  position: absolute;
  top: var(--s-3);
  right: var(--s-3);
  display: grid;
  place-items: center;
  width: 44px; height: 44px; /* full touch target */
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--c-text-mut);
  cursor: pointer;
}
.popup__close:hover { background: rgba(255, 255, 255, 0.08); color: var(--c-text); }
.popup__close svg { width: 22px; height: 22px; }

/* Keep the pop-up form inside one screen on a laptop: tighter rhythm than the
   page forms, dark scrollbar if it still has to scroll on a short window. */
.popup { color-scheme: dark; scrollbar-width: thin; }
.popup .form { gap: var(--s-3); }
.popup .field { gap: var(--s-1); }
.popup .input { min-height: 46px; padding-block: var(--s-2); }
.popup .popup__sub { margin-bottom: var(--s-4); }
.popup .eyebrow { margin-bottom: var(--s-2); }
.popup__pair { display: grid; gap: var(--s-3); }
@media (min-width: 560px) {
  /* The two short dropdowns sit side by side. */
  .popup__pair { grid-template-columns: 1fr 1fr; align-items: end; }
}

/* ---- Wide two-column layout -------------------------------------------- */
.popup__inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(var(--s-6), 5vw, var(--s-8));
  align-items: center;
}
.popup__copy { padding-right: var(--s-4); }
.popup__copy h2 {
  font-size: clamp(1.5rem, 1.1vw + 1.05rem, 2rem);
  line-height: 1.05;
  margin-bottom: var(--s-4);
}
.popup__copy .lede { font-size: var(--t-base); margin-bottom: var(--s-4); }
.popup__copy .popup__sub { margin: 0; }
.popup__form { min-width: 0; }

@media (max-width: 760px) {
  .popup__inner { grid-template-columns: 1fr; gap: var(--s-5); }
  .popup__copy { padding-right: 0; }
  .popup__copy > :first-child { padding-right: var(--s-7); } /* only the top line meets the close button */
  .popup__copy h2 { font-size: var(--t-xl); margin-bottom: var(--s-3); }
  .popup__copy .lede { font-size: var(--t-sm); margin-bottom: var(--s-2); }
  /* Consult pop-up: the form's own 24-hour line says enough on a phone; the form fits. */
  #consult-popup .popup__copy .lede { display: none; }
}

/* Floating pill: always one line; label scales on phones (Bryan 10-16) */
.popup-fab { white-space: nowrap; max-width: calc(100vw - 2 * var(--s-4)); }
@media (max-width: 640px) {
  .popup-fab {
    font-size: clamp(0.75rem, 3.6vw, 0.9375rem);
    letter-spacing: 0.05em;
    gap: var(--s-3);
    padding-inline: var(--s-4);
  }
}
