/*
 * THOTH — module de réservation.
 * Toutes les couleurs passent par les variables --tb-* ci-dessous : remplacez les valeurs
 * de secours par les variables de votre feuille de style (ex. --tb-ink: var(--ink);).
 * La police est héritée de la page (Readex Pro sur thoth.group).
 */
/* Raccordé aux jetons de thoth.group (README §7 étape 3). Le second argument de
   var() garde les couleurs d'origine là où ces jetons n'existent pas — la page
   d'exemple autonome de site-addons/ reste donc utilisable telle quelle.
   Les jetons du site basculant en mode sombre, le module suit automatiquement. */
[data-thoth-booking] {
  --tb-ink: var(--text, #172231);
  --tb-muted: var(--muted, #5b6676);
  --tb-line: var(--rule-strong, #d3dae3);
  --tb-paper: var(--surface, #ffffff);
  --tb-accent: var(--btn-bg, #1f4a73);
  --tb-accent-ink: var(--btn-fg, #ffffff);
  --tb-accent-soft: var(--panel, #eaf0f6);
  --tb-error: #a3262a;
  --tb-radius: var(--r-sm, 4px);

  color: var(--tb-ink);
  font: inherit;
  line-height: 1.5;
  max-width: 56rem;
}

/* Le rouge d'erreur n'a pas de jeton dans le site : il lui faut sa propre variante
   sombre, sans quoi il deviendrait illisible sur fond foncé. Même structure à trois
   états que la feuille du site : clair par défaut, préférence système, choix explicite. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-thoth-booking] { --tb-error: #F0908C; }
}
:root[data-theme="dark"] [data-thoth-booking] { --tb-error: #F0908C; }

.tb *,
.tb *::before,
.tb *::after { box-sizing: border-box; }

:where(.tb) button,
:where(.tb) input,
:where(.tb) textarea { font: inherit; color: inherit; } /* spécificité nulle : les classes gagnent */

.tb :focus-visible {
  outline: 2px solid var(--tb-accent);
  outline-offset: 2px;
}
.tb-heading:focus { outline: none; }

.tb-heading {
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 0.5rem;
}

.tb-loading,
.tb-zone,
.tb-note { color: var(--tb-muted); margin: 0 0 1.5rem; }
.tb-note a { color: var(--tb-accent); }

.tb-notice {
  margin: 0 0 1.25rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--tb-error);
  background: #fbf1f1;
}

/* ── Étape 1 : jours et heures ─────────────────────────────────────────── */
.tb-picker {
  display: grid;
  grid-template-columns: minmax(10rem, 13rem) 1fr;
  gap: 2rem;
  align-items: start;
}

.tb-days {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--tb-line);
}

.tb-day {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  width: 100%;
  padding: 0.7rem 0.75rem;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--tb-line);
  border-left: 3px solid transparent;
  text-align: left;
  cursor: pointer;
}
.tb-day:hover { background: var(--tb-accent-soft); }
.tb-day[aria-pressed="true"] {
  border-left-color: var(--tb-accent);
  background: var(--tb-accent-soft);
  font-weight: 500;
}
.tb-day-count {
  color: var(--tb-muted);
  font-size: 0.8125rem;
  font-weight: 400;
  white-space: nowrap;
}

.tb-day-title {
  font-size: 1rem;
  font-weight: 500;
  margin: 0 0 0.75rem;
}

.tb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.75rem, 1fr));
  gap: 0.5rem;
}

.tb-time {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.125rem;
  min-height: 3.25rem;
  padding: 0.6rem 0.5rem;
  background: var(--tb-paper);
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tb-time:hover {
  border-color: var(--tb-accent);
  color: var(--tb-accent);
}
.tb-time-main { font-size: 1.0625rem; font-weight: 500; }
.tb-time-alt { font-size: 0.75rem; color: var(--tb-muted); }

/* ── Étape 2 : formulaire ──────────────────────────────────────────────── */
.tb-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem 1.5rem;
  max-width: 38rem;
  margin: 0.5rem 0 1.75rem;
  padding: 0.9rem 1rem;
  background: var(--tb-accent-soft);
  border-left: 3px solid var(--tb-accent);
}
.tb-summary p { margin: 0; }

.tb-link {
  padding: 0;
  background: none;
  border: 0;
  color: var(--tb-accent);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.tb-form { max-width: 38rem; }

.tb-field {
  margin: 0 0 1.25rem;
  padding: 0;
  border: 0;
  min-width: 0;
}
.tb-field > label,
.tb-field > legend {
  display: block;
  font-weight: 500;
  margin: 0 0 0.35rem;
  padding: 0;
}
.tb-optional { color: var(--tb-muted); font-weight: 400; }
.tb-hint { margin: -0.15rem 0 0.4rem; color: var(--tb-muted); font-size: 0.875rem; }

.tb-field input[type="text"],
.tb-field input[type="email"],
.tb-field textarea {
  display: block;
  width: 100%;
  padding: 0.7rem 0.8rem;
  font-size: 1rem; /* 16 px : pas de zoom automatique sur iPhone */
  background: var(--tb-paper);
  border: 1px solid var(--tb-line);
  border-radius: var(--tb-radius);
}
.tb-field textarea { resize: vertical; min-height: 6rem; }
.tb-field input:focus,
.tb-field textarea:focus { border-color: var(--tb-accent); }

.tb .tb-option {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.4rem 0;
  font-weight: 400;
  cursor: pointer;
}
.tb-option input {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0.2rem 0 0;
  accent-color: var(--tb-accent);
}
.tb-choice .tb-option { border-bottom: 1px solid var(--tb-line); padding: 0.6rem 0; }
.tb-choice .tb-option:first-of-type { border-top: 1px solid var(--tb-line); }
.tb-consent a { color: var(--tb-accent); }

.tb-error,
.tb-form-error {
  margin: 0.35rem 0 0;
  color: var(--tb-error);
  font-size: 0.875rem;
}
.tb-error:empty,
.tb-form-error:empty { display: none; }
.tb-invalid input[type="text"],
.tb-invalid input[type="email"],
.tb-invalid textarea { border-color: var(--tb-error); }

.tb-submit {
  margin-top: 0.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--tb-accent);
  color: var(--tb-accent-ink);
  border: 0;
  border-radius: var(--tb-radius);
  font-weight: 500;
  cursor: pointer;
}
.tb-submit:disabled { opacity: 0.6; cursor: progress; }

.tb-hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ── Étape 3 ───────────────────────────────────────────────────────────── */
.tb-step-done p { max-width: 38rem; }

/* ── Mobile ────────────────────────────────────────────────────────────── */
@media (max-width: 42rem) {
  .tb-picker { grid-template-columns: 1fr; gap: 1.25rem; }
  .tb-days {
    flex-direction: row;
    overflow-x: auto;
    gap: 0.5rem;
    border-top: 0;
    padding-bottom: 0.25rem;
    scroll-snap-type: x proximity;
  }
  .tb-day {
    flex: none;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    width: auto;
    min-width: 6.5rem;
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-radius);
    scroll-snap-align: start;
  }
  .tb-day[aria-pressed="true"] { border-color: var(--tb-accent); border-left-width: 1px; box-shadow: inset 0 -3px 0 var(--tb-accent); }
  .tb-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (prefers-reduced-motion: no-preference) {
  .tb-day,
  .tb-time { transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease; }
}
