/* 4fred.info: Greenwich voting data. Blue, plain and data-first. Light theme only,
   matching Fred's other sites. Chart colors are validated for color-blind readers. */
:root {
  --paper: #f6f8fb;
  --white: #ffffff;
  --ink: #14202e;
  --muted: #556273;
  --navy: #0d2c54;
  --navy-deep: #081f3d;
  --blue: #1c5cab;
  --blue-wash: #e6eef9;
  --line: #d9e1ec;
  --sky: #9ec5f4;

  /* chart roles */
  --chart-surface: #ffffff;
  --series-1: #2a78d6;  /* blue: Greenwich, presidential, the selected election */
  --series-2: #eb6834;  /* orange: Connecticut, state elections */
  --series-3: #1baf7a;  /* aqua: municipal elections */
  --context: #c3ccd8;   /* other elections, drawn quietly behind */
  --grid: #e7ecf2;

  --ui: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; font: 400 1.0625rem/1.65 var(--ui); color: var(--ink); background: var(--paper); }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid #f2b33d; outline-offset: 2px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 24px; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 20; background: var(--white); padding: 8px 12px; }

h1, h2, h3 { font-weight: 700; line-height: 1.15; margin: 0 0 .5em; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 4.8vw, 3.5rem); }
h2 { font-size: clamp(1.6rem, 2.8vw, 2.15rem); }
h3 { font-size: 1.2rem; }
.label { font: 700 .75rem/1.4 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--blue); margin: 0 0 .7rem; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }

