/* Childhood Homelessness by Legislative District — Family Promise of Hawaiʻi */

:root {
  --fp-blue: #0063be;
  --fp-deep-blue: #004477;
  --fp-gold: #fec357;
  --fp-dark-gold: #f6a03b;
  --fp-gold-ink: #b06a10;      /* darkened gold for small text/strokes */
  --fp-purple: #8d4982;
  --fp-dark-purple: #472d5b;
  --ink: #1c2b39;
  --ink-2: #51616f;
  --ink-3: #7d8b98;
  --line: #e3e9ee;
  --card: #ffffff;
  --bg: #eef2f5;
  --radius: 14px;
  --shadow: 0 2px 6px rgba(0, 42, 78, .08), 0 12px 32px rgba(0, 42, 78, .12);
  --font: "omnes-variable", "Verdana", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  font-variation-settings: "wdth" 100, "wght" 500;
  color: var(--ink);
  background: var(--bg);
}

#map {
  position: fixed;
  inset: 0;
  background: #dfe8ee;
  z-index: 0;
}

/* ---------- Floating panel ---------- */

.panel {
  position: fixed;
  top: 16px;
  left: 16px;
  bottom: 16px;
  width: min(420px, calc(100vw - 32px));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel-header {
  padding: 22px 22px 6px;
}

.logo {
  display: block;
  width: 187px;
  height: auto;
  margin: 2px 0 12px;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  color: var(--fp-deep-blue);
  font-variation-settings: "wdth" 100, "wght" 680;
}

/* ---------- Controls ---------- */

.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 10px;
  padding: 14px 22px 4px;
}

.control-label {
  display: block;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 4px;
  font-variation-settings: "wdth" 100, "wght" 620;
}

