/* ============================================================================
   Branded Discovery-Call Booking — design system (§5, enforced)
   Every color traces to a §5 token. Accent (#B25A32) is used on CTAs ONLY.
   Contrast note: white-on-#C1653A measures 4.05:1 (fails 4.5:1), so per §5 the
   CTA accent is darkened to #B25A32 = 4.77:1 white-on-accent / 4.66:1 as text.
   No drop shadows. System fonts only (no CDN). Mobile-first.
   ========================================================================== */

:root {
  --bg:            #FDFBF7;   /* warm white — page background */
  --surface:       #FFFFFF;   /* cards, panels, form fields (also = white text) */
  --surface-alt:   #F3EFE8;   /* alternating sections, subtle bands */
  --text:          #2B2B2B;   /* body copy, headings */
  --text-muted:    #6B6560;   /* captions, labels, secondary copy (16px+ only) */
  --border:        #E3DDD3;   /* hairlines, card edges, input borders */
  --accent:        #B25A32;   /* terracotta (§5 AA-darkened) — CTAs ONLY */
  --accent-hover:  #A85430;
  --secondary:     #8A9A82;   /* sage — icons, tags, decorative only */

  --radius: 6px;
  --maxw: 1080px;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua",
                Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  color-scheme: light;
}

/* --- Reset / base ---------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: 1.0625rem;          /* 17px */
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.2;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 1.9rem); }
h3 { font-size: 1.2rem; }
p  { color: var(--text); }
a  { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
img, svg { max-width: 100%; display: block; }
/* The hidden attribute must always win over class display rules (skeletons, spinner). */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.band      { background: var(--bg); }
.band--alt { background: var(--surface-alt); }
.muted     { color: var(--text-muted); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Buttons (§5 rule 6) --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; line-height: 1;
  padding: 14px 28px; border-radius: var(--radius);
  border: 1px solid transparent; background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none;
  min-height: 48px;              /* thumb target */
  transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}
.btn--primary { background: var(--accent); color: var(--surface); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--secondary { background: transparent; border-color: var(--border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-alt); }
.btn--block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: .55; cursor: not-allowed; pointer-events: none;
}
.btn .spinner { width: 16px; height: 16px; }

/* --- Header / footer ------------------------------------------------------- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 0; background: var(--bg);
}
.site-header .container { display: flex; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
/* Brand logo — Radius Local pin-in-rings mark, drawn in --text with a --secondary
   middle ring, so it stays on the §5 palette. Height follows the viewBox ratio. */
.brand__mark { width: 42px; flex: 0 0 auto; display: block; }
.brand__mark img { width: 100%; height: auto; display: block; }
.brand__name { font-family: var(--font-serif); font-size: 1.15rem; letter-spacing: -.01em; }
.site-footer {
  border-top: 1px solid var(--border); padding: 28px 0; margin-top: 48px;
  color: var(--text-muted); font-size: .95rem;
}
.site-footer a { color: var(--text-muted); }

/* --- Booking hero ---------------------------------------------------------- */
.hero { padding: 40px 0 8px; }
.hero p.lead { color: var(--text-muted); max-width: 54ch; margin-top: 10px; font-size: 1.1rem; }

/* --- Booking layout -------------------------------------------------------- */
.booking { padding: 24px 0 8px; }
.booking-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
.step {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.step[hidden] { display: none; }
.step__title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.step__num {
  font-family: var(--font-serif); color: var(--text-muted);
  font-size: .95rem; font-weight: 600;
}

/* --- Calendar (§5: availability dot = secondary) --------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-title { font-family: var(--font-serif); font-size: 1.15rem; }
.cal-nav { display: flex; gap: 8px; }
.cal-nav button {
  width: 40px; height: 40px; border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); cursor: pointer; color: var(--text);
  font-size: 1.1rem; line-height: 1; display: grid; place-items: center;
}
.cal-nav button:hover:not(:disabled) { background: var(--surface-alt); }
.cal-nav button:disabled { opacity: .4; cursor: not-allowed; }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-dow span { text-align: center; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; min-height: 44px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius); color: var(--text);
  font: inherit; font-size: .98rem; cursor: pointer;
  display: grid; place-items: center;
}
.cal-cell.is-empty-cell { border-color: transparent; background: transparent; cursor: default; }
.cal-cell.is-available:hover { background: var(--surface-alt); }
.cal-cell.is-unavailable {          /* day with zero slots — visible, disabled */
  background: var(--surface-alt); color: var(--text-muted);
  border-color: transparent; cursor: not-allowed;
}
.cal-cell.is-past { background: var(--surface-alt); color: var(--text-muted); border-color: transparent; cursor: not-allowed; }
.cal-cell.is-selected { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.cal-cell .dot {
  position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--secondary);
}
.cal-cell.is-selected .dot { background: var(--surface); }

/* --- Timezone selector ----------------------------------------------------- */
.tz-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.tz-row label { color: var(--text-muted); font-size: .95rem; }
.tz-select, .field input, .field select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 11px 12px; width: 100%;
}
.tz-select { width: auto; min-width: 220px; }

