/* State Comparison Grid — "How each state stacks up".
 * Implements the "State Comparison Grid" design (claude.ai/design project
 * "Abhortion"). One grid system, two densities: .cmp-print is the letter
 * sheet rendered inside <doc-page> (with snapshot.css for the paper tokens),
 * .cmp-web the site page that links to its PDF (with site.css). */

/* ---------- Shared grid ---------- */
.cmp-grid {
  --cmp-green: #3d6b3f;
  --cmp-yellow: #c9992e;
  --cmp-red: #9c3a33;
  --cmp-blank: #b9b4a8;
  --cmp-unclear-a: #e3dcc9;
  --cmp-unclear-b: #a39d8f;
  --cmp-label-w: 96px;
  --cmp-row-h: 15px;
  --cmp-gap: 1px;
  --cmp-cols: 8;
}
.cmp-grid { --cmp-band-gap: 5px; }
.cmp-row {
  display: grid;
  grid-template-columns: var(--cmp-template, var(--cmp-label-w) repeat(var(--cmp-cols), minmax(0, 1fr)));
  gap: var(--cmp-gap);
}
.cmp-gap { display: block; }
/* Band labels span their columns above the headings. */
.cmp-bands { align-items: end; }
.cmp-band {
  font-family: var(--sans);
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-fade);
  border-bottom: 1px solid var(--rule);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-head { align-items: end; }
/* Column headings run bottom-to-top in the short lines the spec's `lines`
 * give (rendered as <br>), so the header band stays shallow and a column
 * can be as narrow as a couple of lines of type. */
.cmp-th {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
}
.cmp-th > span {
  display: block;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  line-height: 1.3;
}
.cmp-body {
  display: flex;
  flex-direction: column;
  gap: var(--cmp-row-gap, var(--cmp-gap));
  padding-top: var(--cmp-row-gap, var(--cmp-gap));
}
.cmp-body .cmp-row { height: var(--cmp-row-h); }
.cmp-cell {
  display: block;
  min-width: 0;
  background: var(--cmp-blank);
}
.cmp-cell.g { background: var(--cmp-green); }
.cmp-cell.y { background: var(--cmp-yellow); }
.cmp-cell.r { background: var(--cmp-red); }
.cmp-cell.u,
.cmp-legend i.u,
.cmp-key .sw.u {
  background: repeating-linear-gradient(135deg, var(--cmp-unclear-b) 0 1.5px, var(--cmp-unclear-a) 1.5px 5px);
}
.cmp-label {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  padding-right: 4px;
  line-height: 1;
  color: var(--ink);
}
.cmp-label .code {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-fade);
}
.cmp-label .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-row.is-pending .cmp-label { color: var(--ink-fade); }

/* Legend swatches (both densities). */
.cmp-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  font-family: var(--sans);
  text-transform: uppercase;
  color: var(--ink-2);
}
.cmp-legend span { display: flex; align-items: center; }
.cmp-legend i {
  display: block;
  --cmp-green: #3d6b3f; --cmp-yellow: #c9992e; --cmp-red: #9c3a33; --cmp-blank: #b9b4a8;
  --cmp-unclear-a: #e3dcc9; --cmp-unclear-b: #a39d8f;
  background: var(--cmp-blank);
}
.cmp-legend i.g { background: var(--cmp-green); }
.cmp-legend i.y { background: var(--cmp-yellow); }
.cmp-legend i.r { background: var(--cmp-red); }

/* ---------- Print sheet (letter, one explicit page) ---------- */
.cmp-print {
  display: flex;
  flex-direction: column;
  padding: 0.42in 0.45in 0.4in;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}
