/* Alive webapp — uber-light theme. Air hues come ONLY from the CPCB
   band scale; everything else is warm paper + ink + one forest accent. */
@font-face { font-family: "Satoshi"; src: url("fonts/satoshi-light.woff2") format("woff2"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Satoshi"; src: url("fonts/satoshi-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Satoshi"; src: url("fonts/satoshi-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Satoshi"; src: url("fonts/satoshi-bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --paper: #FAFAF7; --surface: #FFFFFF; --surface2: #EFEDE7;
  --ink: #16181D; --ink2: #4A4E57; --ink3: #6E7278; --ink4: #A6ACB8;
  --ink10: rgba(22,24,29,.06); --ink15: rgba(22,24,29,.10);
  --accent: #35614B; --accent-ink: #2A4D3B; --accent-wash: #E5E2DA;
  /* CPCB pm2.5 bands — the ONLY hues that mean air */
  --b0: #6E93AE; --b1: #C7A34F; --b2: #CF8A50; --b3: #C05F3A; --b4: #A83D30; --b5: #6E2D28;
  --w0: rgba(110,147,174,.14); --w1: rgba(199,163,79,.14); --w2: rgba(207,138,80,.14);
  --w3: rgba(192,95,58,.14); --w4: rgba(168,61,48,.14); --w5: rgba(110,45,40,.14);
  --font: "Satoshi", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-row: 13px; --r-card: 20px; --r-sheet: 24px;
  --sh-card: 0 6px 18px rgba(59,52,35,.07);
  --sh-float: 0 8px 22px rgba(59,52,35,.12);
  --sh-sheet: 0 -6px 30px rgba(59,52,35,.14);
  --ease: cubic-bezier(.32,.72,0,1);
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
}
*, *::before, *::after { box-sizing: border-box }
[hidden] { display: none !important }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: var(--paper); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.35;
  overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent }
input { font: inherit; color: inherit }
a { color: var(--accent-ink); text-decoration: none }

#map { position: fixed; inset: 0; background: var(--surface2); }
#map .maplibregl-canvas { outline: none }

/* the "basic map" note chip (map.js sets its box inline — the overrides
   must carry !important). It has two faces on one class: the slim chip
   and the full-veil no-WebGL wall — told apart by the veil's inline
   "inset:" shorthand. */
#map .map-nogl:not([style*="inset"]) {
  /* phone: keep it in the top strip, clear of the mark pill at left */
  left: 104px !important; right: 10px !important; transform: none !important;
}

/* ── chrome ── */
#chrome { position: fixed; top: calc(10px + var(--sat)); left: 12px; right: 12px;
  display: flex; align-items: center; justify-content: space-between;
  pointer-events: none; z-index: 30; }
#mark { font-weight: 700; font-size: 21px; letter-spacing: -.02em;
  background: var(--surface); padding: 8px 14px; border-radius: 999px;
  box-shadow: var(--sh-card); pointer-events: auto; }
#loc-chip { pointer-events: auto; display: flex; align-items: center; gap: 8px;
  background: var(--glass, var(--surface)); backdrop-filter: blur(8px);
  border-radius: 999px; padding: 8px 13px; font-size: 12.5px; font-weight: 500;
  color: var(--ink2); box-shadow: var(--sh-card); max-width: 62vw; }
#loc-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none }
/* the chip only acts on home (it re-opens consent); off-home it is dead
   and its fixed position covers sheet controls — hide it there */
body[data-top]:not([data-top="home"]) #loc-chip { display: none; }
#loc-chip .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }

/* ── screen stack ── */
#screens { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: none; display: none; }
.screen.on { display: block; }
.screen > * { pointer-events: auto }

/* home: bottom panel above the map */
.home-panel { position: absolute; left: 0; right: 0; bottom: 0;
  padding: 0 12px calc(12px + var(--sab)); display: flex; flex-direction: column; gap: 10px; }

/* the AQI card */
.air-card { background: var(--surface); border-radius: var(--r-card);
  box-shadow: var(--sh-sheet); padding: 16px 18px 14px; position: relative; overflow: hidden; }
