/* Shared interface pieces for every surface. Loaded after tokens.css and
   before the surface's own stylesheet, so a surface can still override.

   Button semantics (one primary per screen):
     .btn-primary    the main action on the screen (brand red)
     .btn-secondary  a supporting action (water blue)
     .btn-danger     delete, deny, reject, cancel a booking, deactivate
     .btn-quiet      an outlined neutral action
     .btn-link       an inline text action (readable on light surfaces;
                     the header variants recolour it where needed)
   Every button is at least the touch token tall and shows a disabled state. */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--hc-touch);
  padding: 10px 16px;
  border-radius: var(--hc-radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn-primary { background: var(--hc-red); color: var(--hc-red-ink); }
.btn-primary:hover { background: var(--hc-red-deep); }
.btn-secondary { background: var(--hc-water); color: var(--hc-water-ink); }
.btn-secondary:hover { filter: brightness(0.92); }
.btn-danger { background: var(--hc-closed); color: var(--hc-closed-ink); }
.btn-danger:hover { filter: brightness(0.9); }
.btn-quiet {
  background: var(--hc-surface);
  color: var(--hc-ink);
  border-color: var(--hc-line);
}
.btn-quiet:hover { background: var(--hc-bg); }
.btn-link {
  background: none;
  border: none;
  color: var(--hc-water);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 10px 6px;
  min-height: var(--hc-touch);
  font-weight: 600;
}
.btn-link:hover { color: var(--hc-ink); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 0.9rem; }
/* Small buttons keep a 44 px target where fingers do the tapping. */
@media (pointer: coarse), (max-width: 900px) { .btn-sm { min-height: 44px; } }

.btn:disabled,
.btn[aria-disabled="true"],
.btn[aria-busy="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}
.btn[aria-busy="true"] { cursor: progress; }

.btn:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible,
.file-btn:focus-within {
  outline: 3px solid var(--hc-water);
  outline-offset: 2px;
}

/* Form controls: every text-like input gets the same height and padding,
   including types the surfaces used to leave at browser defaults. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
select,
textarea {
  font: inherit;
  min-height: var(--hc-touch);
  padding: 10px 12px;
  border: 1px solid var(--hc-line);
  border-radius: var(--hc-radius-sm);
  background: var(--hc-surface);
  color: var(--hc-ink);
  box-sizing: border-box;
  max-width: 100%;
}
textarea { min-height: 88px; resize: vertical; }
input[type="checkbox"], input[type="radio"] {
  width: 22px;
  height: 22px;
  margin: 0 8px 0 0;
  accent-color: var(--hc-water);
  vertical-align: middle;
  flex: none;
}
input[type="file"] { font: inherit; }
/* A file input dressed as a button: wrap it in <label class="btn btn-secondary file-btn">. */
.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}

/* A checkbox or radio stays 22 px, but the label row around it is the tap
   target: at least the touch token tall, and the whole row toggles it. */
.check-row,
.pref-row,
label:has(> input[type="checkbox"]),
label:has(> input[type="radio"]) {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--hc-touch);
  cursor: pointer;
}

/* Stepper: − / value / + for a small count (guests, packs, headcount).
   HC.stepper(input) builds it around an existing input. */
.hc-stepper { display: inline-flex; align-items: stretch; gap: 6px; max-width: 100%; }
.hc-stepper .hc-step {
  width: var(--hc-touch);
  min-height: var(--hc-touch);
  padding: 0;
  margin: 0;
  flex: none;
  font-size: 1.4rem;
  line-height: 1;
}
.hc-stepper input {
  width: 5rem;
  flex: 0 1 5rem;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.hc-stepper input::-webkit-outer-spin-button,
.hc-stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.hc-stepper input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Segmented control: 2 to 4 choices as one row of buttons, role="radiogroup"
   with role="radio" buttons (aria-checked carries the state). */
.hc-segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: none;
}
.hc-segment {
  flex: 1 1 auto;
  min-height: var(--hc-touch);
  padding: 8px 14px;
  font: inherit;
  font-weight: 700;
  background: var(--hc-surface);
  color: var(--hc-ink);
  border: 2px solid var(--hc-line);
  border-radius: var(--hc-radius-sm);
  cursor: pointer;
  text-align: center;
}
.hc-segment:hover { border-color: var(--hc-water); }
.hc-segment[aria-checked="true"] {
  border-color: var(--hc-water);
  background: var(--hc-water-soft);
  color: var(--hc-ink);
}
.hc-segment[aria-checked="true"]::before { content: "\2713\FE0E  "; }

/* Inline status next to a control. */
.hc-msg {
  margin: 8px 0 0;
  font-weight: 600;
  line-height: 1.35;
}
.hc-msg[hidden] { display: none; }
.hc-msg.is-ok { color: var(--hc-ok-ink); }
.hc-msg.is-error { color: var(--hc-danger-text); }
.hc-msg.is-error::before { content: "\26A0\FE0E  "; }
.hc-msg.is-info { color: var(--hc-muted); }
/* Errors always carry an icon as well as the colour. */
.field-error { color: var(--hc-danger-text); font-size: 0.9rem; font-weight: 600; margin: 4px 0 0; }
.field-error:not(:empty)::before { content: "\26A0\FE0E  "; }
.is-invalid { border-color: var(--hc-danger-text) !important; box-shadow: 0 0 0 2px var(--hc-red-soft); }

/* Toast */
.hc-toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 20px);
  max-width: min(92vw, 480px);
  padding: 12px 16px;
  border-radius: var(--hc-radius);
  background: var(--hc-inverse-bg);
  color: var(--hc-inverse-ink);
  font-weight: 600;
  box-shadow: 0 6px 24px rgba(21, 25, 30, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 1000;
}
.hc-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.hc-toast.is-ok { background: var(--hc-ok-ink); }
.hc-toast.is-error { background: var(--hc-closed); }

/* Dialog */
.hc-dialog {
  border: none;
  border-radius: var(--hc-radius);
  padding: 20px;
  max-width: min(92vw, 440px);
  box-shadow: 0 12px 40px rgba(21, 25, 30, 0.3);
  background: var(--hc-surface);
  color: var(--hc-ink);
}
.hc-dialog::backdrop { background: rgba(21, 25, 30, 0.45); }
.hc-dialog h2 { margin: 0 0 8px; font-size: 1.15rem; }
.hc-dialog p { margin: 0 0 8px; line-height: 1.4; }
.hc-dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* Status chips (household status, booking status, report status). */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  background: var(--hc-bg);
  color: var(--hc-ink);
  border: 1px solid var(--hc-line);
}
.chip-ok { background: var(--hc-ok-soft); color: var(--hc-ok-ink); border-color: transparent; }
.chip-warn { background: var(--hc-warn-soft); color: var(--hc-warn-ink); border-color: transparent; }
.chip-bad { background: var(--hc-red-soft); color: var(--hc-danger-text); border-color: transparent; }
.chip-info { background: var(--hc-water-soft); color: var(--hc-water); border-color: transparent; }

/* Visually hidden (for an h1 or a label that must exist but not show). */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* Anchored sections should clear a sticky header. */
[id] { scroll-margin-top: var(--hc-sticky-offset, 84px); }

@media (prefers-reduced-motion: reduce) {
  .btn, .hc-toast { transition: none; }
}
