/**
 * PX Booking — site styles. Bootstrap 5.3 of Joomla does the layout; this file only adds what Bootstrap
 * has not: the date grid, day states, slot buttons, honeypot. Every var(--bs-*) has a fallback (Cassiopeia
 * on Joomla 6 compiles most Bootstrap variables away). Override the --pxb-* variables in a template.
 */
.pxb {
  --pxb-primary: var(--cassiopeia-color-primary, var(--bs-primary, #0d6efd));
  --pxb-on-primary: #fff;
  --pxb-available: var(--bs-success-bg-subtle, #d1e7dd);
  --pxb-available-text: var(--bs-success-text-emphasis, #0a3622);
  --pxb-limited: var(--bs-warning-bg-subtle, #fff3cd);
  --pxb-limited-text: var(--bs-warning-text-emphasis, #664d03);
  --pxb-full: var(--bs-secondary-bg, #e9ecef);
  --pxb-full-text: var(--bs-secondary-color, #595c5f);
  --pxb-border: var(--bs-border-color, #dee2e6);
  --pxb-radius: var(--bs-border-radius, 0.375rem);
  --pxb-focus: var(--bs-focus-ring-color, rgba(13, 110, 253, 0.5));
  /* Solid focus ring, drawn outside the cell (offset) so it contrasts with the page, not with the cell. */
  --pxb-focus-ring: var(--pxb-primary);
  --pxb-page: var(--bs-body-bg, #fff);
  --pxb-day-size: 2.5rem;
}

/* Dark Bootstrap theme of the template (UX-24): dark-safe day colours. */
[data-bs-theme="dark"] .pxb {
  --pxb-available: var(--bs-success-bg-subtle, #051b11);
  --pxb-available-text: var(--bs-success-text-emphasis, #75b798);
  --pxb-limited: var(--bs-warning-bg-subtle, #332701);
  --pxb-limited-text: var(--bs-warning-text-emphasis, #ffda6a);
  --pxb-full: var(--bs-secondary-bg, #343a40);
  --pxb-full-text: var(--bs-secondary-color, #adb5bd);
  --pxb-border: var(--bs-border-color, #495057);
  --pxb-page: var(--bs-body-bg, #212529);
  --pxb-focus-ring: var(--bs-primary-text-emphasis, #6ea8fe);
}

/* Calendar ---------------------------------------------------------------------------------------- */
.pxb-cal__grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  table-layout: fixed;
}

.pxb-cal__grid th {
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  color: var(--pxb-full-text);
  padding: 0.25rem 0;
}

.pxb-cal__grid td {
  padding: 0;
  text-align: center;
}

.pxb-cal__nav,
.pxb-cal__nav-spacer {
  min-width: 2.25rem;
}

[dir="rtl"] .pxb-cal__arrow {
  display: inline-block;
  transform: scaleX(-1);
}

.pxb-day {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--pxb-day-size);
  border-radius: var(--pxb-radius);
  border: 1px solid transparent;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  color: inherit;
  position: relative;
}

a.pxb-day {
  cursor: pointer;
}

a.pxb-day:hover {
  border-color: var(--pxb-primary);
}

.pxb-day:focus-visible,
.pxb-slot:focus-visible,
.pxb-cal__nav:focus-visible {
  outline: 3px solid var(--pxb-focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--pxb-page);
  z-index: 1;
}

.pxb-day--available {
  background: var(--pxb-available);
  color: var(--pxb-available-text);
}

.pxb-day--limited {
  background: var(--pxb-limited);
  color: var(--pxb-limited-text);
}

/* "Few left" is not told by colour alone (UX-16): a corner mark, also in the legend. */
.pxb-day--limited::after,
.pxb-legend--limited::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentcolor;
}

.pxb-legend--limited {
  position: relative;
  color: var(--pxb-limited-text);
}

.pxb-legend--limited::after {
  top: 1px;
  right: 1px;
  width: 0.3rem;
  height: 0.3rem;
}

.pxb-day--full,
.pxb-day--closed {
  background: var(--pxb-full);
  color: var(--pxb-full-text);
  text-decoration: line-through;
}

.pxb-day--closed {
  background: transparent;
}

.pxb-day--today {
  font-weight: 700;
  box-shadow: inset 0 0 0 1px var(--pxb-full-text);
}

.pxb-day--selected {
  background: var(--pxb-primary);
  color: var(--pxb-on-primary);
  text-decoration: none;
}

.pxb-legend {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 0.2em;
  vertical-align: -0.1em;
  border: 1px solid var(--pxb-border);
}

.pxb-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  margin-inline-end: 0.75rem;
}

.pxb-legend--available { background: var(--pxb-available); }
.pxb-legend--limited { background: var(--pxb-limited); }
.pxb-legend--full { background: var(--pxb-full); }

/* Widget, slots, summary --------------------------------------------------------------------------- */
.pxb-widget {
  position: sticky;
  top: 1rem;
}

.pxb-slot {
  min-width: 4.5rem;
  font-variant-numeric: tabular-nums;
}

.pxb-slot[aria-pressed="true"] {
  background: var(--pxb-primary);
  color: var(--pxb-on-primary);
}

.pxb-summary:empty {
  display: none;
}

.pxb-quote__table caption {
  padding-top: 0;
}

.pxb-quote__line--coupon td {
  color: var(--bs-success-text-emphasis, #0a3622);
}

.pxb-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Default (Enter) button of the checkout form: out of sight and of the tab order (UX-1). */
.pxb-default-submit {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Rooms of a location as cards on phones (UX-19). */
@media (max-width: 575.98px) {
  .pxb-rooms__table thead {
    position: absolute;
    left: -10000px;
  }

  .pxb-rooms__table tr,
  .pxb-rooms__table th,
  .pxb-rooms__table td {
    display: block;
    text-align: start !important;
  }

  .pxb-rooms__table tr {
    border-bottom: 1px solid var(--pxb-border);
    padding: 0.5rem 0;
  }

  .pxb-rooms__table th,
  .pxb-rooms__table td {
    border: 0;
    padding: 0.15rem 0;
  }

  .pxb-rooms__table td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
  }
}

.pxb-countdown--low {
  color: var(--bs-danger-text-emphasis, #58151c);
  font-weight: 600;
}

/* Gallery, cards ----------------------------------------------------------------------------------- */
.pxb-gallery {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
}

.pxb-gallery__img {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.pxb-gallery__img--main {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 9;
}

.pxb-card__img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.pxb-card__link:focus-visible {
  outline: 3px solid var(--pxb-focus);
}

/* Status badges (contrast AA on both backgrounds) */
.pxb .pxb-status { background: var(--pxb-full); color: var(--pxb-full-text); }
.pxb .pxb-status--confirmed, .pxb .pxb-status--checked_in, .pxb .pxb-status--completed { background: var(--pxb-available); color: var(--pxb-available-text); }
.pxb .pxb-status--pending, .pxb .pxb-status--awaiting_approval { background: var(--pxb-limited); color: var(--pxb-limited-text); }
.pxb .pxb-status--cancelled, .pxb .pxb-status--no_show { background: var(--bs-danger-bg-subtle, #f8d7da); color: var(--bs-danger-text-emphasis, #58151c); }

/* Honeypot: away from sight and from assistive technology, but still in the form */
.pxb-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Conditional custom fields hidden by site.js */
.pxb-field[hidden] {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .pxb-day,
  .pxb-slot {
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
  }
}

@media print {
  .pxb-widget,
  .pxb-booking form,
  .pxb-cal {
    display: none;
  }
}
