/* Inputs and selection controls — DESIGN.md §5.2–5.3. Interactive borders use --line-input (≥3:1). */

.input {
  width: 100%; min-height: var(--tap); padding: 0 var(--s-4);
  background: var(--surface); border: 1.5px solid var(--line-input); border-radius: var(--r-1);
  font-size: max(16px, var(--step-0)); line-height: 1.3;
  transition: border-color var(--dur-fast) var(--ease-hover), box-shadow var(--dur-fast) var(--ease-hover);
}
.input::placeholder { color: var(--ink-3); opacity: 1; }
@media (hover: hover) and (pointer: fine) { .input:hover { border-color: var(--ink-2); } }
.input:focus-visible, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--error); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px var(--error-wash); }
textarea.input { min-height: 96px; padding-block: var(--s-3); resize: vertical; }
.input[type="date"] { appearance: none; -webkit-appearance: none; display: block; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 44px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink) 50%), linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; }

.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 44px; }
.search .input::-webkit-search-cancel-button { cursor: pointer; }

.field { display: grid; gap: 6px; }
.field > label:not(.check), .legend { font-weight: 600; font-size: var(--step--1); color: var(--ink); }
.hint { font-size: var(--step--1); color: var(--ink-3); }
.opt { font-weight: 400; color: var(--ink-3); }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--s-2); }

.err { font-size: var(--step--1); color: var(--error); font-weight: 500; }
.err:empty { display: none; }
/* An error line that has cleared keeps its height until the step changes (booking_controller),
   so nothing jumps under the thumb on the way to the next field. */
.err[data-reserved]:empty { display: block; min-height: 1.4em; }
.err:not(:empty) { animation: err-in var(--dur-fast) var(--ease-out); }
@keyframes err-in { from { opacity: 0; transform: translateY(-3px); } }

/* Horizontal scroller with preserved edge padding (chips, letters) */
.scroller { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1); padding-inline: var(--gutter);
  scroll-padding-inline: var(--gutter); scroll-snap-type: x proximity; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; flex: none; }

/* Filter chip: rectangular, never a pill */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border: 1.5px solid var(--line-input); border-radius: var(--r-1); background: transparent;
  font-weight: 500; font-size: var(--step--1); color: var(--ink-2); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-hover), border-color var(--dur-fast) var(--ease-hover), color var(--dur-fast) var(--ease-hover), box-shadow var(--dur-fast) var(--ease-hover), transform var(--dur-press) var(--ease-out);
}
.chip:active { transform: scale(0.96); }
.chip[aria-pressed="true"], .chip[aria-current="page"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-press); box-shadow: inset 0 0 0 0.5px var(--accent); }
.chip__count { font: 500 0.75rem/1 var(--font-mono); opacity: .75; }
@media (hover: hover) and (pointer: fine) {
  .chip:hover { border-color: var(--ink); color: var(--ink); }
  .chip[aria-pressed="true"]:hover, .chip[aria-current="page"]:hover { color: var(--accent-press); border-color: var(--accent); }
}