.air-card .bandwash { position: absolute; inset: 0; opacity: .5; pointer-events: none; transition: background-color .5s }
.air-head { display: flex; align-items: baseline; justify-content: space-between; position: relative }
.air-label { font-size: 12px; font-weight: 500; color: var(--ink3); letter-spacing: .02em }
.air-age { font-size: 11px; color: var(--ink4); font-family: var(--mono) }
.air-num { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; position: relative }
.air-num .v { font-size: 46px; font-weight: 300; letter-spacing: -.03em; line-height: 1.04 }
.air-num .u { font-size: 13px; color: var(--ink3) }
.air-word { font-size: 15px; font-weight: 500; margin-left: auto; }
.air-sub { display: flex; gap: 14px; margin-top: 8px; position: relative; flex-wrap: wrap }
.air-sub .m { font-size: 12px; color: var(--ink2) }
.air-sub .m b { font-weight: 500; font-family: var(--mono); font-size: 12px }
.air-why { margin-top: 9px; font-size: 12.5px; color: var(--ink3); position: relative }
.bandscale { display: flex; gap: 3px; margin-top: 11px; position: relative }
.bandscale .seg { height: 3px; flex: 1; border-radius: 2px; opacity: .35 }
.bandscale .seg.me { opacity: 1; height: 5px; margin-top: -1px }

/* feature doors */
.doors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.door { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--sh-card);
  padding: 13px 14px; text-align: left; transition: transform .35s var(--ease), box-shadow .3s; }
.door:active { transform: scale(.97) }
.door .d-t { font-weight: 500; font-size: 14.5px }
.door .d-s { font-size: 11.5px; color: var(--ink3); margin-top: 2px; line-height: 1.3 }
.door .d-i { font-size: 16px; margin-bottom: 6px; display: block }

/* sheets — the work surfaces slide up over the map */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; top: calc(52px + var(--sat));
  background: var(--paper); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  box-shadow: var(--sh-sheet); display: flex; flex-direction: column;
  will-change: transform;
  transform: translateY(104%); transition: transform .45s var(--ease); }
.sheet.on { transform: none }
.sheet-grab { width: 38px; height: 4px; border-radius: 2px; background: var(--ink15);
  margin: 9px auto 4px; flex: none }
.sheet-body { flex: 1; overflow-y: auto; padding: 4px 18px calc(18px + var(--sab)); }
.sheet-title { display: flex; align-items: center; gap: 10px; padding: 2px 18px 10px; flex: none; position: relative; z-index: 2; background: var(--paper) }
.sheet-title h2 { font-size: 19px; font-weight: 500; letter-spacing: -.01em; margin: 0; flex: 1 }
.back-btn, .x-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--surface);
  box-shadow: var(--sh-card); display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: var(--ink2); flex: none }
.back-btn:active, .x-btn:active { transform: scale(.92) }

/* search rows (where-to) */
.searchbar { display: flex; align-items: center; gap: 9px; background: var(--surface);
  border-radius: var(--r-row); box-shadow: var(--sh-card); padding: 12px 13px; margin-bottom: 8px; }
.searchbar .sdot { width: 9px; height: 9px; border-radius: 50%; flex: none }
.searchbar .sdot.a { background: var(--accent) }
.searchbar .sdot.b { background: var(--b3); border-radius: 2px }
/* 16px floor on every text input — below it iOS auto-zooms on focus and
   user-scalable=no locks the user there */
.searchbar input { flex: 1; border: 0; outline: 0; font-size: 16px; background: none; min-width: 0 }
.searchbar input::placeholder { color: var(--ink4) }
.row-list { display: flex; flex-direction: column; }
.srow { display: flex; align-items: center; gap: 11px; padding: 11px 6px;
  border-bottom: .5px solid var(--ink10); text-align: left; transition: background-color .2s; }
.srow:active, .srow.sel { background: var(--surface2); border-radius: 10px }
.srow .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--ink3); flex: none }
/* every flex child may shrink below content so the name column can clip;
   flex:none siblings (.ic/.src/.pm-rank/.pm-v) keep their basis anyway */
