/* v3 form field, minimal (reference §4): label above, surface input with a
   3:1 control edge, error under the field. Used by the confirm dialog in
   phase 3; phase 4 builds the full form-field component on it. */

.lg-field { display: flex; flex-direction: column; gap: var(--space-1); }
.lg-field__label { font-size: var(--size-label); line-height: var(--leading-label); font-weight: 500; }
.lg-field__input {
  width: 100%;
  min-height: var(--control-height);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: var(--size-body);
}
textarea.lg-field__input { min-height: 5rem; resize: vertical; }
/* Native date / time boxes (decision 288): Safari on iPhone centres the value
   and gives the box a fixed minimum width (it spilled out of a two-column
   row); left-aligned, shrinkable, same height as the other inputs. */
.lg-field__input:is([type="date"], [type="time"], [type="datetime-local"]) {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  min-width: 0;
  text-align: start;
  /* Chromium's date / time value box is 24px tall: 1px less padding keeps
     these at the one control height (2.5rem, decision 303), not 42px. */
  padding-block: calc(var(--space-2) - 1px);
}
.lg-field__input::-webkit-date-and-time-value { min-height: 1.5em; text-align: start; }
/* Native file box (kind="file"): the browser's own button inside our edge. */
.lg-field__input--file { padding: var(--space-1) var(--space-2); }
.lg-field__input--file::file-selector-button {
  margin-inline-end: var(--space-3);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.lg-field__input:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; }
.lg-field__input[aria-invalid="true"] { border-color: var(--danger); }
/* Small control for dense toolbars and the grid footer (1.875rem). */
.lg-field__input--sm {
  width: auto;
  min-height: var(--control-height-sm);
  padding: 0 var(--space-2);
  font-size: var(--size-label);
}
/* Native checkbox in the accent colour; the browser's own edge is ≥ 3:1. */
.lg-check {
  inline-size: 1rem;
  block-size: 1rem;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.lg-field__error { margin: 0; color: var(--danger); font-size: var(--size-caption); line-height: var(--leading-caption); font-weight: 500; }
.lg-field__error[hidden] { display: none; }

/* ---------- Full field (phase 4 step 5; reference §4, plan §11 #85–#89) ---------- */
fieldset.lg-field { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.lg-field > legend { padding: 0; margin-bottom: var(--space-1); }
.lg-field__opt { font-weight: 400; color: var(--text-muted); }
.lg-field__hint { margin: 0; color: var(--text-muted); font-size: var(--size-caption); line-height: var(--leading-caption); }
.lg-field__control { display: flex; flex-wrap: wrap; align-items: stretch; }
.lg-field__control > .lg-date-readout,
.lg-field__control > .lg-picker__list,
.lg-field__control > .lg-picker__note { flex-basis: 100%; }
.lg-field__control > .lg-field__input { flex: 1; min-width: 0; }
.lg-field__prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-right: 0;
  border-radius: var(--radius-control) 0 0 var(--radius-control);
  background: var(--neutral-tint);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--size-label);
}
.lg-field__control--prefix > .lg-field__input { border-top-left-radius: 0; border-bottom-left-radius: 0; }
/* A decorative icon inside the box at the start (lead_icon, decision 279). */
.lg-field__control--lead { position: relative; }
.lg-field__lead {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--space-3);
  display: flex;
  align-items: center;
  color: var(--text-muted);
  pointer-events: none;
}
.lg-field__control--lead > .lg-field__input { padding-inline-start: 2.5rem; }
.lg-field__input[aria-invalid="true"] { border-width: 2px; }
.lg-field__input::placeholder { color: var(--text-muted); }
/* Same select on every phone: our surface + a drawn chevron (WebKit otherwise
   paints its own grey box). The chevron is two borders, so it follows the theme. */
/* v2's global `[data-theme] select` rule (components/data_grid.css) paints every
   select with fixed colours and a faint edge; `select.` matches its weight and v3
   loads later, so these win until phase 7 deletes the v2 rule. */
select.lg-field__input { background-color: var(--surface); color: var(--text); border-color: var(--border-control); }
select.lg-field__input[aria-invalid="true"] { border-color: var(--danger); }
select.lg-field__input option { background-color: var(--raised); color: var(--text); }
.lg-field__select {
  appearance: none;
  padding-right: calc(var(--space-3) * 2 + 0.5rem);
  cursor: pointer;
}
.lg-field__control:has(> .lg-field__select:not([hidden])) { position: relative; }
.lg-field__control:has(> .lg-field__select:not([hidden]))::after {
  content: "";
  position: absolute;
  right: var(--space-4);
  top: 50%;
  width: 0.5rem;
  height: 0.5rem;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
/* Widths say how long the answer is (GOV.UK): a 6-digit code isn't a full-width box. */
.lg-field--w-xs .lg-field__control { max-width: 6rem; }
.lg-field--w-sm .lg-field__control { max-width: 10rem; }
.lg-field--w-md .lg-field__control { max-width: 20rem; }
.lg-field--w-lg .lg-field__control { max-width: 32rem; }
/* A code people copy from somewhere (two-step code): digits spaced apart so they
   can check them (plan §11 #100). Full width like the other inputs (decision 255). */
.lg-field__input--code { letter-spacing: 0.15em; }

/* Radios and checkboxes: the real control, a large label to tap (44px rows). */
.lg-choices__list { display: flex; flex-direction: column; gap: var(--space-1); }
.lg-choices--inline .lg-choices__list { flex-direction: row; flex-wrap: wrap; column-gap: var(--space-6); }
.lg-choice { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: var(--space-3); }
.lg-choice__input {
  inline-size: 1.25rem;
  block-size: 1.25rem;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}
.lg-choice__input:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; }
.lg-choice__label { display: flex; align-items: center; min-height: var(--control-height); cursor: pointer; }
.lg-choice__hint { grid-column: 2; margin: calc(var(--space-1) * -1) 0 var(--space-1); color: var(--text-muted); font-size: var(--size-caption); line-height: var(--leading-caption); }
.lg-choice--single { display: grid; }
.lg-choice--single .lg-field__error { grid-column: 2; }

