/*
  08-forms.css — v41.1 modern form system + Holdings header

  Two jobs.

  1. Every data-entry screen in the app. All form styling previously lived in
     styles.css inside @layer legacy; because this file is unlayered it wins the
     cascade without !important, so restyling the generic patterns every modal
     already uses (.form-grid, .modal-form-grid, label, input, .form-actions)
     lifts every form at once rather than one dialog at a time.

  2. The Holdings header, where section headings sat at 1.32:1 against the dark
     deck — h3 inherited --ink because only h2 was ever given a light colour.
*/

/* ==========================================================
   Fields
   ========================================================== */
.modal .form-grid,
.modal .modal-form-grid { gap: var(--s3); align-items: start; }

.modal .form-grid > div,
.modal .modal-form-grid > div { display: grid; gap: 5px; min-width: 0; }

/* Field captions only. Scoped to labels sitting above a control inside a field
   wrapper — a bare <label> wrapping its own checkbox (.check-row and the older
   inline toggles) is sentence text, not a caption, and must not be uppercased. */
.modal .form-grid > div > label,
.modal .modal-form-grid > div > label,
.mform-grid > div > label {
  color: var(--muted);
  font-size: .69rem;
  font-weight: 900;
  letter-spacing: .07em;
  text-transform: uppercase;
  line-height: 1.3;
}

/* Legacy bare checkbox labels get the same tappable strip as .check-row. */
.modal .form-grid > label,
.modal .modal-form-grid > label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  background: var(--field, #f4e9cd);
  color: var(--ink);
  font-size: .85rem;
  font-weight: 750;
  cursor: pointer;
}
.modal .form-grid > label input[type="checkbox"],
.modal .modal-form-grid > label input[type="checkbox"] {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--lagoon);
}

.modal input:not([type="checkbox"]):not([type="radio"]),
.modal select,
.modal textarea {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  /* v41.15: background-COLOR, not the shorthand. The shorthand reset
     background-image, which would wipe the chevron 10-controls.css paints on
     every select. Surface comes from the shared --field token. */
  background-color: var(--field, #f4e9cd);
  color: var(--ink);
  font: inherit;
  font-size: .92rem;
  box-shadow: inset 0 1px 2px rgba(30, 20, 10, .07);
  transition: border-color .14s ease, box-shadow .14s ease;
  appearance: none;
}
.modal textarea { min-height: 96px; line-height: 1.5; resize: vertical; }

.modal input:not([type="checkbox"]):not([type="radio"]):hover,
.modal select:hover,
.modal textarea:hover { border-color: color-mix(in srgb, var(--brass) 55%, var(--line-strong)); }

.modal input:not([type="checkbox"]):not([type="radio"]):focus,
.modal select:focus,
.modal textarea:focus {
  outline: none;
  border-color: var(--lagoon);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--lagoon) 22%, transparent);
}
.modal input::placeholder,
.modal textarea::placeholder { color: var(--faint); }

/* v41.15: the select chevron moved to 10-controls.css, which draws a real
   SVG chevron for every select in the app rather than a two-triangle wedge
   for modals only. Nothing here should paint a select background-image. */

.modal .field-help,
.modal .row-sub {
  color: var(--muted);
  font-size: .74rem;
  line-height: 1.45;
}

/* Checkbox rows read as one tappable strip. */
.modal .check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-s);
  background: var(--field, #f4e9cd);
  color: var(--ink);
  font-size: .85rem;
  font-weight: 750;
  cursor: pointer;
}
.modal .check-row:hover { border-color: color-mix(in srgb, var(--brass) 55%, var(--line-strong)); }
.modal .check-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin: 0;
  accent-color: var(--lagoon);
}
.modal .check-row:has(input:checked) {
  border-color: color-mix(in srgb, var(--lagoon) 55%, var(--line));
  background: color-mix(in srgb, var(--lagoon) 8%, #fffaec);
}

/* ==========================================================
   Grouped form sections
   ========================================================== */
.mform { display: grid; gap: var(--s4); }
.mform-sect { display: grid; gap: var(--s2); }
.mform-sect > h4 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 900;
  letter-spacing: .09em;
  text-transform: uppercase;
}
.mform-sect > h4::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.mform-grid { display: grid; gap: var(--s3); grid-template-columns: 1fr; }
.mform-grid > div { display: grid; gap: 5px; min-width: 0; }
.mform-grid > .span-2 { grid-column: 1 / -1; }
@media (min-width: 560px) {
  .mform-grid { grid-template-columns: 1fr 1fr; }
}

/* A read-only derived value, shown where a field would sit. */
.mform-derived {
  display: grid;
  gap: 3px;
  padding: 10px 13px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-s);
  background: rgba(0, 0, 0, .04);
}
.mform-derived b { font-size: .87rem; }
.mform-derived span { color: var(--muted); font-size: .74rem; line-height: 1.4; }

