/* Spam Patterns — single light theme (no dark mode in v1), forced-colors supported. */
:root {
  --canvas: #F8FAFC; --surface: #FFFFFF; --text: #172333; --text-2: #475569;
  --divider: #CBD5E1; --outline: #64748B; --action: #1746A2; --action-hover: #123679;
  --focus: #155EEF; --err: #9F2020; --err-bg: #FFF1F1; --ok: #14533D; --ok-bg: #EAF6EF;
  --warn: #713D00; --warn-bg: #FFF4DB; --map-bg: #F1F5F9;
  --bin0: #F1F5F9; --bin0-text: #475569; --bin1: #A9C5E2; --bin2: #6D98C5; --bin3: #3B6B9B; --bin4: #204A73;
  --bin-text-light: #172333; --bin-text-dark: #FFFFFF;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--canvas); color: var(--text); font: 400 16px/24px var(--font); }
a { color: var(--action); }
a:hover { color: var(--action-hover); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px #fff; }
.wrap { max-width: 1280px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 1024px) { .wrap { padding: 0 32px; } }
.narrow { max-width: 560px; }
.prose { max-width: 72ch; }
h1 { font-size: 28px; line-height: 34px; font-weight: 650; margin: 32px 0 16px; }
h2 { font-size: 22px; line-height: 28px; font-weight: 650; margin: 32px 0 12px; }
h3 { font-size: 18px; line-height: 24px; font-weight: 650; margin: 24px 0 8px; }
@media (min-width: 1024px) { h1 { font-size: 36px; line-height: 44px; } h2 { font-size: 24px; line-height: 32px; } }
.lead { font-size: 18px; line-height: 28px; color: var(--text); }
.meta, .help { font-size: 14px; line-height: 20px; color: var(--text-2); }
.num, .mono { font-variant-numeric: tabular-nums; }
.mono, .receipt { font-family: var(--mono); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 16px; }

/* header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--divider); }
.header-row { display: flex; align-items: center; gap: 16px; min-height: 64px; flex-wrap: wrap; }
.wordmark { font-weight: 650; font-size: 18px; color: var(--text); text-decoration: none; margin-right: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; }
.wordmark .logo { width: 32px; height: 32px; flex: none; }
.nav-desktop { display: none; gap: 16px; }
.nav-desktop a, .nav-mobile a { color: var(--text); text-decoration: none; padding: 8px 4px; }
.nav-desktop a[aria-current], .nav-mobile a[aria-current] { color: var(--action); text-decoration: underline; text-underline-offset: 6px; }
.nav-mobile summary { cursor: pointer; padding: 12px 8px; min-height: 48px; font-weight: 600; }
.nav-mobile nav { display: flex; flex-direction: column; padding-bottom: 8px; }
@media (min-width: 768px) { .nav-desktop { display: flex; } .nav-mobile { display: none; } }
.demo-banner { background: var(--warn-bg); color: var(--warn); font-size: 14px; line-height: 20px; padding: 8px 0; border-bottom: 1px solid var(--divider); }
main { padding-bottom: 64px; overflow-wrap: break-word; }
main:focus { outline: none; }
.site-footer { border-top: 1px solid var(--divider); background: var(--surface); padding: 24px 0 32px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; }

/* buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 20px; border-radius: 6px; font: 600 16px/24px var(--font); text-decoration: none; cursor: pointer; border: 2px solid transparent; margin: 0 8px 8px 0; }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-hover); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--action); border-color: var(--action); }
.btn-secondary:hover { color: var(--action-hover); border-color: var(--action-hover); }
.btn-link { background: none; color: var(--action); text-decoration: underline; padding-left: 4px; padding-right: 4px; }
.btn-danger { background: var(--err); color: #fff; }
.btn[disabled] { opacity: .7; cursor: progress; }
.btn-report { margin: 8px 0; }
.file-btn { cursor: pointer; }
input:focus-visible + .file-btn, #shot:focus + .file-btn { outline: 3px solid var(--focus); }
.field { margin: 0 0 16px; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
.optional { font-weight: 400; color: var(--text-2); }
input[type=text], input[type=tel], textarea, select { width: 100%; font: 400 16px/24px var(--font); color: var(--text); background: var(--surface); border: 1px solid var(--outline); border-radius: 6px; padding: 11px 12px; min-height: 48px; }
textarea { resize: vertical; }
[aria-invalid=true] { border-color: var(--err); border-width: 2px; }
.field-error { color: var(--err); font-size: 14px; line-height: 20px; margin: 4px 0 0; font-weight: 600; }
.help { margin: 0 0 4px; }

/* notices */
.notice { border-radius: 6px; padding: 12px 16px; margin: 16px 0; border: 1px solid; }
.notice h1, .notice h2 { margin-top: 4px; }
.notice-error { color: var(--err); background: var(--err-bg); border-color: var(--err); }
.notice-success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.notice-info { background: var(--surface); border-color: var(--divider); }
.notice-warning, .geo-warning { color: var(--warn); background: var(--warn-bg); border-color: var(--warn); }
.geo-warning { border: 1px solid var(--warn); border-radius: 6px; padding: 8px 12px; margin: 0 0 12px; font-size: 14px; line-height: 20px; }
.geo-warning p { margin: 0; }
.terms { font-size: 14px; line-height: 20px; border-left: 3px solid var(--divider); padding-left: 12px; }

/* panels */
.panel { background: var(--surface); border: 1px solid var(--divider); border-radius: 6px; padding: 16px; margin: 0 0 16px; }
.scrubbed { white-space: pre-wrap; overflow-wrap: anywhere; }
.dl { display: grid; grid-template-columns: minmax(8em, max-content) 1fr; gap: 8px 16px; margin: 0 0 16px; }
.dl dt { font-weight: 600; } .dl dd { margin: 0; overflow-wrap: anywhere; }
.dl.compact { font-size: 14px; line-height: 20px; }
.receipt { font-size: 20px; line-height: 28px; background: var(--surface); border: 1px dashed var(--outline); padding: 12px; border-radius: 6px; user-select: all; overflow-wrap: anywhere; }
.choice { display: grid; gap: 16px; }
@media (min-width: 640px) { .choice { grid-template-columns: 1fr 1fr; } }
.choice-item { background: var(--surface); border: 1px solid var(--divider); border-radius: 6px; padding: 16px; }
.choice-item h2 { margin-top: 0; font-size: 18px; line-height: 24px; }
.choice-item .btn { width: 100%; }

/* overview */
.hero { padding: 8px 0 16px; }
.tagline { margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--text-2); }
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-bottom: 8px; }
.filters label { margin: 0; align-self: center; }
.filters select { width: auto; }
.filters .btn { margin: 0; }
.count-block { font-size: 16px; }
.big { font-size: 28px; line-height: 34px; font-weight: 650; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); margin: 8px 0 16px; }
.tabs a { padding: 10px 16px; min-height: 44px; text-decoration: none; color: var(--text); border: 1px solid transparent; border-bottom: 0; border-radius: 6px 6px 0 0; }
.tabs a[aria-current] { border-color: var(--divider); background: var(--surface); color: var(--action); font-weight: 600; margin-bottom: -1px; }
.views-wrap { container: views / inline-size; }
.views-both { display: grid; gap: 16px; align-items: start; }
.views-both > * { min-width: 0; }
/* Two columns only when the map panel keeps its 716 px content minimum
   (716 + 2 x 16 padding + 2 x 1 border = 750) beside a 360 px table. */