/* --- Slot list (§5 slot states) -------------------------------------------- */
.slot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.slot {
  font: inherit; padding: 13px 10px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; min-height: 48px; text-align: center;
}
.slot:hover { background: var(--surface-alt); }
.slot.is-selected { background: var(--accent); color: var(--surface); border-color: var(--accent); }
.slot-empty { color: var(--text-muted); padding: 8px 0; }

/* --- Form (§5: inline error = text + border left-rule) --------------------- */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field label { font-weight: 600; font-size: .96rem; }
.field .hint { color: var(--text-muted); font-size: .9rem; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field.is-invalid {
  border-left: 3px solid var(--border); padding-left: 12px; margin-left: -15px;
}
.field.is-invalid input { border-color: var(--text-muted); }
.error-msg { color: var(--text); font-size: .9rem; }
.error-msg::before { content: "— "; color: var(--text-muted); }
.form__actions { margin-top: 6px; }

/* --- Notices / states ------------------------------------------------------ */
.panel-notice {
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; color: var(--text);
}
.panel-notice h3 { margin-bottom: 6px; }
.panel-notice p { color: var(--text-muted); }
.inline-msg {                        /* §5: error text = --text with a --border left rule */
  border-left: 3px solid var(--border); padding: 8px 0 8px 12px;
  margin-bottom: 12px; color: var(--text); font-size: .96rem;
}
.inline-msg[hidden] { display: none; }

/* --- Skeleton -------------------------------------------------------------- */
.skeleton { display: grid; gap: 8px; }
.skeleton .sk {
  height: 46px; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 37%, var(--surface-alt) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease-in-out infinite;
}
.skeleton .sk--grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; height: auto; background: none; animation: none; }
.skeleton .sk--grid > span {
  aspect-ratio: 1/1; border-radius: var(--radius);
  background: linear-gradient(90deg, var(--surface-alt) 25%, var(--border) 37%, var(--surface-alt) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease-in-out infinite;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .sk, .skeleton .sk--grid > span, .spinner { animation: none !important; } }

/* --- Spinner --------------------------------------------------------------- */
.spinner {
  display: inline-block; border: 2px solid color-mix(in srgb, var(--surface) 55%, transparent);
  border-top-color: var(--surface); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Confirmation ---------------------------------------------------------- */
.confirmation { text-align: left; }
.confirmation .check {
  width: 44px; height: 44px; border-radius: 50%; background: var(--secondary);
  color: var(--surface); display: grid; place-items: center; font-size: 1.4rem; margin-bottom: 14px;
}
.confirm-detail { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 16px 0; }
.confirm-detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
.confirm-detail dt { color: var(--text-muted); }
.confirm-detail dd { font-weight: 600; }
.cancel-note { color: var(--text-muted); font-size: .95rem; }
.cancel-note a { color: var(--text-muted); }

/* --- Admin ----------------------------------------------------------------- */
.admin-wrap { padding: 40px 0; }
.admin-login {
  max-width: 380px; margin: 8vh auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 28px;
}
.admin-login h1 { font-size: 1.5rem; margin-bottom: 6px; }
.admin-login p { color: var(--text-muted); margin-bottom: 18px; }
.admin-login .field { margin-bottom: 16px; }

.health-banner {                     /* alert bar — §5 has no red token, so use --text */
  background: var(--text); color: var(--surface);
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 18px; font-weight: 600;
}
.health-banner[hidden] { display: none; }

.admin-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.admin-toolbar .search { flex: 1 1 220px; }
.admin-toolbar .search input { width: 100%; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg button {
  font: inherit; padding: 9px 14px; background: var(--surface); color: var(--text);
  border: 0; border-right: 1px solid var(--border); cursor: pointer;
}
.seg button:last-child { border-right: 0; }
.seg button.is-active { background: var(--text); color: var(--surface); }  /* active tab — not a CTA */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.bookings { width: 100%; border-collapse: collapse; font-size: .95rem; min-width: 760px; }
table.bookings th, table.bookings td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.bookings th { background: var(--surface-alt); font-weight: 600; color: var(--text); position: sticky; top: 0; }
table.bookings tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; border: 1px solid var(--border); color: var(--text-muted); }
.badge--confirmed { border-color: var(--secondary); color: var(--text); }
.badge--cancelled { background: var(--surface-alt); }
.admin-empty, .admin-loading { padding: 28px; text-align: center; color: var(--text-muted); }
.admin-note { color: var(--text-muted); font-size: .9rem; margin-top: 10px; }

/* --- Responsive ------------------------------------------------------------ */
@media (min-width: 720px) {
  .booking-grid { grid-template-columns: 1.1fr 1fr; align-items: start; }
  .step--details, .step--confirm, .step--notice { grid-column: 1 / -1; }
}
@media (max-width: 420px) {
  .container { padding: 0 14px; }
  .step { padding: 14px; }
  /* 7 columns + gaps + padding must fit 375px with no horizontal scroll.
     aspect-ratio:1/1 + min-height sets the cell's effective min-width, so trim both. */
  .cal-grid, .cal-dow { gap: 5px; }
  .cal-cell { min-height: 40px; font-size: .92rem; }
  .cal-dow span { font-size: .72rem; }
  .slot-list { grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); }
}
