/* Lock scroll with `clip`, not `hidden`: the page masks latent horizontal
   overflow via html,body{overflow-x:clip}. `overflow:hidden` here would upgrade
   overflow-x from clip to a hidden scroll container; Safari then fails to
   re-clip after the dialog closes, leaving the page horizontally scrollable.
   `overflow:clip` locks vertical scroll while keeping overflow-x as clip throughout. */
body.booking-open {
  overflow: clip;
}

.booking-dialog {
  width: min(720px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 40px);
  margin: auto;
  padding: 0;
  overflow: visible;
  color: var(--text);
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 20px;
  box-shadow: 0 32px 100px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
.booking-dialog::backdrop {
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(8px);
}
/* display only when open — a closed <dialog> must stay display:none (UA default)
   so showModal() promotes it to the top layer with a backdrop */
.booking-dialog[open] {
  display: block;
  animation: booking-in 0.2s ease-out;
}
.booking-shell {
  position: relative;
}
.booking-close {
  position: absolute;
  z-index: 5;
  top: 5px;
  right: 5px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--dim);
  box-shadow: none;
  appearance: none;
  transition: color 0.2s;
}
.booking-close svg {
  display: block;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.booking-close:hover,
.booking-close:focus-visible {
  color: var(--text);
  background: transparent;
}
.booking-step {
  padding: clamp(26px, 3.4vw, 40px);
}
.booking-eyebrow {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.booking-notice {
  margin: 0 0 16px;
  padding: 11px 14px;
  border: 1px solid rgba(255, 166, 87, 0.32);
  border-radius: 9px;
  background: rgba(255, 166, 87, 0.08);
  color: var(--c-orange);
  font-size: 13.5px;
}
.booking-notice--error {
  color: var(--c-red);
  border-color: rgba(255, 123, 114, 0.32);
  background: rgba(255, 123, 114, 0.08);
}

/* two-column: identity rail | calendar + time picker */
.booking-scheduler {
  display: grid;
  grid-template-columns: 186px minmax(0, 1fr);
  gap: clamp(22px, 2.6vw, 38px);
}
.booking-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  outline: none;
}
.booking-rail {
  display: flex;
  flex-direction: column;
  padding-right: clamp(4px, 1.4vw, 18px);
  border-right: 1px solid var(--border);
}
.booking-rail__title {
  margin: 0 0 6px;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.08;
  outline: none;
}
.booking-rail__meta {
  display: grid;
  gap: 13px;
  margin-top: 22px;
}
.booking-rail__meta li {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--dim);
  font-size: 14px;
}
.booking-rail__meta svg {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: var(--dim);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.booking-rail__picked {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 5px;
}
.booking-rail__picked strong {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

/* calendar (compact) */
.booking-calendar {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0c0c0c;
  padding: 16px 16px 18px;
}
.booking-calendar__nav {
  display: grid;
  grid-template-columns: 30px 1fr 30px;
  align-items: center;
  margin-bottom: 14px;
  text-align: center;
}
.booking-calendar__nav strong {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.booking-calendar__nav button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--dim);
  font-size: 17px;
  line-height: 1;
  transition:
    color 0.2s,
    border-color 0.2s,
    background 0.2s;
}
.booking-calendar__nav button:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border2);
  background: var(--surface);
}
.booking-calendar__nav button:disabled {
  opacity: 0.22;
  cursor: default;
}
.booking-calendar__weekdays,
.booking-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
  width: 100%;
  max-width: 300px;
  margin-inline: auto;
}
.booking-calendar__weekdays {
  margin-bottom: 5px;
  color: var(--dim2);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-align: center;
  text-transform: uppercase;
}
.booking-day {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #cfcfcf;
  font-size: 13px;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
.booking-day__num {
  line-height: 1;
  transform: translateY(-1px);
}
.booking-day.has-slots {
  color: var(--text);
}
.booking-day.has-slots::after {
  content: "";
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--dim);
  transition: background 0.15s;
}
.booking-day:hover.has-slots:not(.is-selected) {
  border-color: var(--border2);
  background: var(--surface);
}
.booking-day.is-today:not(.is-selected) {
  border-color: var(--border2);
}
.booking-day.is-selected {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  font-weight: 500;
}
.booking-day.is-selected::after {
  background: var(--bg);
}
.booking-day:disabled {
  color: #3a3a3a;
  cursor: default;
}
.booking-day--empty {
  aspect-ratio: 1;
  visibility: hidden;
}