@container views (min-width: 1126px) { .views-both { grid-template-columns: minmax(360px, 1fr) minmax(750px, 1.5fr); } }
#map-h { margin-top: 0; }
.map-links { margin: 0 0 12px; }
.map-links a { display: inline-block; padding: 12px 0; }
.map-summary { font-size: 18px; line-height: 28px; margin: 0 0 4px; }
.map-key { margin: 0 0 12px; }

/* Map: the tile grid needs 716 px (12 x 56 px + 11 x 4 px). Below that the
   state list is shown instead. Both are server-rendered; no JS. */
.map-body { container: mapbody / inline-size; }
.tile-grid { display: none; }
.state-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
@container mapbody (min-width: 716px) {
  .tile-grid { display: grid; grid-template-columns: repeat(12, minmax(56px, 1fr)); grid-template-rows: repeat(8, minmax(56px, auto)); gap: 4px; margin: 0 0 12px; }
  .state-list { display: none; }
}
.gc1 { grid-column: 1; } .gc2 { grid-column: 2; } .gc3 { grid-column: 3; } .gc4 { grid-column: 4; } .gc5 { grid-column: 5; } .gc6 { grid-column: 6; }
.gc7 { grid-column: 7; } .gc8 { grid-column: 8; } .gc9 { grid-column: 9; } .gc10 { grid-column: 10; } .gc11 { grid-column: 11; } .gc12 { grid-column: 12; }
.gr1 { grid-row: 1; } .gr2 { grid-row: 2; } .gr3 { grid-row: 3; } .gr4 { grid-row: 4; } .gr5 { grid-row: 5; } .gr6 { grid-row: 6; } .gr7 { grid-row: 7; } .gr8 { grid-row: 8; }
.tile { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 56px; min-height: 56px; padding: 4px 6px; border-radius: 4px; text-decoration: none; border: 1px solid transparent; }
.tile-abbr { font: 600 14px/18px var(--font); }
.tile-count { font: 700 16px/20px var(--font); font-variant-numeric: tabular-nums; }
a.tile { border-color: var(--outline); }
a.tile:hover { text-decoration: underline; }