.cmp-print .cmp-mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 7px;
  border-bottom: 1.5px solid var(--ink);
}
.cmp-print .brand {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.cmp-print .tag {
  font-size: 7px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-mute);
  margin-top: 3px;
}
.cmp-print .right { text-align: right; }
.cmp-print h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}
.cmp-print .sub {
  font-size: 7.5px;
  color: var(--ink-mute);
  margin-top: 2px;
}
.cmp-print .cmp-legend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 6px 0 5px;
  border-bottom: 1px solid var(--rule);
}
.cmp-print .cmp-legend { gap: 14px; font-size: 7px; letter-spacing: 0.11em; }
.cmp-print .cmp-legend span { gap: 4px; }
.cmp-print .cmp-legend i { width: 9px; height: 9px; }
.cmp-print .hint {
  font-size: 7px;
  color: var(--ink-fade);
  white-space: nowrap;
}
.cmp-print .cmp-grid { --cmp-row-h: 13.5px; --cmp-row-gap: 3px; padding-top: 5px; }
.cmp-print .cmp-band { font-size: 6.5px; letter-spacing: 0.09em; padding-bottom: 2px; }
.cmp-print .cmp-bands { margin-bottom: 4px; }
.cmp-print .cmp-th {
  font-size: 7px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  padding: 0 0 4px;
  border-bottom: 1px solid var(--ink);
}
.cmp-print .cmp-label { font-size: 9px; }
.cmp-print .cmp-label .code { width: 17px; font-size: 7.5px; }
.cmp-print .cmp-foot {
  margin-top: auto;
  padding-top: 7px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 7.5px;
  line-height: 1.4;
  color: var(--ink-mute);
}
.cmp-print .cmp-foot p { margin: 0; }
.cmp-print .cmp-foot .qr {
  flex: none;
  width: 60px;
  text-align: center;
  text-decoration: none;
  color: var(--ink-fade);
  font-size: 6px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cmp-print .cmp-foot .qr svg { display: block; width: 60px; height: 60px; margin-bottom: 3px; }
.cmp-print .cmp-foot .key { flex: 1 1 auto; min-width: 0; }
.cmp-print .cmp-foot .key p { margin: 0 0 1px; }
.cmp-print .cmp-foot .key b { font-weight: 600; color: var(--ink); }
.cmp-print .cmp-foot .right { flex: none; text-align: right; white-space: nowrap; }

/* ---------- Site page ---------- */
.cmp-web .cmp-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -12px 0 32px;
}
.cmp-btn {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--navy);
  border: 1px solid var(--navy);
  border-radius: 3px;
  padding: 10px 16px;
  text-decoration: none;
}
.cmp-btn:hover { background: var(--navy-2); border-color: var(--navy-2); color: var(--paper); }
.cmp-btn.ghost { background: transparent; color: var(--navy); }
.cmp-btn.ghost:hover { background: var(--paper-2); color: var(--navy-2); }

.cmp-web .cmp-legend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 12px 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--rule);
}
.cmp-web .cmp-legend { gap: 8px 22px; font-size: 11px; letter-spacing: 0.14em; }
.cmp-web .cmp-legend span { gap: 7px; }
.cmp-web .cmp-legend i { width: 13px; height: 13px; }
.cmp-web .hint {
  margin: 0;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-fade);
}

.cmp-scroll { overflow-x: auto; }
.cmp-web .cmp-grid {
  --cmp-label-w: 176px;
  --cmp-row-h: 24px;
  --cmp-gap: 2px;
  --cmp-band-gap: 10px;
  min-width: 980px;
  padding-top: 8px;
}
.cmp-web .cmp-band { font-size: 10px; letter-spacing: 0.14em; line-height: 1.3; padding: 0 4px 6px; white-space: normal; overflow: visible; }
.cmp-web .cmp-bands { margin-bottom: 8px; }
.cmp-web .cmp-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--paper);
  padding-top: 6px;
}
.cmp-web .cmp-th {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--ink);
  font-family: var(--sans);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  line-height: 1.3;
  color: var(--ink-2);
  padding: 0 4px 8px;
  cursor: pointer;
}
.cmp-web .cmp-th-label { justify-content: flex-start; text-align: left; }
.cmp-web .cmp-th-label > span { writing-mode: horizontal-tb; transform: none; }
.cmp-web .cmp-th:hover,
.cmp-web .cmp-th[aria-sort] { color: var(--ochre); }
.cmp-web .cmp-th[aria-sort="ascending"] > span::after { content: " ↓"; }
.cmp-web .cmp-th[aria-sort="descending"] > span::after { content: " ↑"; }
.cmp-web .cmp-th-label[aria-sort="ascending"] > span::after { content: " ↓"; }
.cmp-web .cmp-th-label[aria-sort="descending"] > span::after { content: " ↑"; }

