/* California Boundaries: a county-sorting game on brand.css tokens and ui.css,
   laid out as Benefit Cliffs is.

   The three regions are the brand blue (NorCal), a green (Central) and the brand
   orange (SoCal), measured in both themes: each is 5:1 or more against the card,
   and any two are 88 or more apart (CIE Lab), so the colors stay apart wherever
   counties meet; simulated for deuteranopia and protanopia they stay 32 or more
   apart (Central and SoCal are the closest pair). None is the site's purple, which marks controls: the pressed
   brush and the focus ring. Neighboring counties are split by a line in the
   card's color; an unsorted county is a quiet gray with an edge. Color is never
   the only cue: the status line names the county and its region, and the results
   table gives every share. */

.cb-app {
  color: var(--ob-fg);
  color-scheme: dark;
  --cb-card: #0c1220;
  --cb-edge: rgba(148, 163, 184, 0.22);
  --cb-text2: #cfd5e1;
  --cb-none: #1f2937;
  --cb-none-edge: #4b5563;
  --cb-N: #60a5fa;
  --cb-fade: #6b7280;   /* what a closer split fades toward: a mid gray in dark, so it reads washed out, not darker */
  --cb-C: #34d399;
  --cb-S: #fb923c;
}

html[data-map-theme="light"] body.cb-page { background: var(--ob-bg); }

.cb-page *, .cb-page *::before, .cb-page *::after { box-sizing: border-box; }
.cb-page [hidden] { display: none !important; }
.cb-page {
  margin: 0;
  background: var(--ob-bg);
  color: var(--ob-fg);
  font-family: var(--ob-font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.cb-page :focus-visible { outline: 2px solid var(--ob-purple); outline-offset: 2px; border-radius: 4px; }
html[data-map-theme="light"] .cb-app {
  color-scheme: light;
  --cb-card: #ffffff;
  --cb-edge: rgba(15, 23, 42, 0.16);
  --cb-text2: #374151;
  --cb-none: #e5e7eb;
  --cb-none-edge: #9ca3af;
  --cb-N: #1d4ed8;
  --cb-fade: #ffffff;
  --cb-C: #047857;
  --cb-S: #c2410c;
}

.cb-wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px; }
.cb-head { margin: 8px 0 20px; }
.cb-title { font-size: clamp(1.6rem, 5vw, 2.1rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; margin: 0.15rem 0 8px; }
.cb-sub { color: var(--cb-text2); font-size: var(--ob-text-md); max-width: 62ch; margin: 0 0 8px; }

.cb-card {
  background: var(--cb-card);
  border: 1px solid var(--cb-edge);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}
.cb-h { font-size: var(--ob-text-lg); margin: 0 0 6px; }

.cb-tools { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.cb-brushf { display: flex; flex-direction: column; gap: 6px; }
.cb-brush button { display: inline-flex; align-items: center; gap: 7px; }
.cb-sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; flex: none; }
.cb-sw[data-k="N"] { background: var(--cb-N); }
.cb-sw[data-k="C"] { background: var(--cb-C); }
.cb-sw[data-k="S"] { background: var(--cb-S); }
.cb-progress { margin: 0; color: var(--ob-muted); font-size: var(--ob-text-sm); font-variant-numeric: tabular-nums; }
.cb-progress b { color: var(--ob-fg); }
.cb-hint, .cb-viewnote { color: var(--ob-muted); font-size: var(--ob-text-sm); margin: 10px 0 0; max-width: 70ch; }

.cb-mapbox { position: relative; margin-top: 8px; }
.cb-map { display: block; width: 100%; max-width: 620px; height: auto; max-height: 72vh; margin: 0 auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
/* A vertical swipe on a map scrolls the page (pan-y); a sideways stroke draws,
   and only when it starts on the state or a fingertip from it (main.js,
   nearState); two fingers pinch to zoom the map. Chromium does not honor
   touch-action on SVG shapes, so the rule is the map's and main.js decides
   where a stroke may start. */
.cb-map.is-zoomed { cursor: grab; }
.cb-zoom { position: absolute; top: 4px; right: 0; z-index: 1; display: flex; flex-direction: column; gap: 6px; }
.cb-zoom button {
  min-width: var(--ob-control-h); min-height: var(--ob-control-h); padding: 0 6px;
  border: 1px solid var(--ob-control-border); border-radius: 8px;
  background: var(--cb-card); color: var(--ob-fg); font: inherit; font-size: var(--ob-text-md); line-height: 1; cursor: pointer;
}
.cb-zoom button[data-z="fit"] { font-size: var(--ob-text-xs); }
.cb-zoom button:hover { border-color: var(--ob-fg); }
.cb-county {
  fill: var(--cb-none);
  stroke: var(--cb-card);
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
  cursor: pointer;
  outline: none;
}
.cb-county[data-r=""] { stroke: var(--cb-none-edge); stroke-width: 0.75px; }
.cb-county[data-r="N"] { fill: var(--cb-N); }
.cb-county[data-r="C"] { fill: var(--cb-C); }
.cb-county[data-r="S"] { fill: var(--cb-S); }
.cb-results .cb-county { cursor: default; }
/* The county under the pointer is outlined in ink, the one with keyboard focus in
   the focus purple; main.js draws the outline as a copy above the map. */
.cb-ring { fill: none; stroke: var(--ob-fg); stroke-width: 2.5px; vector-effect: non-scaling-stroke; stroke-linejoin: round; pointer-events: none; }
.cb-ring.is-focus { stroke: var(--ob-purple); stroke-width: 3px; }
.cb-page .cb-county:focus-visible { outline: none; }
.cb-status { text-align: center; margin: 6px 0 0; min-height: 1.5em; font-size: var(--ob-text-sm); color: var(--cb-text2); }

/* The buttons sit above the map, so they are seen before drawing (Oren, Nov 2,
   2026). */
.cb-fromf { margin: 0 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--cb-edge); }
.cb-fromdone { margin: 0 0 12px; font-size: var(--ob-text-sm); color: var(--cb-text2); }
.cb-fromdone b { color: var(--ob-fg); font-weight: 600; }
.cb-linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--ob-purple); text-decoration: underline; text-underline-offset: 0.2em; cursor: pointer; min-height: var(--ob-control-h); }
.cb-skipline { margin: 2px 0 0; font-size: var(--ob-text-sm); }
/* Undo and Start over act on the map, so they sit just above it, left; the
   zoom buttons are on its right. */