/* time picker row: combobox + continue */
.booking-timebox {
  margin-top: 16px;
  min-height: 48px;
}
.booking-timebox__row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.booking-timebox__combo {
  flex: 1;
  min-width: 0;
}
.booking-timebox__state {
  padding: 14px 2px;
  color: var(--dim);
  font-size: 14px;
}
.booking-timebox__state--error {
  color: var(--c-red);
}
.booking-timebox__retry {
  margin-left: 6px;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.booking-continue {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 22px;
  border: 1px solid var(--text);
  border-radius: 10px;
  background: var(--text);
  color: var(--bg);
  font-size: 14.5px;
  font-weight: 500;
  transition:
    background 0.2s,
    opacity 0.2s,
    transform 0.2s;
}
.booking-continue:hover:not(:disabled) {
  background: #e8e8e8;
  transform: translateY(-1px);
}
.booking-continue:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* basecoat combobox themed to the dark token system */
.booking-combobox {
  position: relative;
  width: 100%;
}
.booking-combobox input[role="combobox"] {
  width: 100%;
  height: 44px !important;
  padding: 0 40px 0 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  /* iPhone Safari focus-zooms text controls below 16px. That changes the
     visual viewport scale (not the document width), which can leave the page
     horizontally pannable after the modal closes. Keep this at 16px. */
  background: #161616;
  color: var(--text);
  font: 400 16px/1.4 var(--sans);
  outline: none;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}
.booking-combobox input[role="combobox"]:hover {
  border-color: rgba(255, 255, 255, 0.46);
  background: #1b1b1b;
}
.booking-combobox input[role="combobox"]:focus {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.07);
}
/* bright, opaque prompt so the field reads as an active control, not a disabled well */
.booking-combobox input[role="combobox"]::placeholder {
  color: #b2b5b9;
  opacity: 1;
}
/* ensure the combobox is the positioning context (beat basecoat's .combobox) */
.booking-combobox.combobox {
  position: relative !important;
}
/* Basecoat centers with the individual `translate` property, not `transform`.
   Keep top and translate as one positioning model so the inherited -50%
   translation cannot be combined with inset-based centering. */
.booking-combobox svg.combobox-trigger-icon {
  position: absolute !important;
  right: 13px !important;
  left: auto !important;
  top: 50% !important;
  bottom: auto !important;
  margin: 0 !important;
  translate: 0 -50% !important;
  transform: none !important;
  width: 18px;
  height: 18px;
  color: #d4d4d4;
  pointer-events: none;
}
/* popover: target by id-prefix so styling holds even if basecoat relocates it
   in the DOM, and use !important to win over the basecoat-lyra defaults */
[data-popover][id^="booking-timebox-"] {
  z-index: 60;
  margin-top: 6px;
  padding: 6px;
  border: 1px solid var(--border2);
  border-radius: 12px;
  background: #141414;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  color-scheme: dark;
  max-height: 236px;
  overflow-y: auto;
  scrollbar-width: thin;
}
[data-popover][id^="booking-timebox-"] [role="listbox"] {
  display: grid;
  gap: 2px;
}
[data-popover][id^="booking-timebox-"] [role="option"] {
  display: flex;
  align-items: center;
  min-height: 44px; /* Apple HIG minimum 44pt tap target */
  padding: 0 14px !important;
  margin: 0 !important;
  border-radius: 9px;
  color: #dedede;
  font: 400 15px/1.2 var(--sans);
  cursor: pointer;
  transition:
    background 0.12s,
    color 0.12s;
}
[data-popover][id^="booking-timebox-"] [role="option"]:hover,
[data-popover][id^="booking-timebox-"] [role="option"][aria-selected="true"],
[data-popover][id^="booking-timebox-"] [role="option"].active,
[data-popover][id^="booking-timebox-"] [role="option"][data-active="true"] {
  background: rgba(255, 255, 255, 0.09) !important;
  color: #fff !important;
}
[data-popover][id^="booking-timebox-"] [role="listbox"][data-empty]:empty::after {
  content: attr(data-empty);
  display: block;
  padding: 12px;
  color: var(--dim);
  font-size: 13.5px;
}