.cmp-web .cmp-body .cmp-row { text-decoration: none; color: inherit; }
.cmp-web .cmp-body a.cmp-row:hover .cmp-label { color: var(--ochre); }
.cmp-web .cmp-label { font-family: var(--sans); font-size: 14px; }
.cmp-web .cmp-label .code { width: 26px; font-size: 11px; }

.cmp-web .cmp-cell { position: relative; }
.cmp-web .cmp-cell:hover,
.cmp-web .cmp-cell:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
  z-index: 3;
}
.cmp-web .cmp-cell::after {
  content: attr(data-v);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 6px);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.3;
  padding: 5px 9px;
  border-radius: 2px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 4;
}
.cmp-web .cmp-cell:hover::after,
.cmp-web .cmp-cell:focus-visible::after { opacity: 1; visibility: visible; }
/* Keep the tooltip inside the grid at either edge. */
.cmp-web .cmp-cell.edge-l::after { left: 0; transform: none; }
.cmp-web .cmp-cell.edge-r::after { left: auto; right: 0; transform: none; }

.cmp-web .cmp-tally {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
  align-items: center;
}
.cmp-web .cmp-tally .cmp-label { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-fade); }
.cmp-tally-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding-left: 4px;
  font-family: var(--sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}
.cmp-tally-cell b { font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.cmp-tally-cell b::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #b9b4a8;
}
.cmp-tally-cell b.g::before { background: #3d6b3f; }
.cmp-tally-cell b.y::before { background: #c9992e; }
.cmp-tally-cell b.r::before { background: #9c3a33; }
.cmp-tally-cell b.u::before { background: repeating-linear-gradient(135deg, #a39d8f 0 1.5px, #e3dcc9 1.5px 5px); }

.cmp-web .cmp-source {
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-fade);
  max-width: 48rem;
  margin: 20px 0 0;
}

.cmp-web .cmp-key-h {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.01em;
  margin: 56px 0 18px;
}
.cmp-key {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}
.cmp-key th {
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-fade);
  padding: 0 14px 10px 0;
  border-bottom: 1px solid var(--ink);
}
.cmp-key td {
  padding: 11px 14px 11px 0;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
  color: var(--ink-2);
}
.cmp-key td.col {
  font-family: var(--serif);
  font-size: 16px;
  color: var(--ink);
  white-space: nowrap;
}
.cmp-key td.col code {
  display: block;
  font-size: 11.5px;
  color: var(--ink-fade);
  margin-top: 3px;
  white-space: normal;
}
.cmp-key tr.band th {
  padding: 26px 0 8px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  border-bottom: 1px solid var(--ink);
}
.cmp-key tr.band th span {
  display: block;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink-fade);
  margin-top: 2px;
}
.cmp-key .sw {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin: 0 7px -1px 0;
  background: #b9b4a8;
}
.cmp-key .sw.g { background: #3d6b3f; }
.cmp-key .sw.y { background: #c9992e; }
.cmp-key .sw.r { background: #9c3a33; }
.cmp-key .none { color: var(--ink-fade); }

@media (max-width: 900px) {
  .cmp-web .cmp-tools { margin-top: 0; }
  .cmp-key { font-size: 13px; }
  .cmp-key td.col { white-space: normal; font-size: 15px; }
}
@media (max-width: 600px) {
  .cmp-key thead { display: none; }
  .cmp-key tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
  .cmp-key td { display: block; border: 0; padding: 3px 0; }
}
@media print {
  .cmp-web .cmp-tools, .cmp-web .hint, .cmp-web .cmp-source { display: none; }
  .cmp-web .cmp-grid { min-width: 0; }
  .cmp-web .cmp-head { position: static; }
  .cmp-web .cmp-body .cmp-row { break-inside: avoid; }
}
