/* Chips, marks, pills, segments, toasts, focus. Values from §5 and §9. */

/* ---- Focus. Visible on everything, in both themes. ---- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--p-brand);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* ---- Chip (§5) ---- */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.2px;
  padding: 3px 8px; border-radius: 6px; white-space: nowrap;
}
.chip--ok      { color: var(--p-ok);    background: var(--p-ok-soft); }
.chip--warn    { color: var(--p-warn);  background: var(--p-warn-soft); }
.chip--risk    { color: var(--p-risk);  background: var(--p-risk-soft); }
/* --p-brand-ink, not --p-brand. §5 names --p-brand, but that is the accent's
   FILL role: on its own tint it measures 4.06:1 in light, and chip text is
   10.5px. --p-brand-ink (--accent-fg) is the system's accent-as-text role and
   clears 4.5. Divergence recorded in docs/DESIGN-CONFLICTS.md → C8. */
.chip--brand   { color: var(--p-brand-ink); background: var(--p-brand-soft); }
.chip--audit   { color: var(--p-audit); background: var(--p-audit-soft); }
.chip--neutral { color: var(--p-ink-2); background: var(--p-surface-2); }

/* ---- Mark (§5) ---- */
.mark {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; letter-spacing: 0.3px;
}
/* Same reason as .chip--brand: initials are 11px, not large text. */
.mark--brand   { background: var(--p-brand-soft); color: var(--p-brand-ink); }
.mark--audit   { background: var(--p-audit-soft); color: var(--p-audit); }
.mark--neutral { background: var(--p-surface-2);  color: var(--p-ink-2); }

/* ---- Pill (§5) ---- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--p-surface); border: 1px solid var(--p-line);
  border-radius: var(--radius-pill); padding: 7px 14px;
  font-size: 12px; font-weight: 500; color: var(--p-ink-2); cursor: pointer;
}
.pill.is-selected {
  background: var(--p-ink); border-color: var(--p-ink);
  color: var(--p-surface); font-weight: 600;
}
.pill__count { font-size: 11px; opacity: 0.75; }

/* ---- Segment ---- */
.segment {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--p-surface-2); border: 1px solid var(--p-line);
  border-radius: var(--radius-pill);
}
.segment__btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-pill); padding: 5px 11px;
  font-size: 12px; font-weight: 500; color: var(--p-ink-3); cursor: pointer;
}
.segment__btn.is-selected {
  background: var(--p-surface); border-color: var(--p-line-2);
  box-shadow: var(--shadow-xs); color: var(--p-ink); font-weight: 600;
}

/* ---- Icon button (36px circle) ---- */
.icon-btn {
  position: relative; flex: none;
  width: 36px; height: 36px; border-radius: var(--radius-pill);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--p-surface-2); border: 1px solid var(--p-line);
  color: var(--p-ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--p-ink); }
.icon-btn__badge {
  position: absolute; top: -3px; inset-inline-end: -3px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-pill);
  background: var(--p-risk); color: var(--p-bg);
  font-size: 9.5px; font-weight: 700; line-height: 16px; text-align: center;
}

/* ---- Primary button ---- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--p-brand); border: none; border-radius: var(--radius-pill);
  padding: 10px 16px; font-size: 13px; font-weight: 600;
  /* Reference hard-codes #fff here; --p-on-brand is the token and it passes
     AA on --p-brand where white does not. See docs/DESIGN-CONFLICTS.md. */
  color: var(--p-on-brand); cursor: pointer;
}

/* ---- Toast (§8.7) ---- */
.toast-host {
  position: fixed; inset-inline: 0; bottom: 24px;
  display: flex; justify-content: center; pointer-events: none; z-index: 60;
}
.toast {
  pointer-events: auto;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface-inverse); color: var(--text-inverse);
  border-radius: var(--radius-pill); padding: 10px 12px 10px 14px;
  box-shadow: var(--shadow-lg); font-size: 12.5px;
}
.toast__icon { color: var(--p-ok); }
.toast__dismiss {
  background: transparent; border: none; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text-inverse);
  opacity: 0.7; padding: 2px 6px;
}
.toast__dismiss:hover { opacity: 1; }

