/* =============================================================================
   booking.css — modal shell for the Calendly booking widget
   -----------------------------------------------------------------------------
   Paired with assets/booking.js. Visual rules:
     • Backdrop is a soft, blurred dim — never pure black.
     • Panel matches the project's dark cinematic palette.
     • Inline Calendly iframe gets a transparent background so it inherits the
       panel surface; we set its theme + brand color via Calendly query params
       (booking.js builds the URL).
     • Reduced-motion users get an instant fade-in instead of a slide.

   Selector contract (mirrors booking.js):
     .booking-modal[data-open="true"]
       .booking-modal__panel        — sized container
         .booking-modal__head        — title + close button
         .booking-modal__embed       — Calendly inline-widget mount (≥520px)
         .booking-modal__fallback    — shown when Calendly fails / opt-out
   ========================================================================== */

.booking-modal {
  position: fixed;
  inset: 0;
  z-index: 200;                       /* above chatbot (90) and cookie banner (80) */
  display: none;
  align-items: stretch;
  justify-content: center;
  background: color-mix(in oklab, var(--bg-0) 70%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: clamp(12px, 3vw, 32px);
  overflow-y: auto;
  /* Use overscroll-behavior so scroll inside the panel doesn't bubble. */
  overscroll-behavior: contain;
}
.booking-modal[data-open="true"] {
  display: flex;
  animation: booking-fade .25s ease-out both;
}
@keyframes booking-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.booking-modal__panel {
  position: relative;
  width: min(960px, 100%);
  max-height: 100%;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
  animation: booking-rise .3s cubic-bezier(.2,.7,.2,1) both;
}
@keyframes booking-rise {
  from { transform: translateY(12px); }
  to   { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .booking-modal[data-open="true"] { animation: none; }
  .booking-modal__panel             { animation: none; }
}

/* Header --------------------------------------------------------------- */
.booking-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in oklab, var(--bg-1) 92%, transparent);
}
.booking-modal__head__title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.booking-modal__head__title strong {
  font-size: 16px;
  color: var(--fg-0);
  font-weight: 500;
  letter-spacing: 0;
}
.booking-modal__head__title span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--fg-2);
}
.booking-modal__close {
  /* With the Calendly iframe filling the panel, this is one of the few
   * exit paths — making it generous on phones matters. 44x44 AAA target. */
  width: 44px; height: 44px;
  border-radius: 999px;
  display: grid; place-items: center;
  color: var(--fg-1);
  border: 1px solid var(--line);
  background: transparent;
  transition: color .2s, background .2s, border-color .2s;
  flex: none;
}
.booking-modal__close:hover {
  color: var(--fg-0);
  background: var(--line);
  border-color: var(--line-strong);
}
.booking-modal__close svg { width: 14px; height: 14px; }

/* Embed mount ---------------------------------------------------------- */
/* Calendly's inline widget injects an <iframe>; we set min-height so it
 * never collapses while loading. The actual content gets a transparent
 * background via the &embed_domain & &background_color query params built
 * in booking.js — those are critical for the embed to feel native.
 */
.booking-modal__embed {
  flex: 1 1 auto;
  /* Adapt to viewport: tall enough for desktop, compact enough that
   * iPhone SE (667px viewport - chrome ≈ 90px) doesn't get a double
   * scrollbar. dvh handles dynamic mobile chrome correctly. */
  min-height: clamp(420px, 70dvh, 620px);
  background: var(--bg-1);
  position: relative;
}
.booking-modal__embed iframe {
  width: 100%; height: 100%;
  min-height: clamp(420px, 70dvh, 620px);
  border: 0;
  display: block;
}

/* Loading state — shimmer behind the iframe until Calendly paints */
.booking-modal__loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 10px;
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(110deg,
    color-mix(in oklab, var(--bg-1) 70%, transparent) 30%,
    color-mix(in oklab, var(--bg-2) 90%, transparent) 50%,
    color-mix(in oklab, var(--bg-1) 70%, transparent) 70%);
  background-size: 200% 100%;
  animation: booking-shimmer 1.4s linear infinite;
  pointer-events: none;
}
.booking-modal[data-loaded="true"] .booking-modal__loading { display: none; }
@keyframes booking-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .booking-modal__loading { animation: none; }
}

/* Fallback panel — shown when Calendly fails or the user opts out of
 * the marketing-cookies category. Always present in the DOM so we can
 * focus it on error.                                                       */
