/* ==========================================================================
   Keep Spicewood Strong — page layout.
   Consumes tokens from theme.css. MOBILE FIRST: every base rule targets the
   small screen, and breakpoints only ever ADD. Most families will only ever
   see this on a phone.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* `hidden` must win over any display rule below, or conditional sections
   (Today's Bonus) leak onto the page when they have nothing to say. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  /* Nothing may cause sideways scroll on a phone. */
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; }

.ks-skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ks-yellow);
  color: var(--ks-ink);
  border: var(--ks-outline) solid var(--ks-ink);
  padding: .6rem 1rem;
  z-index: 100;
}
.ks-skip:focus { left: .5rem; top: .5rem; }

/* --- Masthead ------------------------------------------------------------ */
.ks-masthead {
  background-color: var(--ks-blue);
  border-bottom: var(--ks-outline) solid var(--ks-ink);
  padding-block: 1rem;
  /* Respect notched phones. */
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
}
.ks-masthead__inner { display: grid; gap: .75rem; }

.ks-brand {
  display: grid;
  justify-items: center;
  text-decoration: none;
  line-height: .85;
}
.ks-brand__kicker {
  font-family: var(--ks-font-head);
  font-size: clamp(1rem, .7rem + 1.6vw, 1.6rem);
  text-transform: uppercase;
  color: var(--ks-paper);
  -webkit-text-stroke: 1.5px var(--ks-ink);
  paint-order: stroke fill;
  transform: skewX(-8deg);
}
.ks-brand__kicker--end { align-self: start; }

.ks-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem .75rem;
}
.ks-nav a {
  font-family: var(--ks-font-head);
  text-transform: uppercase;
  font-size: var(--ks-step--1);
  letter-spacing: .03em;
  color: var(--ks-paper);
  text-decoration: none;
  background: var(--ks-ink);
  border-radius: 999px;
  /* 44px minimum touch target — thumbs, not cursors. */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 .9rem;
}
.ks-nav a:hover { background: var(--ks-red); }

/* --- Hero ---------------------------------------------------------------- */
.ks-hero { padding-block: clamp(1.25rem, .8rem + 2vw, 2.5rem); display: grid; gap: 1.25rem; }

.ks-tagline {
  font-family: var(--ks-font-display);
  font-size: var(--ks-step-2);
  letter-spacing: .05em;
  text-align: center;
  margin: 0;
  color: var(--ks-red);
}

.ks-hero__goal { display: grid; gap: .75rem; }
.ks-hero__amount { font-family: var(--ks-font-head); font-size: var(--ks-step-2); margin: 0; }
.ks-hero__next { margin: 0; font-weight: 700; }
.ks-fineprint { font-size: var(--ks-step--1); color: var(--ks-muted); margin: 0; }

.ks-hero .ks-btn { justify-content: center; min-height: 52px; }

/* Full-width give button on phones; content-width once there's room. */
@media (min-width: 34rem) {
  .ks-hero .ks-btn { justify-self: start; }
}

.ks-bonus { display: grid; justify-items: center; gap: .5rem; text-align: center; }
.ks-bonus p { font-weight: 700; margin: 0; }

/* --- Sections ------------------------------------------------------------ */
.ks-section { padding-block: clamp(1.5rem, 1rem + 2.5vw, 3rem); display: grid; gap: 1rem; }
.ks-lede { margin: 0; max-width: 60ch; }