/* One palette for tile fills, list swatches and legend swatches. */
.bin0 { background: var(--bin0); color: var(--bin0-text); }
.bin1 { background: var(--bin1); color: var(--bin-text-light); }
.bin2 { background: var(--bin2); color: var(--bin-text-light); }
.bin3 { background: var(--bin3); color: var(--bin-text-dark); }
.bin4 { background: var(--bin4); color: var(--bin-text-dark); }
a.tile.bin1:hover, a.tile.bin2:hover { color: var(--bin-text-light); }
a.tile.bin3:hover, a.tile.bin4:hover { color: var(--bin-text-dark); }

/* Focus: distinct outer outline (global :focus-visible). Selected: inset
   border plus a check mark. Both can show at once. */
.tile.selected, .state-row.selected { box-shadow: inset 0 0 0 3px var(--text), inset 0 0 0 5px #fff; }
.tile.selected:focus-visible, .state-row.selected:focus-visible { box-shadow: 0 0 0 2px #fff, inset 0 0 0 3px var(--text), inset 0 0 0 5px #fff; }
.sel-mark { position: absolute; top: 4px; right: 7px; font: 700 14px/18px var(--font); }
.state-row { position: relative; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--divider); border-radius: 6px; background: var(--surface); color: var(--text); text-decoration: none; }
.state-row:hover { border-color: var(--action); color: var(--action-hover); }
.state-row .swatch { flex: none; }
.sl-name { flex: 1; min-width: 0; text-decoration: underline; text-underline-offset: 3px; }
.sl-sep { display: none; }
.sl-count { text-align: right; white-space: nowrap; }
.state-row.selected { padding-right: 32px; font-weight: 600; }
.state-row .sel-mark { top: 50%; transform: translateY(-50%); right: 12px; }

.legend ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 14px; }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid var(--outline); vertical-align: -3px; margin-right: 6px; }
.state-row .swatch { margin-right: 0; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 15px; line-height: 22px; }
.data-table caption { text-align: left; font-size: 14px; color: var(--text-2); padding: 4px 0 8px; }
.data-table th, .data-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--divider); vertical-align: top; }
.data-table th a { color: var(--text); }
.data-table .num { text-align: right; }
.data-table tr.selected td { background: #EEF3FB; font-weight: 600; }
.stack-region { display: none; }
@media (max-width: 400px) { .data-table th, .data-table td { padding: 8px 6px; } .panel { padding: 12px; } }
@media (max-width: 600px) { .col-region { display: none; } .stack-region { display: block; font-size: 14px; color: var(--text-2); } }
.code-list { list-style: none; padding: 0; columns: 2; }
.code-list li { padding: 4px 0; }
.empty { color: var(--text-2); padding: 12px 0; }

/* patterns */
.pattern-list { list-style: none; padding: 0; display: grid; gap: 16px; }
/* recurring scripts (home) */
.scripts { margin: 0 0 24px; }
.script-list { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.script-list li { padding: 8px 0; border-bottom: 1px solid var(--divider); }
.script-list .meta { display: block; }
.correction { margin: 12px 0; }
.pattern h2 { margin-top: 0; font-size: 18px; line-height: 24px; }
.badge { display: inline-block; font-size: 14px; line-height: 20px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--outline); background: var(--surface); margin: 0 0 12px; }
.skeleton { font-size: 15px; }

/* how it works (home): the diagram keeps its text legible and scrolls sideways on narrow screens */
.how { margin: 32px 0 0; }
.flow { margin: 0 0 12px; }
.flow-scroll { overflow-x: auto; border: 1px solid var(--divider); border-radius: 6px; background: var(--surface); }
.flow-scroll img { display: block; width: 100%; min-width: 1100px; max-width: 1240px; height: auto; margin: 0 auto; }
.flow-hint { margin: 4px 0 0; }
@media (min-width: 1132px) { .flow-hint { display: none; } }

/* install hint (footer and receipt), never a popup */
.install-hint { margin: 16px 0; }
.install-hint p { margin: 0 0 8px; }
.install-btn { margin-top: 4px; }
.site-footer .install-hint { border-top: 1px solid var(--divider); padding-top: 12px; }

@media (forced-colors: active) {
  .btn { border: 2px solid ButtonText; }
  .tile { border: 1px solid GrayText; color: GrayText; }
  a.tile, .state-row { border: 2px solid LinkText; color: LinkText; }
  .tile.selected, .state-row.selected { border: 4px solid Highlight; }
  .sel-mark { color: Highlight; }
  :focus-visible { outline: 3px solid CanvasText; }
  .swatch { forced-color-adjust: none; border-color: CanvasText; }
  .geo-warning, .notice { border: 2px solid CanvasText; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.nowrap { white-space: nowrap; }
