/* ==========================================================================
   India Air Quality — projects/air-quality/
   Design rules: no containers, hairlines only; colour is reserved for data;
   every number carries its own yardstick; one screen, no scrolling.
   ========================================================================== */

.page-aq .site-header { position: static; box-shadow: none; }

.aq {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.aq [hidden] { display: none !important; }
.aq-note { font-size: 0.85rem; color: var(--color-muted); }

/* --- Head: title and the data's own timestamp, nothing else --- */
.aq-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.aq-head h1 { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.01em; }
/* Freshness belongs with the time controls, not beside the title. */
.aq-stamp { font-size: 0.7rem; color: var(--color-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.aq-stamp.is-stale { color: #b45309; }

/* --- Pollutant strip: selector and comparison in one --- */
.aq-pollutants {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}
.aq-pol {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  text-align: left;
  border-right: 1px solid var(--color-border);
  border-top: 2px solid transparent;
  color: var(--color-muted);
  transition: background var(--transition), color var(--transition);
}
.aq-pol:last-child { border-right: none; }
.aq-pol:hover { background: var(--color-bg-light); }
.aq-pol.is-on { color: var(--color-text); border-top-color: var(--color-accent); }
.aq-pol-name { font-size: 0.74rem; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
/* Empty until a city is picked; once filled it carries the line, not a grey box. */
.aq-pol-spark { display: block; width: 100%; height: 18px; border-radius: 2px; }
.aq-pol-spark svg { display: block; }
.aq-pol-val { font-size: 0.8rem; font-weight: 600; font-variant-numeric: tabular-nums; min-height: 1.1em; }
/* A mean made of three days, or of two monitors, is drawn faint. The band
   colour stays — it is still the reading — and the line above it stays at full
   strength, because the little of it there is is the point. */
.aq-pol.is-thin .aq-pol-val { opacity: 0.45; }

/* --- Main: map and rail --- */
.aq-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 248px;
  gap: 20px;
  align-items: stretch;
}

.aq-stage { position: relative; display: flex; flex-direction: column; min-height: 400px; height: calc(100vh - 340px); }
.aq-map { flex: 1; min-height: 0; background: #fbfdff; border-radius: var(--radius-sm); }
/* while space is held the map takes the wheel, so say so */
body.aq-zooming .aq-map { cursor: zoom-in; }

/* level switch sits on the map, not above it, to save a row */
.aq-levels { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; }
.aq-levels button {
  font-size: 0.74rem;
  font-weight: 500;
  padding: 4px 10px;
  color: var(--color-muted);
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--color-border);
  border-right: none;
}
.aq-levels button:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.aq-levels button:last-child { border-right: 1px solid var(--color-border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.aq-levels button:hover { color: var(--color-text); }
.aq-levels button.is-on { color: var(--color-text); background: #fff; font-weight: 600; box-shadow: inset 0 -2px 0 var(--color-accent); }

.aq-scale { height: 20px; margin-top: 6px; }

/* Breadcrumb is also the way back out, so the map needs no reset button. */
.aq-crumb { position: absolute; top: 8px; right: 8px; z-index: 2; display: flex; align-items: center; gap: 5px; font-size: 0.74rem; }
.aq-crumb:empty { display: none; }
.aq-crumb button { color: var(--color-muted); padding: 4px 8px; background: rgba(255,255,255,0.92); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.aq-crumb button:hover { color: var(--color-text); border-color: var(--color-accent); }
.aq-crumb span { color: var(--color-border); }
.aq-crumb i { font-style: normal; font-weight: 500; color: var(--color-muted); padding: 4px 8px; background: rgba(255,255,255,0.92); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.aq-crumb b, .aq-crumb .aq-crumb-here { font-weight: 600; color: var(--color-text); padding: 4px 8px; background: rgba(255,255,255,0.92); border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.aq-crumb .aq-crumb-here:hover { border-color: var(--color-accent); }
/* One line, however deep the trail. A four-part chain used to wrap into a
   three-row slab across the top of the map on a phone. */
/* Shrink only when there is no room. A fixed character cap cut a quarter of
   the state names short on a desktop with most of the map still empty, and cut
   the two longest ones to the same prefix. */
.aq-crumb { max-width: calc(100% - 16px); }
.aq-crumb button, .aq-crumb i, .aq-crumb b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* The way home never shrinks. "I…" is no use to anybody, and it is five
   characters — whatever is crowding the trail, it is not this. */
.aq-crumb > button:first-child { flex: none; }
/* Where you are gets the next call on the space, and the step between gives way
   first, since the rail says the state anyway. */
.aq-crumb > [aria-current] { flex: 0 1 auto; min-width: 5ch; }
@media (max-width: 560px) {
  /* The frame is the least of the three things here, and the first to go —
     chevron included, or it points at nothing. And the trail stops short of the
     level tabs rather than being painted over them. */
  .aq-crumb { max-width: calc(100% - 170px); }
  .aq-crumb .aq-crumb-frame { display: none; }
  .aq-crumb button, .aq-crumb i, .aq-crumb b { padding: 3px 6px; }
}
/* Said to a screen reader, where weight and colour say nothing. */
.aq-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Shown once, then it gets out of the way for good after the first zoom. */
.aq-hint { position: absolute; right: 10px; bottom: 30px; font-size: 0.7rem; color: var(--color-muted); pointer-events: none; }
/* The same slot carries the reason the map is blank, which is worth reading. */
.aq-hint.is-empty { color: var(--color-text, #0f172a); font-weight: 500; }
/* ...and the reason it is nearly blank, which is easier to miss. */
.aq-hint.is-thin { color: #b45309; font-weight: 500; }

/* --- Rail: the number, its yardstick, its evidence, then the cycles --- */
.aq-rail { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.aq-find { position: relative; }
.aq-find input {
  width: 100%;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.8rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.aq-find input:focus { outline: none; border-color: var(--color-accent); }
.aq-find input::placeholder { color: var(--color-muted); }
.aq-find-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 210px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.aq-find-list li {
  padding: 5px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.aq-find-list li small { color: var(--color-muted); }
.aq-find-list li[aria-selected="true"], .aq-find-list li:hover { background: var(--color-bg-light); }

.aq-place { font-size: 0.95rem; font-weight: 600; line-height: 1.25; }
.aq-where { font-size: 0.74rem; color: var(--color-muted); margin-top: -10px; min-height: 1em; }
.aq-reading { display: flex; align-items: baseline; gap: 5px; }
.aq-num { font-size: 2rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.aq-unit { font-size: 0.78rem; color: var(--color-muted); }
.aq-versus { font-size: 0.82rem; font-weight: 600; margin-top: -6px; min-height: 1.1em; }
/* Where the reading sits against the standard, without a sentence explaining it. */
.aq-gauge { height: 30px; margin-top: -4px; }
.aq-gauge svg { display: block; }

/* A headline resting on very little is not withdrawn — it is still the best
   figure there is — but it stops being said in the same voice as a month of
   four hundred monitors. The stat row underneath carries the reason. */
.aq-rail.is-thin .aq-num { color: var(--color-muted); }
.aq-rail.is-thin .aq-versus { opacity: 0.5; }

/* Figures sit in an aligned row, not a sentence. */
.aq-stats { display: flex; gap: 18px; flex-wrap: wrap; }
.aq-stat b { display: block; font-size: 1rem; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.aq-stat i {
  display: block;
  font-style: normal;
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-muted);
  white-space: nowrap;
}
/* The figure that made the headline cautious, named by colour rather than by a
   sentence about it. Same amber the timestamp uses when the feed has stalled. */
.aq-stat.is-thin b, .aq-stat.is-thin i { color: #b45309; }

.aq-block { display: flex; flex-direction: column; gap: 5px; }
.aq-block-label {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.aq-cycle { height: 104px; }
.aq-exceed { height: 46px; }
.aq-cycle svg, .aq-exceed svg { display: block; }

/* --- Time strip: instant, history and range in one control --- */
.aq-time {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--color-border);
  padding-top: 10px;
}
.aq-step {
  font-size: 0.62rem;
  color: var(--color-muted);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.aq-step:hover { color: var(--color-text); background: var(--color-bg-light); }
/* The play control stands apart from the grey step arrows beside it. */
.aq-play { color: var(--color-accent); font-size: 0.72rem; }
.aq-play.is-playing { color: var(--color-accent); }
.aq-strip { flex: 1; height: 34px; background: var(--color-bg-light); border-radius: 2px; min-width: 0; }
.aq-strip svg { display: block; }
/* Appears only while a past day is pinned, and is the way back to the latest reading. */
.aq-clear { color: var(--color-muted); padding: 0 4px; font-size: 0.85rem; line-height: 1; }
.aq-clear:hover { color: var(--color-text); }
.aq-when { font-size: 0.76rem; font-variant-numeric: tabular-nums; color: var(--color-text); white-space: nowrap; }

/* --- Actions: exactly two --- */
.aq-actions { display: flex; gap: 8px; }
.aq-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  background: var(--color-bg);
  transition: border-color var(--transition), background var(--transition);
}
.aq-btn:hover { border-color: var(--color-accent); background: var(--color-bg-light); }
.aq-btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
.aq-btn-primary:hover { background: var(--color-primary-light); border-color: var(--color-primary-light); color: #fff; }
/* Not-yet-wired controls read as inactive rather than inviting a dead click. */
.aq-btn:disabled, .aq-levels button:disabled, .aq-panel-tabs button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}
.aq-btn[aria-expanded="true"] { border-color: var(--color-accent); background: var(--color-bg-light); }
.aq :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* --- Chart panel: on demand --- */
.aq-panel { border-top: 1px solid var(--color-border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.aq-panel-tabs { display: flex; gap: 14px; }
.aq-panel-tabs button { font-size: 0.74rem; font-weight: 500; color: var(--color-muted); padding-bottom: 3px; border-bottom: 2px solid transparent; }
.aq-panel-tabs button.is-on { color: var(--color-text); border-bottom-color: var(--color-accent); }
.aq-chart { height: 240px; }
.aq-chart svg { display: block; }
.aq-brush .selection { fill: var(--color-primary); fill-opacity: 0.1; stroke: var(--color-primary); stroke-opacity: 0.35; }

/* --- Tooltip: detail on demand, so the resting map stays quiet --- */
.aq-tip {
  position: fixed;
  z-index: 60;
  display: none;
  pointer-events: none;
  transform: translate(12px, -50%);
  max-width: 230px;
  padding: 6px 9px;
  font-size: 0.75rem;
  line-height: 1.45;
  color: #fff;
  background: rgba(15, 23, 42, 0.93);
  border-radius: var(--radius-sm);
}
/* Stacked lines, so a reading never becomes a run-on string. */
.aq-tip b { display: block; font-weight: 600; font-size: 0.8rem; }
.aq-tip i { display: block; font-style: normal; font-size: 0.68rem; color: rgba(255,255,255,0.62); }
.aq-tip u { display: block; margin-top: 3px; text-decoration: none; font-size: 0.95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.aq-tip u s { text-decoration: none; font-size: 0.66rem; font-weight: 400; color: rgba(255,255,255,0.62); }
.aq-tip em { display: block; font-style: normal; font-size: 0.7rem; font-weight: 600; }

.aq-map svg { display: block; }

/* --- Responsive --- */
@media (max-width: 900px) {
  .aq-main { grid-template-columns: minmax(0, 1fr); }
  .aq-stage { height: 56vh; min-height: 320px; }
  .aq-rail { flex-direction: row; flex-wrap: wrap; gap: 16px 24px; }
  .aq-rail > .aq-block { flex: 1 1 200px; }
}
@media (max-width: 560px) {
  .aq { padding: 12px 16px 20px; }
  .aq-pollutants { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .aq-pol:nth-child(3) { border-right: none; }
  .aq-pol:nth-child(-n+3) { border-bottom: 1px solid var(--color-border); }
  .aq-head h1 { font-size: 1.2rem; }
  .aq-actions .aq-btn { flex: 1; }
}


/* --- Download dialog --- */
.aq-dl {
  /* The global reset zeroes margin on everything, which also kills the margin:auto
     a native modal relies on to centre itself — it was sitting against the left edge. */
  margin: auto;
  width: min(400px, calc(100vw - 28px));
  max-height: calc(100vh - 40px);
  padding: 0;
  overflow: hidden;                     /* nothing may push the dialog sideways */
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 12px 44px rgba(15, 23, 42, 0.2);
  color: var(--color-text);
}
.aq-dl::backdrop { background: rgba(15, 23, 42, 0.4); }
.aq-dl-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px 18px 18px;
  min-width: 0;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.aq-dl-head { display: flex; align-items: center; justify-content: space-between; }
.aq-dl-head h2 { font-size: 1rem; font-weight: 600; }
.aq-dl-x { font-size: 1.35rem; line-height: 1; color: var(--color-muted); padding: 0 4px; }
.aq-dl-x:hover { color: var(--color-text); }

.aq-dl-scope { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-width: 0; }
.aq-dl-scope button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  font-size: 0.82rem;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  background: var(--color-bg);
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.aq-dl-scope button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aq-dl-scope button:hover { border-color: var(--color-accent); color: var(--color-text); }
.aq-dl-scope button.is-on {
  border-color: var(--color-primary);
  background: var(--color-bg-light);
  color: var(--color-text);
  font-weight: 500;
}

.aq-dl-pick { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.aq-dl-pick input[type="search"] {
  width: 100%;
  min-width: 0;
  font-family: inherit;
  font-size: 0.82rem;
  padding: 7px 9px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.aq-dl-pick input:focus { outline: none; border-color: var(--color-accent); }

/* A list we control, so a long monitor name cannot widen the dialog. */
.aq-dl-list {
  min-width: 0;
  max-height: 168px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.aq-dl-list button {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-width: 0;
  padding: 6px 9px;
  font-size: 0.8rem;
  text-align: left;
  color: var(--color-text);
  background: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aq-dl-list button:hover { background: var(--color-bg-light); }
.aq-dl-list button.is-on { background: var(--color-bg-light); font-weight: 600; box-shadow: inset 2px 0 0 var(--color-primary); }
.aq-dl-list button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* An empty box until it is picked, then a tick. No count to read. */
.aq-dl-tick {
  flex: none;
  width: 13px;
  height: 13px;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  position: relative;
}
.aq-dl-list button.is-on .aq-dl-tick { background: var(--color-primary); border-color: var(--color-primary); }
.aq-dl-list button.is-on .aq-dl-tick::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 3px;
  height: 7px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(45deg);
}
.aq-dl-list .aq-dl-sep { border-top: 1px solid var(--color-border); }
.aq-dl-list .aq-dl-none { padding: 8px 9px; font-size: 0.78rem; color: var(--color-muted); }

.aq-dl-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.aq-dl-label {
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
}
.aq-dl-rows { display: flex; gap: 6px; min-width: 0; }
.aq-dl-rows button {
  flex: 1;
  min-width: 0;
  padding: 7px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-muted);
  background: var(--color-bg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aq-dl-rows button:hover { border-color: var(--color-accent); color: var(--color-text); }
.aq-dl-rows button.is-on {
  border-color: var(--color-primary);
  background: var(--color-bg-light);
  color: var(--color-text);
  font-weight: 500;
}

.aq-dl-dates { display: flex; gap: 8px; min-width: 0; }
.aq-dl-dates input[type="date"] {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 8px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}
.aq-dl-actions { display: flex; justify-content: flex-end; gap: 8px; }
.aq-dl-actions .aq-btn { justify-content: center; }
.aq-dl :focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .aq-head { flex-wrap: wrap; gap: 8px; }
  .aq-dl-dates { flex-direction: column; }
}

/* --- Icons: one stroke weight everywhere, inheriting colour --- */
.aq-ico {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.aq-btn { display: inline-flex; align-items: center; gap: 7px; }
