/*
 * Review-table reflow for narrow viewports (WCAG 2.2 1.4.10).
 *
 * Closes review item MEDIUM #6: the Review-table is the MVP's primary
 * surface and enterprise procurement checklists require content to
 * reflow at 320 px without horizontal scrolling.
 *
 * Loaded via <link rel="stylesheet"> from index.html so this rule set
 * lives independently from styles.css (which is currently undergoing a
 * large design-token rewrite). When the design-token work settles,
 * fold these rules into styles.css and remove this file + the
 * index.html link.
 *
 * Behavior at viewport widths:
 *   - > 768 px: full table, all 8 columns (default).
 *   - 481-768 px: existing rule in styles.css hides cols 4-7 (jurisdiction,
 *     confidence, source, verifier), leaving select / title / risk / status.
 *   - <= 480 px: this stylesheet converts the table to a card list.
 *     Each row becomes a stacking card; the select column moves to a
 *     bulk-action button in a sticky footer (phase B work — until then,
 *     individual select stays accessible via the workbench detail).
 *
 * Phase tag: production-polish Phase A (pilot-gating). Phase A scope
 * is intentionally Review-table only; full responsive coverage across
 * other surfaces is Phase C per
 * docs/production-polish/00-README.md.
 */

@media (max-width: 480px) {
  /* The wrapper sometimes pins a min-width or sets a horizontal-scroll
     fallback for table densities; release that so the page reflows. */
  .findings-list-wrap {
    overflow-x: visible;
    min-width: 0;
  }

  /* Hide the column-label row entirely. Each cell will render with an
     inline label via the data-th attribute we don't yet have — for now
     the visible content is enough since the page is single-row-at-once
     in card form. */
  .findings-table thead {
    display: none;
  }

  /* Convert the table to a stack of cards. */
  .findings-table,
  .findings-table tbody {
    display: block;
    width: 100%;
  }

  .findings-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 12px;
    row-gap: 6px;
    align-items: center;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border, #e2e1dc);
    background: var(--surface, #ffffff);
  }

  .findings-table tr:last-child {
    border-bottom: none;
  }

  .findings-table td {
    display: block;
    padding: 0;
    border-bottom: none;
    font-size: 13px;
    line-height: 1.4;
  }

  /* The select checkbox column shrinks rather than disappearing —
     keeping it visible at the start of each card preserves bulk-action
     affordances without horizontal overflow. */
  .findings-table-select-col {
    grid-column: 1 / 2;
    grid-row: 1;
    width: auto;
    text-align: left;
  }

  /* Title gets the wider grid cell; allow it to wrap freely. */
  .findings-table-title {
    grid-column: 1 / -1;
    grid-row: 2;
    font-weight: 600;
    font-size: 14px;
    white-space: normal;
    word-break: break-word;
  }

  /* Risk + status pills sit side-by-side under the title; the rest of
     the metadata columns (jurisdiction, confidence, source, verifier)
     stay hidden — already done by the 768 px rule in styles.css. */
  .findings-table-clause-meta {
    font-size: 11px;
    color: var(--muted, #6b6b66);
  }

  /* Tap target floor: 44 x 44 per WCAG 2.5.5; the checkbox accent stays
     16 px but the surrounding td gets enough padding to meet the floor. */
  .findings-table-select-col input {
    min-width: 20px;
    min-height: 20px;
  }
}

/*
 * Defense in depth: at 320 px (the WCAG floor), tighten padding so
 * the card grid never overflows the viewport regardless of theme or
 * font-stack choices.
 */
@media (max-width: 360px) {
  .findings-table tr {
    padding: 12px 10px;
    column-gap: 8px;
  }
  .findings-table-title {
    font-size: 13.5px;
  }
}