.letters { display: flex; gap: 2px; }
.letter {
  min-width: 36px; height: 40px; padding: 0; border: 0; background: transparent; border-radius: var(--r-1);
  font: 600 var(--step-0)/1 var(--font-display); font-stretch: 80%; color: var(--ink); cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-hover), transform var(--dur-press) var(--ease-out);
}
.letter--all { padding-inline: var(--s-3); font-family: var(--font-body); font-size: var(--step--1); font-weight: 600; }
.letter:active { transform: scale(0.94); }
.letter[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.letter:disabled { color: var(--line); cursor: default; }
@media (hover: hover) and (pointer: fine) { .letter:not(:disabled):not([aria-pressed="true"]):hover { background: var(--paper-sunk); } }
@media (max-width: 899.98px) {
  .letters { gap: 4px; }
  .letter { min-width: 44px; height: 44px; } /* a scroller on phones — room for full-size targets */
}

/* Option tiles (date quick-picks): real radio under a styled span */
.picks { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.pick { position: relative; display: block; }
.pick--wide { grid-column: 1 / -1; }
.pick input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.pick span { display: grid; gap: 2px; align-content: center; min-height: 56px; padding: 10px 12px; border: 1.5px solid var(--line-input); border-radius: var(--r-1);
  font-weight: 600; font-size: var(--step--1); line-height: 1.2; background: var(--surface);
  transition: border-color var(--dur-fast) var(--ease-hover), background-color var(--dur-fast) var(--ease-hover), box-shadow var(--dur-fast) var(--ease-hover), transform var(--dur-press) var(--ease-out); }
.pick--wide span { min-height: 48px; }
.pick small { font: 500 0.6875rem/1.2 var(--font-mono); color: var(--ink-3); text-transform: uppercase; }
.pick small:empty { display: none; }
.pick input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.pick input:checked + span small { color: var(--accent-press); }
.pick input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.pick:active span { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) { .pick:hover input:not(:checked) + span { border-color: var(--ink-3); } }
[aria-invalid="true"] .pick span { border-color: var(--error); }

/* Height reveal (the single allowed layout animation: grid-template-rows 0fr → 1fr) */
.reveal { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--dur-base) var(--ease-out); }
/* Spacing lives inside the clipped wrapper and never toggles, so closing doesn't jump 8 px first. */
.reveal > div { overflow: hidden; min-height: 0; padding-inline: 3px; } /* 3 px keeps the focus ring visible */
.reveal > div > :first-child { margin-top: var(--s-2); }
.reveal > div > :last-child { margin-bottom: 3px; }
.reveal.is-open { grid-template-rows: 1fr; }
.no-js-open { grid-template-rows: 1fr; }

/* Segmented control: radios + sliding thumb (Stimulus sets --i) */
.segmented { position: relative; display: grid; grid-template-columns: repeat(var(--n, 3), minmax(0, 1fr));
  background: var(--paper-sunk); border-radius: var(--r-1); padding: 3px; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.segmented label { position: relative; z-index: 1; display: grid; place-items: center; align-content: center; gap: 1px; min-height: 48px; padding: 4px 6px;
  font-weight: 600; font-size: var(--step--1); text-align: center; cursor: pointer; border-radius: 3px; line-height: 1.15;
  transition: color var(--dur-fast) var(--ease-hover), background-color var(--dur-fast) var(--ease-hover); color: var(--ink-2); }
.segmented label small { font: 500 0.6875rem/1 var(--font-mono); color: var(--ink-3); }
/* Selected = the same language as the date tiles: soft blue with a blue rule (was 1.2:1). */
.segmented input:checked + label, .segmented input:checked + label small { color: var(--accent-press); }
.segmented input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: -2px; }
.segmented__thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / var(--n, 3));
  background: var(--accent-soft); border-radius: 3px; box-shadow: inset 0 0 0 1.5px var(--accent);
  transform: translateX(calc(var(--i, 0) * 100%)); transition: transform var(--dur-base) var(--ease-out); }
.segmented:not([data-has-value]) .segmented__thumb { opacity: 0; transition: none; }
/* Without JS (no thumb positioning) the checked label itself gets the surface */
.segmented:not([data-enhanced]) .segmented__thumb { display: none; }
.segmented:not([data-enhanced]) input:checked + label { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
[aria-invalid="true"] .segmented, .segmented[aria-invalid="true"] { box-shadow: inset 0 0 0 1.5px var(--error); }
.segmented[data-n="4"] { --n: 4; }
.segmented[data-n="5"] { --n: 5; }
.segmented[data-n="6"] { --n: 6; }
.segmented[data-n="2"] { --n: 2; }

/* Custom checkbox, 24 px */
.check { display: grid; grid-template-columns: 24px 1fr; gap: var(--s-3); align-items: start; font-size: var(--step--1); color: var(--ink-2); line-height: 1.45; cursor: pointer; }
.check input { appearance: none; -webkit-appearance: none; width: 24px; height: 24px; margin: 0; border: 1.5px solid var(--ink-3); border-radius: 3px; background: var(--surface);
  display: grid; place-items: center; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-hover), border-color var(--dur-fast) var(--ease-hover); }
.check input::after { content: ""; width: 12px; height: 7px; border: 2.5px solid var(--accent-ink); border-top: 0; border-right: 0;
  transform: rotate(-45deg) translate(1px, -1px) scale(0.6); opacity: 0; transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-fast) var(--ease-out); }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after { opacity: 1; transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.check input[aria-invalid="true"] { border-color: var(--error); }
.check a { color: var(--ink); text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .segmented__thumb, .pick span { transition-property: opacity, background-color, border-color, color !important; }
  .pick:active span { transform: none; }
  .err:not(:empty) { animation-name: fade-only; }
}
