/* goyo.health /states/ complaint screen: "What happened?" choice card (L-69).
   Append AFTER the existing complaint-entry.css (or replace its fieldset, legend and
   label:has(checkbox) rules with this file). CSS only, no markup or JS change.
   Colors are the existing goyo.css token VALUES, held in --cc-* custom properties on the card
   (--cc-ink = --acc #35506B, --cc-tint = --acc-bg #E9EFF5, --cc-hover = --bg2 #F5F6F4,
   --cc-ink2 = --ink2 #4F524D, --cc-row-line = --line2 #EBECE8) plus the choice-card literals
   border #D9DEE4, radius 12px, gold #E8C46A. They are NOT bound to var(--acc) etc. on purpose:
   goyo.css (@layer site21) forces every label/p/legend to #35506B and every card to #fff on a
   light page even when :root[data-theme=dark] is set, so token-bound surfaces would turn dark
   under navy text (checked, see DESIGN_REPORT.md). When site21 stops forcing those, add one
   :root[data-theme=dark] block that remaps the --cc-* values and nothing else changes.
   Why a @layer site21 block: goyo.css forces legend/label/p/checkbox/h3 styles with !important
   inside @layer site21, and a layered !important beats any unlayered rule. To win, the few
   conflicting declarations below sit in the same layer with higher selector specificity. */

/* ---- 1. Layout: wider left column, single column under 1000px ---- */
@media (min-width: 1000px) {
  .complaint-two-pane {
    grid-template-columns: min(26em, 38%) minmax(0, 1fr);
    column-gap: clamp(28px, 3.2vw, 56px);
    align-items: start;
  }
}

/* ---- 2. The card (fieldset) ---- */
.complaint-two-pane fieldset,
.complaint-two-pane fieldset + div {
  --cc-line: #D9DEE4;
  --cc-bg: #fff;
  --cc-ink: #35506B;
  --cc-ink2: #4F524D;
  --cc-tint: #E9EFF5;
  --cc-hover: #F5F6F4;
  --cc-row-line: #EBECE8;
  --cc-gold: #E8C46A;
  min-width: 0;
  margin: 0 0 var(--gap, 24px);
  padding: 20px;
  background: var(--cc-bg);
  border: 1px solid var(--cc-line);
  border-radius: 12px;
}
@media (min-width: 480px) {
  .complaint-two-pane fieldset,
  .complaint-two-pane fieldset + div { padding: 24px; }
}

/* legend sits INSIDE the card, not notched into the border */
.complaint-two-pane fieldset > legend {
  float: left;
  width: 100%;
  margin: 0 0 6px;
  padding: 0;
  font-size: var(--fs-h3, 1.375rem);
  line-height: 1.2;
  letter-spacing: -.01em;
}
.complaint-two-pane fieldset > legend + * { clear: both; }
.complaint-two-pane fieldset > legend + p { margin: 0 0 16px; }

/* ---- 3. Rows: full-width, 44px+ targets, tint + gold bar when selected ---- */
.complaint-two-pane fieldset label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 52px;
  margin: 0 0 6px;
  padding: 10px 16px 10px 19px;           /* 1px border + 19px = 6px bar + 14px: no shift on select */
  border: 1px solid var(--cc-row-line);
  border-radius: 8px;
  background: transparent;
  line-height: 1.3;
  text-wrap: balance;                       /* no orphan word when a long label wraps in a narrow column */
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}
.complaint-two-pane fieldset label:has(> input[type="checkbox"]):last-child { margin-bottom: 0; }
@media (hover: hover) {
  .complaint-two-pane fieldset label:has(> input[type="checkbox"]):hover {
    background: var(--cc-hover);
    border-left: 6px solid var(--cc-gold);
    padding-left: 14px;
  }
}
.complaint-two-pane fieldset label:has(> input[type="checkbox"]:checked),
.complaint-two-pane fieldset label:has(> input[type="checkbox"]:checked):hover {
  background: var(--cc-tint);
  border-left: 6px solid var(--cc-gold);
  padding-left: 14px;
}

/* focus ring moves to the whole row (same gold ring as before) where :has() exists */
@supports selector(:has(*)) {
  .complaint-two-pane fieldset label:has(> input[type="checkbox"]:focus-visible) {
    outline: 3px solid var(--cc-gold);
    outline-offset: 3px;
    box-shadow: 0 0 0 1px var(--cc-ink);
  }
}

