/* Demo date & time picker (calendar.js). Uses the colour tokens from
 * styles.css, so it follows the site's light and dark themes. */

.cal {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.cal__label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
}

/* The field: looks like the form's text inputs. */
.cal__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: color-mix(in srgb, var(--text-dim) 78%, transparent);
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}
.cal.has-value .cal__trigger {
  color: var(--text);
}
.cal__trigger:focus-visible,
.cal.is-open .cal__trigger {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--surface);
}
.cal.is-invalid .cal__trigger {
  border-color: var(--debit);
}
.cal__trigger svg {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--accent);
}
.cal__trigger svg,
.cal__nav svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.cal__text {
  flex: 1;
  min-width: 0;
}
.cal__chevron {
  transition: transform 0.2s ease;
}
.cal.is-open .cal__chevron {
  transform: rotate(180deg);
}

/* The panel that opens under the field. */
.cal__panel {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.cal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.cal__month {
  font-weight: 700;
}
.cal__nav {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.cal__nav svg {
  width: 18px;
  height: 18px;
}
.cal__nav:hover:not(:disabled) {
  background: var(--accent-soft);
}
.cal__nav:disabled {
  color: var(--border-strong);
  cursor: default;
}

.cal__weekdays,
.cal__days {
  display: grid;
  /* minmax(0, …): let the columns shrink below a button's natural width, so
   * the month fits a 320px phone instead of pushing past the form's edge. */
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
  text-align: center;
}
.cal__weekdays {
  margin-bottom: 4px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
}
.cal__day {
  position: relative;
  aspect-ratio: 1;
  max-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cal__day:hover:not(:disabled) {
  background: var(--accent-soft);
}
.cal__day:focus-visible,
.cal__slot:focus-visible,
.cal__nav:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.cal__day:disabled {
  color: var(--border-strong);
  cursor: default;
}
/* Today: a small dot under the number. */
.cal__day.is-today::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
  transform: translateX(-50%);
}
/* :hover too — a phone keeps the tapped day "hovered", which would fade it. */
.cal__day[aria-pressed='true'],
.cal__day[aria-pressed='true']:hover {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}
.cal__day[aria-pressed='true']::after {
  background: #fff;
}

.cal__slots-head {
  margin: 14px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 700;
}
.cal__slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 6px;
  max-height: 168px;
  overflow-y: auto;
}
.cal__slot {
  min-height: 44px;
  padding: 8px 6px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}
.cal__slot:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.cal__slot[aria-pressed='true'] {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.cal .signup-hint {
  color: var(--text-dim);
  font-size: 0.82rem;
}

/* Phones: the pop-up already scrolls, so a second scroll box inside it for the
 * times is fiddly to swipe. Let the times run full length instead. */
@media (max-width: 640px) {
  .cal__panel {
    padding: 12px 10px;
  }
  .cal__slots {
    max-height: none;
    overflow: visible;
  }
}