.booking-modal__fallback {
  display: none;
  padding: clamp(28px, 4vw, 48px);
  text-align: center;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  color: var(--fg-1);
}
.booking-modal__fallback h3 {
  font-size: 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--fg-0);
}
.booking-modal__fallback p { max-width: 52ch; line-height: 1.5; }
.booking-modal[data-fallback="true"] .booking-modal__embed   { display: none; }
.booking-modal[data-fallback="true"] .booking-modal__fallback{ display: flex; }


/* Standalone booking surface. The page grows with the form, while the modal
 * owns its own scroll container. This avoids nested scrolling on phones. */
.booking-page-embed {
  position: relative;
  min-height: 560px;
  overflow: clip;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-1);
  scroll-margin-bottom: 160px;
}
.booking-page-embed iframe {
  display: block;
  width: 100%;
  min-height: 680px;
  border: 0;
}
.booking-expectations {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-expectations span {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  white-space: nowrap;
}
.booking-expectations span + span::before {
  width: 3px;
  height: 3px;
  margin: 0 14px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}
.booking-modal__embed {
  overflow-y: auto;
}

/* =============================================================================
   CalMesh first-party booking flow
   ========================================================================== */
.booking-calmesh {
  min-height: 560px;
  padding: clamp(20px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  color: var(--fg-1);
}
.booking-modal__embed .booking-calmesh {
  min-height: 100%;
}
.booking-calmesh__toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  align-items: end;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.booking-calmesh__intro {
  min-width: 0;
}
.booking-calmesh__intro h3 {
  margin: 4px 0 8px;
  color: var(--fg-0);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0;
}
.booking-calmesh__intro p {
  max-width: 58ch;
  margin: 0;
  color: var(--fg-1);
  font-size: 14px;
  line-height: 1.55;
}
.booking-calmesh__step {
  margin: 0;
  color: var(--accent);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__timezone {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__timezone select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2, var(--bg-1));
  color: var(--fg-0);
  padding: 0 36px 0 12px;
  font: inherit;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  letter-spacing: 0;
  text-transform: none;
}
.booking-calmesh__timezone select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.booking-calmesh__day-nav {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: stretch;
  gap: 8px;
}
.booking-calmesh__day-step {
  width: 40px;
  min-height: 68px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--fg-0);
  font-size: 24px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease;
}
.booking-calmesh__day-step:hover:not(:disabled) {
  background: var(--bg-2);
  border-color: var(--line-strong);
}
.booking-calmesh__day-step:disabled {
  cursor: default;
  opacity: .28;
}
.booking-calmesh__day-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(86px, 1fr);
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: thin;
  scroll-snap-type: x proximity;
}
.booking-calmesh__day-tab {
  min-width: 86px;
  min-height: 68px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2, var(--bg-1));
  color: var(--fg-1);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  scroll-snap-align: center;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.booking-calmesh__day-tab span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__day-tab strong {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}
.booking-calmesh__day-tab:hover,
.booking-calmesh__day-tab[aria-selected="true"] {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 12%, var(--bg-2));
  color: var(--fg-0);
}
.booking-calmesh__day-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 220px;
}
.booking-calmesh__day-panel h4 {
  margin: 0;
  color: var(--fg-0);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
}
.booking-calmesh__slots {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}
.booking-calmesh__slot {
  appearance: none;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--fg-0);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
.booking-calmesh__slot:hover {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent) 10%, var(--bg-1));
}
.booking-calmesh__slot:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.booking-calmesh__slot:active {
  transform: translateY(1px);
}