/* Header */
.site-header { background: var(--navy); color: var(--white); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-block: 14px; flex-wrap: wrap; }
.wordmark { color: var(--white); text-decoration: none; display: flex; align-items: center; gap: 12px; }
.wordmark-mark { width: 34px; height: 20px; border-radius: 50%; background: var(--white); flex: none; }
.wordmark strong { display: block; font-size: 1.15rem; }
.wordmark small { display: block; font-size: .82rem; color: var(--sky); }
.nav { display: flex; gap: 6px 22px; flex-wrap: wrap; }
.nav a { color: #dce7f6; text-decoration: none; font-weight: 500; font-size: .95rem; padding-block: 4px; }
.nav a:hover { color: var(--white); }
.nav a[aria-current="page"] { color: var(--white); box-shadow: inset 0 -2px 0 var(--sky); }

/* Page head */
.page-head { background: var(--navy); color: var(--white); padding-block: clamp(36px, 6vw, 72px) clamp(40px, 6vw, 76px); border-top: 1px solid #1d3f6c; }
.page-head .label { color: var(--sky); }
.page-head p.lede { font-size: clamp(1.05rem, 1.8vw, 1.25rem); color: #dce7f6; max-width: 60ch; margin: 0; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: -40px; position: relative; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px; }
.stat-label { margin: 0 0 6px; font-size: .92rem; color: var(--muted); }
.stat-value { margin: 0; font-size: clamp(2.2rem, 4vw, 3rem); font-weight: 650; line-height: 1.05; letter-spacing: -.02em; }
.stat-note { margin: 6px 0 0; font-size: .88rem; color: var(--muted); }

/* Sections and cards */
section { padding-block: clamp(40px, 6vw, 72px); }
.section-head { max-width: 68ch; margin-bottom: 1.4rem; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: clamp(18px, 3vw, 28px); }
.card + .card { margin-top: 20px; }
.card h3 { margin-bottom: .3em; }
.chart-sub { margin: 0 0 1rem; color: var(--muted); font-size: .95rem; }

/* Links grid */
.links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 0; padding: 0; list-style: none; }
.links a { display: block; height: 100%; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; text-decoration: none; color: var(--ink); transition: border-color .15s; }
.links a:hover { border-color: var(--blue); }
.links strong { display: block; color: var(--blue); margin-bottom: 4px; }
.links span { font-size: .93rem; color: var(--muted); }

/* Lookup embed */
.lookup { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); }

/* Charts */
.chart { display: block; overflow: visible; font: 12px var(--ui); touch-action: pan-y; }
.chart .axis text, .chart .axis-text { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .axis-text.is-selected { fill: var(--ink); font-weight: 700; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: #b7c2d0; stroke-width: 1; }
.chart .crosshair { stroke: #8b97a8; stroke-width: 1; }
.chart .end-label { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .value-label { fill: var(--ink); font-size: 13px; font-weight: 700; }
.chart .bar path { transition: opacity .12s; }
.chart .bar:hover path { opacity: .82; }
.chart .bar.is-clickable { cursor: pointer; }
.chart .bar.is-selected path { stroke: var(--ink); stroke-width: 0; }
.chart:focus { outline: none; }
.chart:focus-visible, .chart .bar:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; padding: 0; list-style: none; font-size: .9rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 7px; }
.key-line { width: 16px; height: 2px; border-radius: 1px; }
.key-box { width: 10px; height: 10px; border-radius: 2px; }

.chart-tip { position: absolute; z-index: 30; display: none; pointer-events: none; background: var(--white); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(13,44,84,.14); padding: 8px 12px; font-size: .85rem; min-width: 140px; }
.chart-tip-title { color: var(--muted); margin-bottom: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 8px; }
.chart-tip-row strong { font-variant-numeric: tabular-nums; }
.chart-tip-row span:last-child { color: var(--muted); }
.chart-tip-key { width: 12px; height: 2px; border-radius: 1px; flex: none; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; margin-bottom: 20px; }
.controls label { display: grid; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.controls select { font: 600 1rem var(--ui); color: var(--ink); padding: 9px 36px 9px 12px; border: 1px solid #b9c5d4; border-radius: 6px; background: var(--white); }

/* Small multiples */
.multiples { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.multiple { margin: 0; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 12px 12px 6px; min-width: 0; }
.multiple figcaption { display: flex; justify-content: space-between; align-items: baseline; font-size: .9rem; margin-bottom: 4px; }
.multiple figcaption span { color: var(--muted); }

/* Tables */
details.table-view { margin-top: 16px; }
details.table-view summary { cursor: pointer; color: var(--blue); font-weight: 600; font-size: .92rem; }
.table-scroll { overflow-x: auto; margin-top: 10px; }
table.data { border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: right; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { color: var(--muted); font-weight: 600; }
table.data tfoot td { font-weight: 700; }

/* Prose pages */
.prose { max-width: 760px; }
.prose ul { padding-left: 1.2em; }
.prose li { margin-bottom: .35em; }
.callout { background: var(--blue-wash); border-radius: 8px; padding: 18px 22px; margin: 1.4rem 0; }
.callout p { margin: 0; }

/* Buttons and form */
.btn { display: inline-block; font: 600 1rem var(--ui); text-decoration: none; cursor: pointer; padding: 12px 22px; border-radius: 6px; border: 2px solid transparent; }
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--navy); }
.form-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: clamp(28px, 5vw, 56px); align-items: start; }
.form { display: grid; gap: 16px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: clamp(18px, 3vw, 28px); min-width: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: .93rem; min-width: 0; }
.form input, .form textarea { font: 1rem var(--ui); color: var(--ink); width: 100%; min-width: 0; padding: 10px 12px; border: 1px solid #b9c5d4; border-radius: 6px; background: var(--paper); }
.form textarea { min-height: 120px; resize: vertical; }
.form .btn { justify-self: start; }
.hp { position: absolute; left: -9999px; }

/* Footer */
.site-footer { background: var(--navy-deep); color: #b6c3d4; padding-block: 32px; font-size: .9rem; }
.site-footer p { margin: 0 0 .5em; }
.site-footer a { color: #e2eaf5; }
.footer-name { color: var(--white); font-weight: 600; }

@media (max-width: 900px) {
  .links { grid-template-columns: 1fr 1fr; }
  .multiples { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding-inline: 16px; }
  .stats, .links { grid-template-columns: 1fr; }
  .stats { margin-top: -28px; }
  .multiples { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .lookup { height: 720px; }
}