/* Memorable date: Day / Month / Year boxes (GOV.UK date input). */
.lg-memorable__parts { display: flex; gap: var(--space-3); }
.lg-memorable__part { display: flex; flex-direction: column; gap: var(--space-1); }
.lg-memorable__part--day, .lg-memorable__part--month { width: 4rem; }
.lg-memorable__part--year { width: 5.5rem; }
.lg-memorable__label { font-size: var(--size-caption); color: var(--text-muted); }

/* Searchable picker (js/v3/picker.js). */
.lg-picker { position: relative; }
.lg-picker__list {
  position: absolute;
  inset: calc(100% - var(--space-1)) 0 auto 0;
  z-index: var(--layer-menu);
  max-height: 18rem;
  margin: 0;
  padding: var(--space-1);
  overflow-y: auto;
  list-style: none;
  border-radius: var(--radius-card);
  background: var(--raised);
  box-shadow: var(--shadow-menu);
  border: 1px solid var(--float-border);
}
.lg-picker__list[hidden], .lg-picker__note[hidden] { display: none; }
.lg-picker__option {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: var(--control-height);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.lg-picker__option:hover, .lg-picker__option[aria-selected="true"] { background: var(--primary-tint); color: var(--primary-ink); }
.lg-picker__option[data-current] { font-weight: 600; }
.lg-picker__sub { color: var(--text-muted); font-size: var(--size-caption); }
.lg-picker__option[aria-selected="true"] .lg-picker__sub { color: inherit; }
.lg-picker__note { margin: var(--space-1) 0 0; color: var(--text-muted); font-size: var(--size-caption); }

/* A form: one column; two short fields may share a row on wider screens (core §5). */
.lg-form { display: flex; flex-direction: column; gap: var(--space-5); max-width: 40rem; }
/* A form that IS the page (event page with section tabs): full width; its
   cards and fields keep their own widths. */
.lg-form--page { max-width: none; }
/* Fields stacked inside a card or a wizard step: the same spacing as a form. */
.lg-fields { display: flex; flex-direction: column; gap: var(--space-5); }
.lg-form__row { display: grid; gap: var(--space-5); }
@media (min-width: 40em) { .lg-form__row { grid-template-columns: 1fr 1fr; } }
.lg-form__actions { display: flex; gap: var(--space-2); padding-top: var(--space-2); }
.lg-form__saved {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-control);
  background: var(--success-tint);
  color: var(--text);
}

/* Error summary at the top of a form (role=alert, focused on arrival). */
.lg-error-summary {
  padding: var(--space-4);
  border: 2px solid var(--danger);
  border-radius: var(--radius-control);
  background: var(--danger-tint);
}
.lg-error-summary:focus-visible { outline: var(--focus-ring) solid var(--focus); outline-offset: 2px; }
.lg-error-summary__title { margin: 0 0 var(--space-2); font-size: var(--size-card-title); line-height: var(--leading-card-title); font-weight: 600; color: var(--text); }
.lg-error-summary__list { margin: 0; padding-left: var(--space-5); }
.lg-error-summary__list a { color: var(--danger); font-weight: 500; }

@media (max-width: 39.99em) {
  /* Phones (decision 288): 44px boxes, 16px text (no iOS zoom); short-width
     fields (dates, times) use the full width, only tiny numbers stay narrow. */
  .lg-field__input { min-height: var(--touch-target); font-size: 1rem; }
  .lg-field--w-sm .lg-field__control, .lg-field--w-md .lg-field__control,
  .lg-field--w-lg .lg-field__control { max-width: none; }
  .lg-field__input--sm { min-height: var(--touch-target); }
  .lg-check { inline-size: 1.25rem; block-size: 1.25rem; }
  .lg-choice__input { inline-size: 1.5rem; block-size: 1.5rem; }
  .lg-choice__label { min-height: var(--touch-target); }
  .lg-choices--inline .lg-choices__list { column-gap: var(--space-5); }
  .lg-field__prefix { font-size: 1rem; }
  .lg-picker__list { position: static; max-height: 50dvh; margin-top: var(--space-1); }
  .lg-picker__option { min-height: var(--touch-target); }
}