.ks-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--ks-gap);
  /* One column on a phone. */
  grid-template-columns: 1fr;
}
@media (min-width: 40rem) { .ks-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 64rem) { .ks-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 40rem) { .ks-grid--tight { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 56rem) { .ks-grid--tight { grid-template-columns: repeat(3, 1fr); } }

.ks-card { display: grid; gap: .6rem; align-content: start; }
.ks-card__title { font-family: var(--ks-font-head); font-size: var(--ks-step-1); text-transform: uppercase; margin: 0; line-height: 1; }
.ks-card__blurb { margin: 0; }
.ks-card .ks-btn { justify-content: center; min-height: 48px; font-size: var(--ks-step-0); }

.ks-empty { color: var(--ks-muted); text-align: center; }

.ks-trophy { display: grid; gap: .4rem; text-align: center; }
.ks-trophy__emoji { font-size: 2.5rem; line-height: 1; }
.ks-trophy__name { font-family: var(--ks-font-head); text-transform: uppercase; font-size: var(--ks-step-1); margin: 0; }
.ks-trophy__criteria { margin: 0; font-size: var(--ks-step--1); }
.ks-trophy__holder { font-weight: 900; }

.ks-promise { text-align: center; }
.ks-promise p { margin: .5rem 0 0; max-width: 55ch; margin-inline: auto; }

/* --- Footer -------------------------------------------------------------- */
.ks-footer {
  background-color: var(--ks-yellow);
  border-top: var(--ks-outline) solid var(--ks-ink);
  padding-block: 1.5rem;
  margin-top: 2rem;
  text-align: center;
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}
.ks-footer p { margin: .25rem 0; }

/* --- Wider screens: masthead becomes a single row ------------------------ */
@media (min-width: 52rem) {
  .ks-masthead__inner {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 1.5rem;
  }
  .ks-brand { justify-items: start; }
  .ks-nav { justify-content: flex-end; }
}

/* --- The creed ------------------------------------------------------------
   The emotional close of the page. Three parts, then the chain that ties them.

   Colour is carried by the top rule of each panel, never by the heading text:
   panther blue (#25A3E0) on white measures 2.84:1, below the WCAG AA minimum,
   so headings stay ink black and the brand colour lives where contrast can't
   be harmed. */
.ks-creed { text-align: center; }
.ks-creed > .ks-h2 { justify-self: center; }
.ks-creed__list { margin-top: .5rem; text-align: left; }

.ks-creed__item { border-top-width: 12px; }
.ks-creed__item--1 { border-top-color: var(--ks-red); }
.ks-creed__item--2 { border-top-color: var(--ks-blue); }
.ks-creed__item--3 { border-top-color: var(--ks-yellow); }

.ks-creed__title {
  font-family: var(--ks-font-head);
  font-size: var(--ks-step-1);
  text-transform: uppercase;
  line-height: 1;
  margin: 0 0 .5rem;
  color: var(--ks-ink);
}
.ks-creed__body { margin: 0; }

/* The payoff line. Reads as a comic caption, not a footnote. */
.ks-creed__chain {
  font-family: var(--ks-font-display);
  font-size: var(--ks-step-2);
  letter-spacing: .03em;
  line-height: 1.15;
  color: var(--ks-ink);
  background: var(--ks-yellow);
  border: var(--ks-outline) solid var(--ks-ink);
  border-radius: var(--ks-radius);
  box-shadow: var(--ks-shadow-pop);
  margin: .5rem 0 0;
  padding: .7em 1em;
  /* Keep the three clauses together on a phone rather than orphaning a word. */
  text-wrap: balance;
}

/* --- Current page in nav -------------------------------------------------- */
.ks-nav a.is-current { background: var(--ks-red); }

/* --- Hero meter ----------------------------------------------------------- */
.ks-meter--hero { height: 44px; }

/* --- Grade meters ---------------------------------------------------------
   One row per grade, all tracks sharing a left edge and a 0–100% scale, so
   grades are comparable at a glance. Separate thermometers per grade would
   look festive and compare badly. Length carries the value; every bar is the
   same colour because this is one series, not six. */
.ks-grades { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }

.ks-grade {
  display: grid;
  grid-template-columns: minmax(4.5rem, auto) 1fr minmax(2.75rem, auto);
  align-items: center;
  gap: .6rem;
}
.ks-grade__label {
  font-family: var(--ks-font-head);
  text-transform: uppercase;
  font-size: var(--ks-step--1);
  line-height: 1.1;
}
.ks-grade__track {
  position: relative;
  height: 22px;
  background: var(--ks-paper);
  border: 2px solid var(--ks-ink);
  border-radius: 999px;
  overflow: hidden;
}
.ks-grade__fill {
  display: block;
  height: 100%;
  background: var(--ks-red);
  border-radius: 999px 0 0 999px;
  transition: width .6s cubic-bezier(.22,1,.36,1);
}
/* Reference line for the participation goal — the target, not a data mark. */
.ks-grade__goal {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--ks-ink);
  opacity: .45;
  z-index: 1;
}
.ks-grade__value {
  font-family: var(--ks-font-head);
  font-size: var(--ks-step--1);
  text-align: right;
}
.ks-grade--key .ks-grade__track { border-color: transparent; background: none; height: 14px; }
.ks-grade--key .ks-grade__value { opacity: .7; font-family: var(--ks-font-body); font-weight: 700; }

/* --- Stat tiles ----------------------------------------------------------- */
.ks-stats {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: .75rem;
  grid-template-columns: repeat(2, 1fr);
}
.ks-stat {
  border: var(--ks-outline) solid var(--ks-ink);
  border-radius: var(--ks-radius);
  box-shadow: var(--ks-shadow-pop-sm);
  background: var(--ks-paper);
  padding: .75rem 1rem;
  display: grid;
  gap: .1rem;
}
.ks-stat__value { font-family: var(--ks-font-head); font-size: var(--ks-step-2); line-height: 1; }
.ks-stat__label { font-size: var(--ks-step--1); text-transform: uppercase; letter-spacing: .03em; }