.cb-maptools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cb-tool { font-size: var(--ob-text-sm); }
/* The finish: Submit (the check step only), then the way out without answering. */
.cb-finish { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 10px; font-size: var(--ob-text-sm); }
/* A slip (too short, the wrong way) or a line that left a region empty: said
   above the map in the warning color, while the game carries on. */
.cb-warn { margin: 10px 0 0; color: var(--ob-orange); font-size: var(--ob-text-sm); max-width: 70ch; }
/* Submit sits below the map, where the player finishes the check step. */
.cb-submitbar { display: flex; justify-content: center; width: 100%; }
.cb-submitbar .ob-btn { min-width: 260px; }
.cb-card { scroll-margin-top: 64px; }
.cb-hint { min-height: 3em; }
.cb-hint:focus, .cb-h:focus { outline: none; }
.cb-error { color: var(--ob-orange); margin: 10px 0 0; font-size: var(--ob-text-sm); }

.cb-scorerow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin: 0 0 12px; }
.cb-score { font-size: var(--ob-text-md); margin: 0; color: var(--cb-text2); }
.cb-score b { color: var(--ob-fg); }
.cb-key { margin: 8px 0 14px; font-size: var(--ob-text-sm); color: var(--cb-text2); }
.cb-key-row { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; }
.cb-key span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Where the player is from, above the buttons; the results' filter beside the views. */
.cb-fromf { display: flex; flex-direction: column; gap: 6px; flex: 1 1 100%; }
/* The four places, spelled out, stack in one column on a narrow screen. */
.cb-from { flex-wrap: wrap; align-self: flex-start; }
@media (max-width: 720px) {
  .cb-from { display: grid; grid-template-columns: 1fr; align-self: stretch; }
  .cb-from button { border-left: 0; width: 100%; margin: 0; }
  .cb-from button + button { border-left: 0; border-top: 1px solid var(--ob-control-border); }
}
.cb-fromview { margin: 0; min-width: 0; flex: 0 1 280px; }
.cb-table td.num, .cb-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.cb-table tbody th { font-size: var(--ob-text-md); font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--ob-fg); }
.cb-tablef { margin-top: 4px; }
.cb-tablef summary { cursor: pointer; font-size: var(--ob-text-sm); color: var(--cb-text2); }
.cb-tablef[open] summary { margin-bottom: 8px; }
.cb-table td.is-top { font-weight: 600; }

.cb-foot { color: var(--ob-muted); font-size: var(--ob-text-sm); }
.cb-method summary { cursor: pointer; color: var(--ob-fg); }
.cb-method p { max-width: 70ch; }
.cb-foot a { color: var(--ob-purple); }

@media (max-width: 560px) {
  .cb-card { padding: 12px; }
  .cb-brush button { padding-left: 10px; padding-right: 10px; }
  /* The steps on one line and Submit full width, so the map is near the top. */
  .cb-steps li:not([aria-current]) { font-size: 0; gap: 0; }
  .cb-steps li:not([aria-current]) .cb-sw { display: none; }
  .cb-steps li:not([aria-current])::before { font-size: var(--ob-text-xs); }
  .cb-submitbar .ob-btn { width: 100%; min-width: 0; }
}

/* The three steps: draw where NorCal ends, draw where SoCal begins, check the
   counties. The current step is in ink, a finished one muted with a check. */
.cb-steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0; padding: 0; counter-reset: cb-step; font-size: var(--ob-text-sm); color: var(--ob-muted); }
.cb-steps li { display: inline-flex; align-items: center; gap: 7px; counter-increment: cb-step; }
.cb-steps li::before { content: counter(cb-step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--ob-control-border); font-size: var(--ob-text-xs); font-weight: 600; }
.cb-steps li[aria-current="step"] { color: var(--ob-fg); font-weight: 600; }
.cb-steps li[aria-current="step"]::before { background: var(--ob-purple); border-color: var(--ob-purple); color: var(--ob-on-accent); }
.cb-steps li.is-done::before { content: "\2713"; }
.cb-fix { margin-top: 10px; }

/* While a line is being drawn, the pointer is a crosshair. */
.cb-map.is-drawing { cursor: crosshair; }
.cb-map.is-drawing .cb-county { cursor: crosshair; }

/* The drawn lines: ink, one opaque path each. */
.cb-line { fill: none; stroke: var(--ob-fg); stroke-width: 3px; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.cb-line--live { stroke-dasharray: 6 5; }