/* ---- Disabled means disabled (§8.6) ---- */
.is-disabled,
[aria-disabled='true'] {
  background: var(--p-line-2); color: var(--p-ink-3); cursor: not-allowed;
}

/* ---- Confirmation, for acts whose size is the risk ---- */
.confirm__host { position: fixed; inset: 0; z-index: 95; }
.confirm__scrim {
  position: absolute; inset: 0; background: var(--p-scrim);
  border: none; padding: 0; cursor: pointer;
}
.confirm {
  position: absolute; inset-inline: 0; top: 50%;
  transform: translateY(-50%);
  width: min(420px, calc(100% - 32px)); margin: 0 auto;
  background: var(--p-surface); border: 1px solid var(--p-line);
  border-radius: var(--radius-xl); padding: 20px;
  box-shadow: var(--shadow-xl);
}
.confirm__title { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.confirm__body { font-size: 12.5px; line-height: 1.55; color: var(--p-ink-2); margin: 0 0 18px; }
.confirm__actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.confirm__cancel {
  background: var(--p-surface-2); border: 1px solid var(--p-line);
  border-radius: var(--radius-pill); padding: 9px 14px;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
}

.toast__msg { flex: 1; min-width: 0; }

.confirm__field {
  width: 100%; background: var(--p-surface-2); border: 1px solid var(--p-line);
  border-radius: var(--radius-md); padding: 9px 11px;
  font-size: 12.5px; resize: vertical; margin-bottom: 8px;
}
.confirm__hint { font-size: 10.5px; color: var(--p-ink-3); margin: 0 0 16px; }

.request-form { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto; }
.request-form__field, .finding__field { display: grid; gap: 6px; color: var(--p-ink-2); font-size: 11.5px; }
.request-form__field input, .request-form__field select,
.finding__field input, .finding__field select, .finding__field textarea {
  width: 100%; border: 1px solid var(--p-line); border-radius: 8px;
  background: var(--p-surface-2); color: var(--p-ink-1); padding: 9px 10px;
  font: inherit; box-sizing: border-box;
}
.request-form__modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 14px; border: 0; padding: 0; margin: 14px 0; }
.request-form__modules legend { color: var(--p-ink-2); font-size: 11.5px; margin-bottom: 7px; }
.request-form__check { display: flex; align-items: center; gap: 7px; color: var(--p-ink-2); font-size: 11.5px; }
.request-form__dates, .finding__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }

/* MOBILE NUMBER *or* BUSINESS ID — pick one, then answer one question.
 *
 * A single box asked for either and advertised both in its placeholder, so the
 * reader had to decide what shape was wanted and whether to type the country
 * code. The mode buttons make that choice explicit, and the country becomes a
 * select so `+973` is never typed and never forgotten. */
.request-form__modes { display: flex; gap: 6px; margin-bottom: 6px; }
.request-form__mode {
  border: 1px solid var(--p-line); border-radius: 999px;
  background: var(--p-surface-2); color: var(--p-ink-2);
  padding: 6px 12px; font: inherit; font-size: 11.5px; cursor: pointer;
}
.request-form__mode.is-on {
  background: var(--p-brand-soft); border-color: var(--p-brand); color: var(--p-ink-1);
  font-weight: 600;
}
/* `auto 1fr` — the dial code takes only the width its own text needs, so the
   number keeps the rest. The flag makes the country recognisable at a glance
   without reading. */
.request-form__phone { display: grid; grid-template-columns: auto 1fr; gap: 6px; }
.request-form__field .request-form__dial,
.request-form__field .request-form__phone-number,
.request-form__field .request-form__id {
  min-height: 42px; font-size: 13.5px;
}
.request-form__field .request-form__dial { cursor: pointer; padding: 10px 8px; }
/* Numerals in the ledger face: a phone number is read back digit by digit. */
.request-form__field .request-form__phone-number { letter-spacing: 0.04em; }