/* form step */
/* form fills the right column beside the persistent rail */
.booking-form {
  display: grid;
  gap: 16px;
}
.booking-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.booking-field {
  display: grid;
  gap: 8px;
  color: #dedede;
  font-size: 14px;
  font-weight: 500;
}
.booking-field span {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}
.booking-field em {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9px;
  font-style: normal;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.booking-field input,
.booking-field textarea {
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: #0b0b0b;
  color: var(--text);
  font: 400 16px/1.4 var(--sans);
  outline: none;
  padding: 12px 13px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}
.booking-field textarea {
  resize: vertical;
  min-height: 104px;
}
.booking-field input:focus,
.booking-field textarea:focus {
  border-color: rgba(255, 255, 255, 0.48);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}
.booking-field input[aria-invalid="true"] {
  border-color: var(--c-red);
}
.booking-field small {
  color: var(--c-red);
  font-size: 12px;
  font-weight: 400;
}
.booking-form__privacy {
  margin: 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.45;
}
.booking-form__privacy a {
  color: #c9c9c9;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.booking-form__privacy a:hover {
  color: var(--text);
}
.booking-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}
/* match the calendar step's Continue button so both steps read consistently */
.booking-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  height: 44px;
  padding: 0 22px;
  border: 1px solid var(--border2);
  border-radius: 10px;
  font-size: 14.5px;
  font-weight: 500;
  transition:
    background 0.2s,
    color 0.2s,
    border-color 0.2s,
    transform 0.2s;
}
.booking-button--secondary {
  color: var(--dim);
}
.booking-button--secondary:hover {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.35);
}
.booking-button--primary {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.booking-button--primary:hover:not(:disabled) {
  background: #e8e8e8;
  transform: translateY(-1px);
}
.booking-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* success step */
.booking-success {
  display: flex;
  max-width: 600px;
  margin: 0 auto;
  align-items: flex-start;
  justify-content: center;
  flex-direction: column;
}
.booking-success h2 {
  margin: 5px 0 16px;
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 0.92;
  outline: none;
}
.booking-success > p:not(.booking-eyebrow) {
  max-width: 520px;
  color: var(--dim);
  font-size: 16px;
}
.booking-success strong {
  color: var(--text);
  font-weight: 500;
}
.booking-success .booking-success__time {
  margin-bottom: 12px;
  color: var(--text);
  font-size: 19px;
}
.booking-success .booking-button {
  margin-top: 30px;
}

@keyframes booking-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 720px) {
  .booking-dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    border-radius: 16px;
  }
  .booking-step {
    padding: clamp(24px, 4vw, 32px);
  }
  .booking-scheduler {
    display: block;
  }
  .booking-rail {
    padding: 0 0 18px;
    margin-bottom: 18px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .booking-rail__meta {
    grid-auto-flow: column;
    justify-content: start;
    gap: 6px 22px;
    margin-top: 14px;
  }
  /* the dialog scrolls on mobile (overflow-y:auto), which clips a downward
     popover opening past the dialog's bottom edge. The combobox sits at the
     bottom of the calendar step, so open the times upward — over the calendar,
     inside the dialog's box, where nothing clips them. */
  [data-popover][id^="booking-timebox-"] {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 6px !important;
  }
}
@media (max-width: 520px) {
  .booking-rail__meta {
    grid-auto-flow: row;
    gap: 8px;
  }
  .booking-timebox__row {
    flex-direction: column;
  }
  .booking-continue {
    justify-content: center;
    padding: 12px 22px;
  }
  .booking-form__row {
    grid-template-columns: 1fr;
  }
  .booking-actions {
    flex-direction: column-reverse;
  }
  .booking-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .booking-dialog[open] {
    animation: none;
  }
}
