/* Base: reset, type, the top bar, footer, forms, focus and browser surfaces. */

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

html {
  background: var(--ground);
  color: var(--ink);
  font: 400 17px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
  accent-color: var(--accent);
  caret-color: var(--accent);
  scrollbar-color: var(--line) transparent;
  /* Room for the scrollbar is kept even when the page is short, so opening the form does not
     shift the page sideways. */
  scrollbar-gutter: stable;
}
body { min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
main:focus { outline: none; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.2; text-wrap: balance; }
/* Headings: Anek set narrower and bolder, the way Indian newspapers set their heads. */
h1, h2 { font-family: var(--display); font-weight: 650; font-stretch: var(--display-stretch); letter-spacing: -0.01em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1rem; }
p, li { text-wrap: pretty; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
code, pre { font-family: var(--sans); font-size: 0.8125rem; }
.meta { font-size: 0.875rem; }

::selection { background: var(--accent); color: var(--on-accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: var(--space-3); top: -60px; z-index: 10;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  padding: var(--space-2) var(--space-3); border-radius: 8px;
}
.skip:focus { top: var(--space-3); }

/* The top bar: the wordmark, and a live status the page can stand behind. */
.bar { background: var(--bar); border-bottom: 1px solid var(--line); }
.bar-in, .foot-in {
  max-width: var(--page-max); margin: 0 auto; padding: var(--space-3) var(--gutter);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4);
}
.brand { font: 700 clamp(1.75rem, 1.2rem + 1.4vw, 2.5rem)/1 var(--display); font-stretch: var(--display-stretch); letter-spacing: -0.015em; text-decoration: none; padding: 4px 0 6px; }
.brand span { color: var(--accent); }
.live {
  display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap;
  font: 500 0.8125rem/1 var(--sans); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px 7px 10px;
}
.live b { color: var(--ink); font-weight: 600; }
/* On the narrowest phones the pill keeps only the AQI; the time is in the line below. */
@media (max-width: 379px) { .live-time { display: none; } .live { padding-inline: 10px; } }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--kind-measured); box-shadow: 0 0 0 3px color-mix(in srgb, var(--kind-measured) 28%, transparent); }

.foot { border-top: 1px solid var(--line); margin-top: var(--space-7); color: var(--muted); font-size: 0.8125rem; }
.foot-in { flex-direction: column; align-items: stretch; padding-block: var(--space-5) var(--space-6); gap: var(--space-4); }
.foot p { max-width: 72ch; }

/* Fact labels: what kind of number this is, a coloured dot and a word. */
.kind {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: 0.12em; margin-right: var(--space-1);
  font: 500 0.6875rem/1 var(--sans); letter-spacing: 0.01em; color: var(--muted); white-space: nowrap;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px 4px 7px; background: var(--panel);
}
.kind::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--kind-guidance); }
.kind-measured::before { background: var(--kind-measured); }
.kind-forecast::before { background: var(--kind-forecast); }
.kind-estimate::before { background: var(--kind-estimate); }
.kind-household::before { background: var(--kind-household); }

.muted { color: var(--muted); }
.note {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3); font-size: 0.9375rem;
}
.field-note { color: var(--muted); font-size: 0.875rem; }

/* Forms. */
label { font-weight: 500; font-size: 0.875rem; }
input[type="text"], input[type="number"], select {
  display: block; width: 100%; margin-top: var(--space-1);
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; min-height: 44px;
  transition: border-color 160ms var(--ease-out);
}
input::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover { border-color: var(--muted); }
fieldset { border: 0; padding: 0; min-width: 0; }
legend { font-weight: 600; font-size: 1rem; padding: 0; margin-bottom: var(--space-2); }

button {
  font: inherit; font-weight: 600; cursor: pointer; min-height: 44px;
  border: 1px solid transparent; border-radius: var(--radius-control); padding: 10px 18px;
  background: var(--accent); color: var(--on-accent);
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}
button:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
/* Every press gives way a little and springs back. */
button:active, .go:active { transform: scale(0.96); }
button:disabled, button.htmx-request { opacity: 0.6; cursor: progress; }
button.quiet { background: transparent; color: var(--ink); border-color: var(--line); }
button.quiet:hover { border-color: var(--muted); background: var(--panel); }
button[aria-pressed="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }

/* Colours, in the top bar: one round button on phones (each tap moves dark, follow the sky,
   light), the three-way switch from 720px. */
.bar-end { display: flex; align-items: center; gap: var(--space-2); }
.theme fieldset { display: none; }
.cycle {
  min-height: 0; width: 34px; height: 34px; padding: 0; display: grid; place-items: center;
  background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 50%;
}
.cycle:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); border-color: var(--muted); }
.cycle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.cycle svg .fill { fill: currentColor; stroke: none; }
@media (min-width: 720px) {
  .cycle { display: none; }
  .theme fieldset { display: inline-flex; }
}
.switch { display: inline-flex; gap: 2px; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--panel); }
.switch button {
  min-height: 0; width: 32px; height: 28px; padding: 0; display: grid; place-items: center;
  background: transparent; color: var(--muted); border: 0; border-radius: 999px;
}
.switch button:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.switch svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.switch svg .fill { fill: currentColor; stroke: none; }

/* A theme change cross-fades every colour instead of snapping (theme.js adds the class),
   unless the visitor asks for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
    transition: background-color 500ms var(--ease-out), color 500ms var(--ease-out),
      border-color 500ms var(--ease-out), fill 500ms var(--ease-out), stop-color 500ms var(--ease-out) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  /* No transitions or animations at all: a tiny duration would still start a transition on
     every property, and colours would briefly sit halfway between two states. */
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.error-page { max-width: 640px; margin: 0 auto; padding: var(--space-7) var(--space-4); display: grid; gap: var(--space-4); }
.error-page h1 { font-size: 2rem; }