/* ==========================================================
   Action bar
   ========================================================== */
.modal .form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
  margin-top: var(--s4);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
}
.modal .form-actions .button { min-height: 44px; }
.modal .form-actions .button.primary { flex: 1 1 auto; min-width: 140px; }
/* A destructive action is pushed away from the confirming one. */
.modal .form-actions .button.danger { margin-left: auto; }
@media (max-width: 480px) {
  .modal .form-actions .button.danger { margin-left: 0; width: 100%; }
}

/* ==========================================================
   Holdings header
   ========================================================== */
.hold-hero {
  display: grid;
  gap: var(--s3);
  margin: 0 0 var(--s4);
  padding: 16px 17px;
  border: 1px solid rgba(232, 192, 105, .26);
  border-radius: var(--r-l);
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(192, 138, 46, .22) 0%, transparent 62%),
    linear-gradient(160deg, rgba(255, 255, 255, .07), rgba(0, 0, 0, .14));
  box-shadow: var(--e2);
}
.hold-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s3);
}
.hold-hero-k { min-width: 0; display: grid; gap: 3px; }
.hold-eyebrow {
  color: var(--brass);
  font-size: .66rem;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.hold-hero h2 {
  margin: 0;
  color: #f6ead0;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2rem);
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1.1;
}
.hold-hero-sub {
  margin: 0;
  max-width: 46ch;
  color: #cdbb95;
  font-size: var(--t0);
  line-height: 1.5;
}
.hold-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.hold-stats > div {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid rgba(232, 192, 105, .2);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
}
.hold-stats b {
  color: var(--brass-bright);
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}
.hold-stats span {
  color: #c3b18d;
  font-size: .71rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* The contrast fix: any heading or hint sitting directly on the deck. */
.holding-section .section-title h3,
.holding-section > h3 { color: #f2e5c8; }
.holding-section .section-title .hint,
.screen-intro { color: #c3b18d; }

@media (max-width: 420px) {
  .hold-hero-top { flex-direction: column; }
  .hold-hero-top .button { width: 100%; }
  .hold-stats > div { flex: 1 1 auto; justify-content: center; }
}

/* ==========================================================
   Type-to-confirm deletion
   ========================================================== */
.cdel-warn {
  display: grid;
  gap: 4px;
  padding: 11px 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--line));
  border-radius: var(--r-s);
  background: var(--danger-bg);
}
.cdel-warn b { color: var(--danger); font-size: .87rem; }
.cdel-warn span { color: var(--ink-soft); font-size: .79rem; line-height: 1.45; }
.cdel-name {
  color: var(--ink);
  font-weight: 900;
  text-transform: none;
  letter-spacing: 0;
}
.modal #cdelInput { font-weight: 750; }
/* The name is shown in the label, never as a placeholder — a greyed-out copy of
   the name inside the field reads as already filled in and invites a paste. */
.modal #cdelInput::placeholder { font-weight: 500; color: var(--faint); }
.modal #cdelInput.is-ok {
  border-color: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent);
}
.modal .form-actions .button.danger[disabled] { opacity: .45; cursor: not-allowed; }

/* ==========================================================
   Bastion armaments
   ========================================================== */
.barm-list { display: grid; gap: 7px; }
.barm {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: color-mix(in srgb, var(--chart-2) 54%, var(--chart));
}
.barm.is-idle { opacity: .72; border-style: dashed; }
.barm-k { min-width: 0; flex: 1; display: grid; gap: 2px; }
.barm-k b { font-size: .88rem; }
.barm-k small { color: var(--muted); font-size: .74rem; line-height: 1.35; }
.barm-crew {
  display: grid;
  gap: 2px;
  margin-top: 9px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--lagoon) 32%, var(--line));
  border-radius: var(--r-s);
  background: color-mix(in srgb, var(--lagoon) 7%, var(--chart));
}
.barm-crew span {
  color: var(--muted);
  font-size: .68rem;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.barm-crew b { font-size: var(--t1); }
.barm-crew.is-short {
  border-color: color-mix(in srgb, var(--warn) 52%, var(--line));
  background: var(--warn-bg);
}
.barm-crew em { color: #7b4208; font-size: .76rem; font-style: normal; font-weight: 800; }
.barm-pick { display: grid; gap: 7px; }
.barm-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--chart);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.barm-pick-row:hover { border-color: color-mix(in srgb, var(--brass) 55%, var(--line)); }
.barm-pick-row span:first-child { min-width: 0; display: grid; gap: 2px; }
.barm-pick-row b { font-size: .9rem; }
.barm-pick-row small { color: var(--muted); font-size: .75rem; }