.srow > span { min-width: 0 }
.srow .n { font-weight: 500; font-size: 14px; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.srow .s { font-size: 11.5px; color: var(--ink3); margin-top: 1px; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.srow .src { font-size: 9.5px; font-family: var(--mono); color: var(--ink4); margin-left: auto; flex: none; padding-left: 8px }

/* mode cards */
.modes { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 }
.mode { background: var(--surface); border-radius: var(--r-row); box-shadow: var(--sh-card);
  padding: 13px 14px; display: flex; gap: 12px; align-items: center; text-align: left;
  border: 1.5px solid transparent; transition: border-color .25s, transform .3s var(--ease) }
.mode.sel { border-color: var(--accent) }
.mode:active { transform: scale(.98) }
.mode .mi { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-wash);
  display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none }
.mode .mt { font-weight: 500; font-size: 14.5px }
.mode .ms { font-size: 11.5px; color: var(--ink3); margin-top: 1px; line-height: 1.35 }

/* vehicle chips */
.vrow { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none }
.vrow::-webkit-scrollbar { display: none }
.vchip { flex: none; background: var(--surface); border-radius: 999px; box-shadow: var(--sh-card);
  padding: 9px 15px; font-size: 13.5px; font-weight: 500; border: 1.5px solid transparent;
  display: flex; gap: 7px; align-items: center }
.vchip.sel { border-color: var(--accent); color: var(--accent-ink) }

/* route option cards */
.opt { background: var(--surface); border-radius: var(--r-card); box-shadow: var(--sh-card);
  padding: 14px 15px; margin-bottom: 10px; border: 1.5px solid transparent; transition: border-color .25s }
.opt.sel { border-color: var(--accent) }
.opt .ot { display: flex; align-items: baseline; gap: 8px }
.opt .ot .m { font-weight: 500; font-size: 14.5px }
.opt .ot .t { margin-left: auto; font-size: 12px; color: var(--ink3); font-family: var(--mono) }
.opt .dose { display: flex; align-items: baseline; gap: 7px; margin-top: 7px }
.opt .dose .v { font-size: 21px; font-weight: 300; letter-spacing: -.02em }
.opt .dose .w { font-size: 12px; font-weight: 500 }
.opt .dose .r { margin-left: auto; font-size: 11.5px; color: var(--ink3) }
.opt .why { font-size: 12px; color: var(--ink3); margin-top: 6px; line-height: 1.4 }
.opt .strip { display: flex; height: 4px; border-radius: 2px; overflow: hidden; margin-top: 9px; gap: 1px }
.opt .strip i { flex: 1 }

/* primary CTA */
.cta { position: sticky; bottom: 0; padding: 10px 0 2px; background: linear-gradient(transparent, var(--paper) 30%) }
.btn-primary { display: block; width: 100%; background: var(--accent); color: #fff;
  border-radius: 16px; padding: 15px; font-size: 15.5px; font-weight: 500;
  transition: transform .3s var(--ease) }
.btn-primary:active { transform: scale(.97) }
.btn-primary[disabled] { opacity: .45 }
.btn-ghost { display: block; width: 100%; padding: 11px; font-size: 14px; color: var(--ink2) }

/* consent */
#consent { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end;
  background: rgba(10,14,22,.34); backdrop-filter: blur(3px); }
.consent-card { background: var(--surface); border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  width: 100%; padding: 26px 22px calc(22px + var(--sab)); box-shadow: var(--sh-sheet);
  animation: rise .55s var(--ease) }
@keyframes rise { from { transform: translateY(30px); opacity: 0 } }
.consent-card .consent-dot { width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent-wash); position: relative; margin-bottom: 14px }
.consent-card .consent-dot::after { content: ""; position: absolute; inset: 14px;
  border-radius: 50%; background: var(--accent) }
.consent-card h1 { font-size: 20px; font-weight: 500; margin: 0 0 8px; letter-spacing: -.01em }
.consent-card p { font-size: 13.5px; color: var(--ink2); line-height: 1.5; margin: 0 0 18px }
.consent-actions { display: flex; flex-direction: column; gap: 4px }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--sab)); transform: translateX(-50%);
  background: rgba(22,24,29,.94); color: #fff; font-size: 13px; font-weight: 500;
  padding: 10px 16px; border-radius: 999px; z-index: 70; animation: rise .4s var(--ease);
  max-width: 88vw; text-align: center }

/* skeleton + misc */
.sk { border-radius: 8px; background: linear-gradient(100deg, var(--surface2) 40%, var(--surface) 50%, var(--surface2) 60%);
  background-size: 200% 100%; animation: sk 1.4s linear infinite }