/* --- Reach map ------------------------------------------------------------
   Tile grid rather than a projection: legible at 320px, and every state gets
   equal weight, which is the point — a donor in Rhode Island counts as much
   as one in Texas. */
.ks-map-figure { margin: 0; display: grid; gap: .6rem; }
.ks-map { display: grid; gap: 2px; }
.ks-map__row { display: grid; grid-template-columns: repeat(11, 1fr); gap: 2px; }

.ks-map__tile,
.ks-map__gap { aspect-ratio: 1; border-radius: 3px; }

.ks-map__tile {
  display: grid;
  place-items: center;
  /* 2px surface gap between fills comes from the grid gap above. */
  background: #E9E9E9;
  color: #5A5A5A;
  border: 1px solid rgba(0,0,0,.12);
  font-family: var(--ks-font-body);
  font-weight: 900;
  font-size: clamp(7px, 2vw, 12px);
  letter-spacing: 0;
  text-decoration: none;
  cursor: default;
}
.ks-map__tile.is-reached { border-color: rgba(0,0,0,.35); }
.ks-map__gap { background: none; }

.ks-map-legend {
  display: flex; flex-wrap: wrap; gap: .35rem .9rem;
  font-size: var(--ks-step--1);
}
.ks-legend__item { display: inline-flex; align-items: center; gap: .35rem; }
.ks-legend__swatch {
  width: 14px; height: 14px; border-radius: 3px;
  border: 1px solid rgba(0,0,0,.3);
}

/* --- Table view (accessibility relief for the map) ------------------------ */
.ks-table-toggle summary {
  cursor: pointer;
  font-weight: 700;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.ks-table-scroll { overflow-x: auto; }
.ks-table { border-collapse: collapse; width: 100%; font-size: var(--ks-step--1); }
.ks-table caption { text-align: left; padding-bottom: .4rem; font-weight: 700; }
.ks-table th, .ks-table td {
  border: 1px solid var(--ks-ink);
  padding: .35rem .6rem;
  text-align: left;
}
.ks-table th { background: var(--ks-yellow); }

/* --- FAQ ------------------------------------------------------------------ */
.ks-faq { margin: 0; display: grid; gap: .35rem; }
.ks-faq dt {
  font-family: var(--ks-font-head);
  text-transform: uppercase;
  font-size: var(--ks-step-1);
  line-height: 1.05;
  margin-top: 1rem;
}
.ks-faq dd { margin: 0; max-width: 62ch; }

@media (min-width: 40rem) {
  .ks-stats { grid-template-columns: repeat(3, 1fr); }
  .ks-map { max-width: 46rem; }
}

/* Standalone navigational links are real tap targets, unlike links inline in a
   sentence (which WCAG 2.5.8 exempts). */
.ks-btn--sm {
  font-size: var(--ks-step-0);
  min-height: 44px;
  justify-self: start;
}

/* --- Texas ZIP map --------------------------------------------------------
   County outlines give the shape that makes Texas recognisable; donor ZIPs sit
   on top as proportional circles. Circle AREA scales with donor count, so four
   donors read as four times the ink — not sixteen. */
.ks-txmap svg { display: block; width: 100%; height: auto; }

.ks-txmap__counties path {
  fill: #EFEFEF;
  stroke: var(--ks-paper);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.ks-txmap__dot {
  fill: var(--ks-blue-deep);
  fill-opacity: .78;
  /* Surface-coloured ring keeps overlapping dots readable where donors cluster. */
  stroke: var(--ks-paper);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.ks-txmap__school path {
  fill: var(--ks-red);
  stroke: var(--ks-paper);
  stroke-width: 3.5;
  paint-order: stroke fill;
  vector-effect: non-scaling-stroke;
  /* A hard outer edge keeps the landmark legible even sitting on top of a
     dense cluster of donor dots. */
  filter: drop-shadow(0 0 1.5px rgba(0,0,0,.85));
}

.ks-map-figure > .ks-h3 { margin: 0 0 .5rem; }

.ks-legend__dot, .ks-legend__school { flex: none; overflow: visible; }
.ks-map-legend .ks-legend__item { align-items: center; }
.ks-legend__dot circle { fill: var(--ks-blue-deep); fill-opacity: .78; stroke: var(--ks-paper); stroke-width: 2; }
.ks-legend__school path { fill: var(--ks-red); stroke: var(--ks-ink); stroke-width: 2; }

@media (min-width: 40rem) {
  .ks-txmap svg { max-width: 42rem; }
}