/* DAY · MONTH · YEAR, three selects instead of one date input.
 *
 * `1fr 1.4fr 1fr` gives the month the extra room its NAME needs — "September"
 * and "سبتمبر" are both wider than two digits, and a month shown as a word is
 * the reason nobody has to remember whether 07 means July or the 7th.
 *
 * Each control is 42px tall so it is a comfortable target, and the year is a
 * plain list: the native control was reported twice as hard to catch on the
 * year specifically, and a dropdown replaces landing-then-spinning with one
 * gesture. */
.request-form__date-parts {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 6px;
}
.request-form__field .request-form__date-part {
  min-height: 42px;
  padding: 10px 8px;
  font-size: 13.5px;
  cursor: pointer;
}
/* Numerals in the ledger face, as everywhere a figure is read. The month keeps
   the text face — it is a word, not a number. */
.request-form__date-parts > .request-form__date-part:first-child,
.request-form__date-parts > .request-form__date-part:last-child {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.request-form__field .request-form__date-part:focus-visible {
  outline: 2px solid var(--p-brand);
  outline-offset: 1px;
}

/* DATE FIELDS WERE 11.5px, WHICH IS WHY THEY WERE HARD TO HIT.
 *
 * The rule above sets `font: inherit` on inputs, and `.request-form__field`
 * sets 11.5px for its LABEL — so the day, month and year segments inherited
 * label type. Each segment was roughly 14px wide, and hitting `mm` between
 * `dd` and `yyyy` meant aiming at something smaller than a fingertip.
 *
 * Numerals get the ledger face here for the same reason amounts do: tabular
 * figures do not change width as the digits change, so the segments stop
 * shifting under the cursor as you type.
 *
 * `color-scheme` is the load-bearing line. Without it the browser draws the
 * native picker — the popup calendar, the segment highlight, the indicator
 * glyph — in its LIGHT palette over this dark surface, which is why the
 * calendar looked washed out and the selected day was hard to see. Naming both
 * schemes lets it follow the theme instead of being pinned to either. */
.request-form__field input[type="date"],
.finding__field input[type="date"] {
  color-scheme: light dark;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  letter-spacing: 0.02em;
  min-height: 42px;
  padding: 10px 12px;
  cursor: pointer;
}
/* A 24px target instead of the default ~12px, and a pointer so it reads as a
   button. Clicking it opens the real calendar, which is the easy path — the
   segments stay typable for anyone who prefers the keyboard. */
.request-form__field input[type="date"]::-webkit-calendar-picker-indicator,
.finding__field input[type="date"]::-webkit-calendar-picker-indicator {
  width: 24px;
  height: 24px;
  padding: 2px;
  margin-inline-start: 6px;
  cursor: pointer;
  opacity: 0.75;
  border-radius: 6px;
}
.request-form__field input[type="date"]::-webkit-calendar-picker-indicator:hover,
.finding__field input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
  background: var(--p-surface-3, var(--p-line));
}
.request-form__field input[type="date"]:focus-visible,
.finding__field input[type="date"]:focus-visible {
  outline: 2px solid var(--p-brand);
  outline-offset: 1px;
}
.request-form__error, .finding__error { color: var(--p-danger); min-height: 18px; font-size: 11.5px; }

.finding__page-head { margin-bottom: 18px; }
.finding__page-title { margin: 0; font-size: 24px; }
.finding__lead { color: var(--p-ink-2); margin: 6px 0 0; }
.finding__form { display: grid; gap: 12px; margin-bottom: 18px; }
.finding__actions { display: flex; justify-content: flex-end; }
.finding__list { display: grid; gap: 10px; }
.finding__row { border: 1px solid var(--p-line); border-radius: 10px; background: var(--p-surface-1); padding: 14px; }
.finding__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.finding__title { margin: 0; font-size: 14px; }
.finding__meta { margin: 7px 0 0; color: var(--p-ink-3); font-size: 11.5px; }

@media (max-width: 620px) {
  .request-form__dates, .finding__grid { grid-template-columns: 1fr; }
}
.header__locale { font-size: 11px; font-weight: 600; }