/* ---- 4. Conflicts with goyo.css !important rules (same layer, higher specificity) ---- */
@layer site21 {
  html body main#main .complaint-two-pane fieldset > legend {
    font-family: var(--f-head, Literata, Georgia, serif) !important; /* heading token; site21 forces the body face on legend */
    font-weight: 600 !important;
    font-feature-settings: "zero" 0 !important;
    color: var(--cc-ink) !important;
  }
  html body main#main .complaint-two-pane fieldset > legend + p {
    color: var(--cc-ink2) !important;
  }
  html body main#main .complaint-two-pane fieldset label > input[type="checkbox"] {
    appearance: none !important;
    -webkit-appearance: none !important;
    flex: 0 0 24px !important;
    width: 24px !important;
    height: 24px !important;
    min-height: 24px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 2px solid var(--cc-ink) !important;
    border-radius: 6px !important;
    background: var(--cc-bg) !important;
    position: relative !important;
    box-shadow: none !important;
    transition: background-color .12s ease;
  }
  html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]:checked {
    background: var(--cc-ink) !important;
    box-shadow: none !important; /* goyo.css adds an inset white 4px ring on :checked */
  }
  /* row carries the focus ring (see section 3); drop the second ring on the box itself */
  @supports selector(:has(*)) {
    html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]:focus-visible {
      outline: 0 !important;
      box-shadow: none !important;
    }
  }
  /* pseudo-element tick: no image asset (goyo.css also forbids background-image here) */
  html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]::after {
    content: none;
    position: absolute;
    left: 6px;
    top: 1px;
    box-sizing: content-box;
    width: 5px;
    height: 11px;
    border: solid var(--cc-bg);
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
  }
  html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]:checked::after {
    content: "";
  }
  /* right pane: air between the intro lines and the first group heading */
  html body main#main .complaint-two-pane > section:last-child > h2 { margin: 0 0 12px !important; }
  html body main#main .complaint-two-pane > section:last-child > p { margin: 0 0 8px !important; }
  html body main#main .complaint-two-pane > section:last-child > div > section > h3 { margin: 32px 0 12px !important; }
  html body main#main .complaint-two-pane > section:last-child > div > section:first-child > h3 { margin-top: 28px !important; }
}

/* ---- 5. Preferences ---- */
@media (prefers-reduced-motion: reduce) {
  .complaint-two-pane fieldset label,
  .complaint-two-pane fieldset label > input[type="checkbox"] { transition: none !important; }
}
@media (forced-colors: active) {
  .complaint-two-pane fieldset label > input[type="checkbox"]:checked { background: Highlight !important; forced-color-adjust: none; }
  .complaint-two-pane fieldset label > input[type="checkbox"]::after { border-color: HighlightText; }
}
/* UI/UX patch proposed on top of candidate v1 (append AFTER complaint-entry.fix.css) */
/* R4/R14: left column never under 380px at 1000-1099 */
@media (min-width: 1000px) {
  .complaint-two-pane { grid-template-columns: clamp(380px, 38%, 26em) minmax(0, 1fr); }
}
/* R16: hover = tint only, never the gold bar (gold bar = selected) */
@media (hover: hover) {
  .complaint-two-pane fieldset label:has(> input[type="checkbox"]):not(:has(> input:checked)):hover {
    background: var(--cc-hover);
    border-left: 1px solid var(--cc-row-line);
    padding-left: 19px;
  }
}
/* R17: focus ring: 2px navy inside + 3px gold outside */
@supports selector(:has(*)) {
  .complaint-two-pane fieldset label:has(> input[type="checkbox"]:focus-visible) {
    outline: 3px solid var(--cc-gold);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px var(--cc-ink);
  }
}
.complaint-two-pane fieldset label > input[type="checkbox"] { scroll-margin-block: 24px; }
/* R26: forced-colors, same layer so it beats the layered !important rules */
@layer site21 {
  @media (forced-colors: active) {
    html body main#main .complaint-two-pane fieldset label > input[type="checkbox"] { border-color: ButtonText !important; background: Canvas !important; }
    html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]:checked { background: Highlight !important; border-color: Highlight !important; }
    html body main#main .complaint-two-pane fieldset label > input[type="checkbox"]::after { border-color: HighlightText !important; }
  }
}
/* R23 (SHOULD): two columns of rows between 600 and 999px */
@media (min-width: 600px) and (max-width: 999px) {
  .complaint-two-pane fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 12px; align-content: start; }
  .complaint-two-pane fieldset > legend + p { grid-column: 1 / -1; }
  .complaint-two-pane fieldset label:has(> input[type="checkbox"]) { margin: 0 0 6px; }
}
