/* Shared booking picker — the month grid + slot column used by BOTH the public
 * call-booking form (www/) and the portal scheduling surface (portal/).
 *
 * Single source of truth. This file used to exist twice: 31 rules in
 * www/static/css/page-contact.css and 48 inline in
 * portal/templates/intake/schedule.html. The two drifted, which is why the same
 * calendar looked like two different products.
 *
 * The two apps ship different design-token vocabularies (www: --line/--ink/
 * --accent/--s1; portal: --border/--text/--brand/--r-sm), so this file consumes
 * a neutral --bp-* set. Each app maps its own tokens onto --bp-* on
 * .booking-picker-grid; the fallbacks below keep the picker legible if a host
 * forgets to. Do not reference an app-specific variable in here.
 */

.booking-picker-grid {
  display: grid;
  gap: var(--bp-gap-lg, 1rem);
  grid-template-columns: minmax(320px, 1fr) minmax(240px, 0.8fr);
  align-items: start;
}

.booking-picker-calendar {
  border: 1px solid var(--bp-line, #d5d9e0);
  border-radius: var(--bp-radius-lg, 12px);
  background: var(--bp-surface-muted, #f6f7f9);
  padding: var(--bp-gap-lg, 0.9rem);
}

/* Both arrows are ALWAYS in the flow -- an unavailable one is invisible but
   still occupies its 44px (see the :disabled rule below). That is what keeps
   the month label optically centred: with the prev arrow removed from the row
   entirely, the label's flex box started at the left edge instead of after a
   44px button, so its centre sat ~25px left and the title visibly jumped
   sideways between the first month and the second. */
.booking-picker-calendar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bp-gap-md, 0.6rem);
  margin-bottom: 0.75rem;
}
.booking-picker-calendar__header strong {
  flex: 1 1 auto;
  text-align: center;
  font-size: 0.98rem;
}

/* 44px keeps the month arrows tappable; without an explicit height they
   collapse to text size on touch. flex:0 0 auto stops them absorbing the free
   space left when the sibling arrow is invisible. */
.booking-picker-calendar__nav {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
}

/* visibility, not display/[hidden]: the button keeps its footprint so the
   label never shifts, and visibility:hidden also drops it from the
   accessibility tree so a dead arrow is not announced. Same trick
   .booking-picker-day-btn.is-empty uses for the leading blanks in the grid.
   The engine only ever toggles `disabled` -- never the hidden attribute. */
.booking-picker-calendar__nav:disabled {
  visibility: hidden;
  pointer-events: none;
}

.booking-picker-calendar__weekdays,
.booking-picker-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: var(--bp-gap-sm, 0.35rem);
}

/* Hold a constant height across months. A 5-row month next to a 6-row month
   otherwise reflows the whole surface on every month nav -- on the www wizard
   that also re-triggers step-height syncing. Lives here, not in a host
   stylesheet, so both surfaces get the same stable grid. */
.booking-picker-calendar__grid { min-height: 304px; align-content: start; }

.booking-picker-calendar__weekdays {
  margin-bottom: var(--bp-gap-sm, 0.35rem);
}

.booking-picker-calendar__weekdays span {
  text-align: center;
  font-size: 0.75rem;
  color: var(--bp-ink-soft, #6b7280);
}

/* Day + slot buttons are generated by booking-picker.js with these exact
   class names. Renaming one means renaming it there too.

   The cell contains a date and NOTHING else -- no slot count. Availability is
   carried entirely by the enabled/disabled state below. See the header note in
   booking-picker.js for the ruling. */
.booking-picker-day-btn {
  border: 1px solid var(--bp-line, #d5d9e0);
  border-radius: var(--bp-radius, 8px);
  min-height: 52px;
  background: var(--bp-surface-soft, #ffffff);
  color: var(--bp-ink, #111827);
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 0.3rem 0.15rem;
  font: inherit;
  line-height: 1.15;
}

.booking-picker-day-btn strong {
  font-size: 0.95rem;
  font-weight: 600;
}

.booking-picker-day-btn:hover:not(:disabled) {
  border-color: var(--bp-line-strong, #9aa3b0);
}

.booking-picker-day-btn.is-active {
  border-color: var(--bp-accent, #2563eb);
  box-shadow: inset 0 0 0 1px var(--bp-accent, #2563eb);
}

/* Leading blanks before the 1st of the month: hold grid position, take no
   interaction. */
.booking-picker-day-btn.is-empty {
  visibility: hidden;
  pointer-events: none;
}

/* A fully-booked day. Dimmed and inert -- the ONLY signal that a day has no
   openings now that counts are gone, so it must stay clearly distinguishable
   from an available day at a glance. `.is-empty` above reuses this rule for
   the leading blanks but overrides visibility outright. */
.booking-picker-day-btn:disabled {
  opacity: 0.32;
  cursor: not-allowed;
  background: transparent;
}

.booking-picker-slots-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.booking-picker-slots-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: var(--bp-gap-md, 0.6rem);
}

/* Carries the selected day's date (filled by the component). With the grid no
   longer printing counts, this is what tells the visitor which day the times
   below belong to -- keep it prominent rather than a muted caption. */
.booking-picker-slots-head h3 {
  margin: 0;
  color: var(--bp-ink, #111827);
  font-size: 0.95rem;
  font-weight: 700;
}

.booking-picker-slots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--bp-gap-sm, 0.4rem);
  max-height: 360px;
  overflow: auto;
  padding-right: 0.15rem;
}

.booking-picker-slot-btn {
  border: 1px solid var(--bp-line, #d5d9e0);
  border-radius: var(--bp-radius, 8px);
  padding: 0.55rem 0.4rem;
  min-height: 44px;
  background: var(--bp-surface, #ffffff);
  color: var(--bp-ink, #111827);
  text-align: center;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
}

.booking-picker-slot-btn:hover {
  border-color: var(--bp-line-strong, #9aa3b0);
}

.booking-picker-slot-btn.is-active {
  border-color: var(--bp-accent, #2563eb);
  box-shadow: inset 0 0 0 1px var(--bp-accent, #2563eb);
  color: var(--bp-accent-text, #1d4ed8);
  font-weight: 600;
}

/* Colour/border only -- never layout motion, which would jitter the grid as
   months re-render. */
.booking-picker-day-btn,
.booking-picker-slot-btn {
  transition:
    border-color var(--bp-duration, 140ms) var(--bp-ease, ease),
    color var(--bp-duration, 140ms) var(--bp-ease, ease),
    box-shadow var(--bp-duration, 140ms) var(--bp-ease, ease);
}

@media (prefers-reduced-motion: reduce) {
  .booking-picker-day-btn,
  .booking-picker-slot-btn { transition: none; }
}

@media (max-width: 860px) {
  .booking-picker-grid { grid-template-columns: 1fr; }
  .booking-picker-calendar { padding: 0.7rem; }
  .booking-picker-calendar__grid { gap: 0.25rem; min-height: 272px; }
  .booking-picker-day-btn { min-height: 46px; }
  /* The slot column is no longer beside the grid, so let it run full length
     instead of trapping a second scroll region inside the page scroll. */
  .booking-picker-slots { max-height: none; }
}

@media (max-width: 420px) {
  /* Date-only cells already fit at this width, so nothing has to be dropped.
     Tighten the grid and lean harder on the dimming so the available/booked
     split stays readable on a small screen. */
  .booking-picker-calendar__grid { min-height: 244px; }
  .booking-picker-day-btn { min-height: 42px; }
  .booking-picker-day-btn:disabled { opacity: 0.25; }
}
