/* style.css — layout + map chrome. Mobile-first; tested down to 320px. */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  font-family: "Grot 10", Helvetica, Arial, sans-serif;
  color: #333;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}

#statusbar {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px 11px;
  background: #fff;
  color: #333;
  border-bottom: 1px solid #e6e6e6;
}

#statusbar h1 {
  margin: 0;
  font-family: "Inquirer Headline", Georgia, "Times New Roman", serif;
  font-size: 36px;
  font-weight: 600;
  line-height: 1.2;
  color: #222;
}

.subtitle {
  margin: 3px 0 0;
  font-size: 16px;
  color: #6a6a6a;
}

.meta {
  text-align: left;
  font-size: 0.7rem;
  color: #8a8a8a;
  line-height: 1.4;
}

.meta #updated {
  display: block;
  color: #6a6a6a;
  font-variant-numeric: tabular-nums;
}

#sample-banner {
  display: none;
  padding: 6px 14px;
  background: #ffe8a3;
  color: #5a4300;
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid #e6cf7a;
}

#map {
  /* Fixed 600px map depth. A pixel height (not flex:1 + a viewport unit) keeps
     document.body.scrollHeight deterministic, so the iframe resizer can't feed
     the grow-forever loop that a 100vh body did. The container (body) then
     sizes to its content: header + this map + legend + footer. */
  flex: none;
  height: 600px;
  width: 100%;
}

/* --- Footer (sources + required disclaimers) ----------------------------- */

#page-footer {
  padding: 11px 14px 16px;
  background: #fff;
  color: #8a8a8a;
  font-size: 16px;
  line-height: 1.5;
  border-top: 1px solid #e6e6e6;
}

#page-footer a {
  color: #555;
}

/* Source + notes: slightly smaller than the 16px body/credit text. */
#page-footer p {
  margin: 0 0 6px;
  max-width: 80ch;
  font-size: 14px;
}

/* Byline credit — matches preview.html's .dw-credit: body-size, not bold. */
#page-footer .footer-credit {
  color: #6a6a6a;
  font-size: 16px;
  font-weight: 400;
}

/* --- Legend --------------------------------------------------------------- */

/* Horizontal legend strip below the map (freed from the map canvas). */
#legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 18px;
  padding: 10px 14px;
  background: #fff;
  border-top: 1px solid #e6e6e6;
  font-size: 0.7rem;
  color: #333;
}

.lg-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 9px;
}

.lg-label {
  font-weight: 700;
  color: #556;
}

.lg-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.3);
  flex: none;
}

.swatch-dot {
  border-radius: 50%;
  background: #9e9e9e;
}

.swatch-diamond {
  transform: rotate(45deg);
  background: #9e9e9e;
  width: 10px;
  height: 10px;
}

/* PurpleAir map markers: diamonds, distinct from the round AirNow monitors. */
.pa-marker {
  background: none;
  border: none;
}

.pa-diamond {
  display: block;
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border: 1.5px solid #111;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.pa-tag {
  font-size: 0.6rem;
  background: #7a3fa6;
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
}

/* Interpolated surface sits above the basemap but must not block map clicks. */
.pm25-surface {
  pointer-events: none;
}

/* --- Popups --------------------------------------------------------------- */

.muted {
  color: #667;
  font-size: 0.92em;
}

.aqi-chip {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 700;
  color: #111;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.6);
}

/* Unhealthy and up: the category colors are dark (red/purple/maroon), so black
   text is hard to read. Flip to white with a dark shadow for legibility. */
.aqi-chip--light {
  color: #fff;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.55);
}

.leaflet-popup-content {
  font-size: 0.8rem;
  line-height: 1.45;
}

.spark-title {
  margin: 8px 0 2px;
  font-size: 0.66rem;
  font-weight: 600;
  color: #667;
}

.aqi-pop svg {
  display: block;
}

/* Target embed width is 365–560px: stack the header, shrink the legend. */
@media (max-width: 600px) {
  #statusbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 8px 12px;
  }
  /* Mobile embed: drop the 36px headline to 20px so it doesn't wrap to a wall
     of type on a ~365px frame; the description stays at 16px. */
  #statusbar h1 {
    font-size: 20px;
  }
  .subtitle {
    font-size: 16px;
  }
  .meta {
    text-align: left;
    font-size: 0.67rem;
  }
  #legend {
    font-size: 0.66rem;
    padding: 8px 12px;
    gap: 5px 12px;
  }
  .hist-head h2 {
    font-size: 0.92rem;
  }
  #legend,
  #history-panel,
  #page-footer {
    padding-left: 12px;
    padding-right: 12px;
  }
}