select {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 9px 30px 9px 12px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2351616f' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
select:focus-visible { outline: 2px solid var(--fp-blue); outline-offset: 1px; }

.layer-toggles[hidden], .toggle[hidden] { display: none; }

.layer-toggles {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 22px 2px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.toggle input { accent-color: var(--fp-blue); margin: 0; }

.swatch {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.swatch-doe {
  background: linear-gradient(90deg, #fdeccb, #fdc45f, #ee8f24, #a85608);
  border: 1px solid var(--fp-gold-ink);
}
.swatch-fph { background: rgba(141, 73, 130, .14); border: 1.5px dashed var(--fp-purple); }

/* ---------- Content / cards ---------- */

#content { padding: 10px 22px 6px; }

.section-header { margin: 18px 0 4px; }
.section-header:first-child { margin-top: 6px; }

/* Headline strip: one tile per data source */
.glance {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.glance:has(> :last-child:nth-child(2)) { grid-template-columns: repeat(2, 1fr); }

.tile {
  display: block;
  text-align: left;
  font: inherit;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 9px 10px 8px;
  cursor: pointer;
}
.tile:hover { border-color: #c4d2dd; background: #fafcfd; }
.tile::before { height: 3px; width: 18px; margin-bottom: 7px; }
.tile-pit::before { background: var(--fp-blue); }
.tile-doe::before { background: linear-gradient(90deg, var(--fp-gold), var(--fp-dark-gold)); }
.tile-fph::before { background: var(--fp-purple); }
.tile .v {
  display: block;
  font-size: 21px;
  line-height: 1.05;
  color: var(--fp-deep-blue);
  font-variation-settings: "wdth" 100, "wght" 700;
  font-variant-numeric: tabular-nums;
}
.tile .l {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  line-height: 1.3;
  color: var(--ink-2);
}

/* Loading state + action buttons */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 26px 2px;
  font-size: 14px;
  color: var(--ink-2);
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--fp-blue);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.action-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 22px 0;
}
.action-row[hidden] { display: none; }
.action-btn {
  font: inherit;
  font-size: 12.5px;
  color: var(--fp-blue);
  font-variation-settings: "wdth" 100, "wght" 620;
  background: none;
  border: 1.5px solid var(--line);
  border-radius: 99px;
  padding: 5px 12px;
  cursor: pointer;
}
.action-btn:hover { border-color: var(--fp-blue); background: #f5f9fd; }
.action-btn[hidden] { display: none; }
.action-share { margin-left: auto; }

.glance-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--ink-3);
  text-align: right;
}

/* Point-in-time count context card: deliberately quieter than the others */
.card-pit {
  background: #f3f7fb;
  border: 1.5px solid #dde7ef;
  border-radius: 12px;
  padding: 12px 14px 10px;
  margin-top: 14px;
}
.card-pit p {
  margin: 5px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.card-pit strong {
  color: var(--fp-deep-blue);
  font-variation-settings: "wdth" 100, "wght" 700;
  font-variant-numeric: tabular-nums;
}
.card-pit .source { font-size: 11px; color: var(--ink-3); margin-top: 8px; }
.chg { white-space: nowrap; font-variation-settings: "wdth" 100, "wght" 640; }
.chg.up { color: #a13333; }
.chg.down { color: #22683a; }

.section-title {
  margin: 0;
  font-size: 16px;
  color: var(--fp-deep-blue);
  font-variation-settings: "wdth" 100, "wght" 660;
}

.section-sub {
  margin: 3px 0 0;
  font-size: 12.5px;
  color: var(--ink-3);
}

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 10px;
}

/* Short accent bar above each card's kicker — one color per data source */
.card-doe::before, .card-fph::before, .card-pit::before, .tile::before {
  content: "";
  display: block;
  height: 4px;
  width: 26px;
  border-radius: 99px;
  margin-bottom: 8px;
}
.card-doe::before { background: linear-gradient(90deg, var(--fp-gold), var(--fp-dark-gold)); }
.card-fph::before { background: var(--fp-purple); }
.card-pit::before { background: var(--fp-blue); }

.card-title {
  margin: 0 0 2px;
  font-size: 14.5px;
  color: var(--ink);
  font-variation-settings: "wdth" 100, "wght" 650;
}

.card-kicker {
  font-size: 11px;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.stat-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}

.stat .num {
  font-size: 30px;
  line-height: 1;
  color: var(--fp-deep-blue);
  font-variation-settings: "wdth" 100, "wght" 700;
  font-variant-numeric: tabular-nums;
}
.stat .lbl {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 3px;
}

.stat-secondary { text-align: right; }
.stat-secondary .num { font-size: 19px; color: var(--ink); }

.delta {
  display: inline-block;
  font-size: 12px;
  border-radius: 99px;
  padding: 2px 8px;
  margin-left: 8px;
  vertical-align: 4px;
  font-variation-settings: "wdth" 100, "wght" 620;
  background: #eef2f5;
  color: var(--ink-2);
  white-space: nowrap;
}
.delta.up   { background: #fdeaea; color: #a13333; }  /* more homelessness = adverse */
.delta.down { background: #e8f4ec; color: #22683a; }

.spark-wrap { margin-top: 10px; }
.spark { display: block; width: 100%; height: auto; }
.spark-caption {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--ink-3);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.breakdown { margin: 10px 0 0; padding: 0; list-style: none; }
.breakdown li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-2);
  padding: 3.5px 0;
  border-top: 1px dashed var(--line);
}
.breakdown li strong {
  color: var(--ink);
  font-variation-settings: "wdth" 100, "wght" 640;
  font-variant-numeric: tabular-nums;
}

.source {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--ink-3);
}

/* ZIP rows inside FPH card */
.zip-table { margin: 12px 0 0; border-top: 1px solid var(--line); }
.zip-row {
  display: grid;
  grid-template-columns: 58px 1fr 52px 52px;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.zip-row .zip {
  color: var(--fp-dark-purple);
  font-variation-settings: "wdth" 100, "wght" 650;
}
.zip-row .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }
.zip-head {
  font-size: 10.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
.zip-head .n { color: var(--ink-3); }

.note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.45;
  color: var(--ink-2);
  background: #f5f7f9;
  border-radius: 8px;
  padding: 9px 11px;
}

.empty-state { padding: 4px 0 6px; }
.empty-state .hint {
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 10px 0 0;
}

.panel-footer {
  margin-top: auto;
  padding: 14px 22px 18px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}
.panel-footer p { margin: 0 0 6px; }
.panel-footer a { color: var(--fp-blue); }

/* ---------- Map bits ---------- */

.leaflet-container { font-family: var(--font); }

.map-tip {
  font-family: var(--font);
  font-size: 12.5px;
  font-variation-settings: "wdth" 100, "wght" 600;
  color: var(--ink);
  background: #fff;
  border: none;
  box-shadow: 0 2px 10px rgba(0, 42, 78, .2);
  border-radius: 7px;
  padding: 4px 9px;
}
.map-tip::before { display: none; }

.leaflet-interactive { cursor: pointer; }
.leaflet-interactive:focus { outline: none; }
.leaflet-interactive:focus-visible { outline: 2px solid var(--fp-blue); }

.rate-legend {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 42, 78, .18);
  padding: 9px 12px 8px;
  font-size: 11px;
  color: var(--ink-2);
  max-width: 210px;
}
.rate-legend-title {
  color: var(--fp-deep-blue);
  font-size: 11.5px;
  line-height: 1.25;
  font-variation-settings: "wdth" 100, "wght" 650;
}
.rate-legend-sub { color: var(--ink-3); font-size: 10.5px; margin: 1px 0 7px; }
.rate-legend-ramp {
  display: flex;
  height: 9px;
  border-radius: 3px;
  overflow: hidden;
}
.rate-legend-ramp span { flex: 1; }
.rate-legend-ticks {
  display: flex;
  width: 75%;
  margin-top: 2px;
}
.rate-legend-ticks i {
  flex: 1;
  font-style: normal;
  font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  transform: translateX(50%);
  white-space: nowrap;
}

/* ---------- Mobile ---------- */

@media (max-width: 820px) {
  html, body { height: auto; }

  #map {
    position: sticky;
    top: 0;
    height: 46vh;
    inset: auto;
    width: 100%;
    z-index: 0;
  }

  .panel {
    position: relative;
    top: auto; left: auto; bottom: auto;
    width: auto;
    margin: -14px 10px 10px;
    max-height: none;
    overflow: visible;
    box-shadow: 0 -4px 24px rgba(0, 42, 78, .18);
  }

  h1 { font-size: 21px; }
  .panel-header { padding: 18px 18px 4px; }
  .controls, .layer-toggles, #content, .panel-footer { padding-left: 18px; padding-right: 18px; }
}