@keyframes sk { to { background-position: -200% 0 } }
.muted { color: var(--ink3); font-size: 12.5px }
.mono { font-family: var(--mono); font-size: 11px; color: var(--ink4) }
.sec-label { font-size: 11px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink4); margin: 16px 0 7px }

@media (min-width: 720px) {
  /* the right rail — one width every "keep clear of the sheet" rule reads */
  :root { --rail-w: 400px }
  .home-panel { left: auto; right: 18px; width: 400px; padding-right: 0 }
  .sheet { left: auto; right: 0; width: var(--rail-w); top: 0; border-radius: 0;
    /* the seam: a real left edge so the map reads as running under a
       panel, not ending at a hard paper wall */
    border-left: 1px solid var(--ink10);
    box-shadow: -18px 0 42px rgba(59,52,35,.12);
    transform: translateX(104%) }
  .sheet.on { transform: none }
  /* the armed pin-drop sheet is a ghost (no surface) — no seam artifacts */
  .wt-armed .sheet { border-left: 0; box-shadow: none }
  /* the rail swallows the map's bottom-right corner — slide the zoom /
     attribution cluster left of the seam so it stays real controls.
     Once the cluster moves bottom-left (map lane) these go quiet. */
  #map .maplibregl-ctrl-bottom-right { right: calc(var(--rail-w) + 10px) }
  #map .leaflet-bottom.leaflet-right { right: calc(var(--rail-w) + 10px) }
  /* the basic-map chip centers on the honest map region, not the
     viewport — it can never slide under the rail */
  #map .map-nogl:not([style*="inset"]) {
    left: 0 !important; right: var(--rail-w) !important;
    width: fit-content !important; margin-left: auto !important; margin-right: auto !important;
    max-width: calc(100% - var(--rail-w) - 48px) !important;
  }
  /* …and the no-WebGL veil covers exactly that region, sheet excluded */
  #map .map-nogl[style*="inset"] { right: var(--rail-w) !important }
  /* toasts center on the visible map while a sheet screen is up */
  body[data-top="whereto"] #toast, body[data-top="airmap"] #toast,
  body[data-top="purest"] #toast, body[data-top="ledger"] #toast {
    left: calc(50% - var(--rail-w) / 2) }
  .consent-card { width: 460px; margin: 0 auto 8vh; border-radius: var(--r-sheet) }
  #consent { align-items: center }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important }
}

/* ── air map ── */
.am-legend { display: flex; flex-wrap: wrap; gap: 5px 12px; margin: 2px 0 10px }
.am-leg { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink3) }
.am-leg span { width: 9px; height: 9px; border-radius: 3px }
.am-hint { margin-bottom: 8px }
.am-plain { font-size: 12.5px; color: var(--ink3); padding: 4px 6px }
.am-bars { display: flex; align-items: flex-end; gap: 2px; height: 56px; margin: 10px 0 8px }
.am-bar { flex: 1; display: flex; align-items: flex-end; height: 100%; min-width: 0 }
.am-bar i { width: 100%; border-radius: 3px 3px 1px 1px; min-height: 3px }
.am-verdict { font-size: 14px; font-weight: 500; margin: 2px 0 6px; line-height: 1.4 }
.am-bw { font-size: 13px; padding: 6px 0; border-bottom: .5px solid var(--ink10) }
.am-bw .bw-l { color: var(--ink3); font-size: 11.5px; margin-right: 6px }

/* ── pins + puck ── */
.alive-pin { pointer-events: none }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 3px solid #fff; box-shadow: 0 2px 8px rgba(22,24,29,.3) }
.pin-chip { background: var(--surface); border-radius: 9px; box-shadow: var(--sh-card);
  font-size: 11px; font-weight: 500; padding: 4px 8px; white-space: nowrap }
.alive-puck { pointer-events: none }
.puck-core { width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 3.5px solid #fff; box-shadow: 0 2px 10px rgba(22,24,29,.35); position: absolute;
  left: 50%; top: 50%; transform: translate(-50%,-50%) }
.puck-ring { position: absolute; left: 50%; top: 50%; width: var(--acc, 56px); height: var(--acc, 56px);
  transform: translate(-50%,-50%); border-radius: 50%; background: rgba(53,97,75,.14);
  border: 1px solid rgba(53,97,75,.28) }