.booking-calmesh--loading {
  justify-content: center;
}
.booking-calmesh__loading {
  width: min(620px, 100%);
  margin: auto;
  color: var(--fg-2);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__skeleton {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.booking-calmesh__skeleton span {
  height: 48px;
  border-radius: 8px;
  background: linear-gradient(110deg, var(--bg-2) 30%, color-mix(in oklab, var(--bg-2) 75%, var(--fg-2)) 50%, var(--bg-2) 70%);
  background-size: 220% 100%;
  animation: booking-shimmer 1.4s linear infinite;
}

.booking-calmesh__form {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 32px);
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.booking-calmesh__form-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}
.booking-calmesh__form-head h3 {
  margin: 4px 0 0;
  color: var(--fg-0);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0;
}
.booking-calmesh__slot-summary {
  margin: 6px 0 0;
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__back {
  align-self: flex-start;
  min-height: 36px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  font: inherit;
  font-size: 12px;
  letter-spacing: 0;
  cursor: pointer;
}
.booking-calmesh__back:hover {
  color: var(--fg-0);
}
.booking-calmesh__form .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.booking-calmesh__form .field label {
  color: var(--fg-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0;
  text-transform: uppercase;
}
.booking-calmesh__form .field__hint {
  color: var(--fg-3);
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
}
.booking-calmesh__form .field__required {
  color: #ff7a7a;
}
.booking-calmesh__form .field--checkbox label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--fg-1);
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0;
  line-height: 1.45;
  text-transform: none;
  cursor: pointer;
}
.booking-calmesh__form .field--checkbox input[type="checkbox"] {
  appearance: auto;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}
.booking-calmesh__form .field--checkbox a {
  color: var(--fg-0);
  text-decoration: underline;
}
.booking-calmesh__form input,
.booking-calmesh__form textarea {
  appearance: none;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-2, var(--bg-1));
  color: var(--fg-0);
  font: inherit;
  font-size: 16px;
  letter-spacing: 0;
  line-height: 1.4;
}
.booking-calmesh__form input:focus,
.booking-calmesh__form textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.booking-calmesh__form textarea {
  min-height: 92px;
  resize: vertical;
}
.booking-calmesh__form .field__help {
  color: #ff8a8a;
  font-size: 12px;
}
.booking-calmesh__form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}
.booking-calmesh__form-actions .btn {
  min-width: 180px;
  justify-content: center;
}
.booking-calmesh__form-error {
  margin: 0;
  color: #ff8a8a;
  font-size: 13px;
  line-height: 1.45;
}

.booking-calmesh__success,
.booking-calmesh__fallback {
  min-height: 520px;
  padding: clamp(32px, 6vw, 64px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--fg-1);
  text-align: center;
}
.booking-calmesh__success-mark {
  width: 44px;
  height: 44px;
  border: 1px solid color-mix(in oklab, #64d99f 62%, var(--line));
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #64d99f;
  font-size: 20px;
}
.booking-calmesh__success h3,
.booking-calmesh__fallback h3 {
  margin: 0;
  color: var(--fg-0);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0;
}
.booking-calmesh__success p,
.booking-calmesh__fallback p {
  max-width: 56ch;
  margin: 0;
  line-height: 1.55;
}
.booking-calmesh__success-note {
  color: var(--fg-2);
  font-size: 13px;
}
.booking-calmesh__success-actions,
.booking-calmesh__fallback-actions {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* The calendar should arrive quickly on small screens, before a tall hero. */
.page-hero[data-screen-label="Book / Hero"] {
  min-height: min(420px, 46vh) !important;
}

@media (max-width: 720px) {
  .booking-modal {
    padding: 0;
  }
  .booking-modal__panel {
    width: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .booking-modal__head {
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  }
  .booking-modal__embed {
    min-height: 0;
  }
  .booking-page-embed {
    min-height: 520px;
  }
  .booking-expectations {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
    overflow: visible;
  }
  .booking-expectations span {
    justify-content: center;
    min-width: 0;
    padding: 2px 7px;
    line-height: 1.4;
    text-align: center;
    white-space: normal;
  }
  .booking-expectations span + span {
    border-left: 1px solid var(--line);
  }
  .booking-expectations span + span::before {
    display: none;
  }
  .booking-calmesh {
    min-height: 520px;
    padding: 18px 14px;
    gap: 18px;
  }
  .booking-calmesh__toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
    gap: 16px;
    padding-bottom: 16px;
  }
  .booking-calmesh__intro h3 {
    font-size: 22px;
  }
  .booking-calmesh__day-nav {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
    gap: 6px;
  }
  .booking-calmesh__day-step {
    width: 36px;
    min-height: 64px;
  }
  .booking-calmesh__day-tabs {
    grid-auto-columns: 82px;
    gap: 6px;
  }
  .booking-calmesh__day-tab {
    min-width: 82px;
    min-height: 64px;
    padding: 8px;
  }
  .booking-calmesh__slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .booking-calmesh__form {
    padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  }
  .booking-calmesh__form-actions .btn {
    width: 100%;
    min-width: 0;
    justify-content: center;
  }
  .booking-calmesh__success,
  .booking-calmesh__fallback {
    min-height: 480px;
    padding: 32px 18px calc(32px + env(safe-area-inset-bottom));
  }
  .booking-calmesh__success-actions,
  .booking-calmesh__fallback-actions {
    width: 100%;
    flex-direction: column;
  }
  .booking-calmesh__success-actions .btn,
  .booking-calmesh__fallback-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .page-hero[data-screen-label="Book / Hero"] {
    min-height: 320px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .booking-calmesh__slot,
  .booking-calmesh__day-tab,
  .booking-calmesh__day-step {
    transition: none;
  }
  .booking-calmesh__skeleton span {
    animation: none;
  }
}
