/* Resident app. Colours and fonts come from ../shared/tokens.css. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
}

.muted { color: var(--ink-2); }
.pad { padding: 20px; }
[hidden] { display: none !important; }

/* ---------- header ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 12px;
}
.dam { font-size: 15px; font-weight: 700; line-height: 1.2; }
.sub { font-size: 13px; color: var(--ink-2); display: flex; gap: 8px; }
.status { display: flex; gap: 12px; font-size: 14px; color: var(--ink-2); white-space: nowrap; }
.status > span { display: inline-flex; align-items: center; gap: 6px; }
#alert-status { color: var(--ink); }
#alert-status i { width: 10px; height: 10px; background: var(--way-ink); }
body[data-state="calm"] .top { border-bottom: 1px solid var(--rule); }

/* ---------- band ---------- */
.band {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 13px 18px 11px;
  background: var(--act);
  color: var(--on-colour);
  font-size: 17px;
  font-weight: 800;
}
.band[data-tone="safe"] { background: var(--way); }
.band[data-tone="soon"] { background: var(--soon); color: var(--on-soon); }
#band-clock { white-space: nowrap; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- card ---------- */
#card { padding: 16px 16px 0; }
.label { font-size: 15px; margin: 0 4px; }
.calm-lead { font-size: 22px; font-weight: 800; margin: 14px 4px 0; line-height: 1.2; }

.timer {
  margin: 0 4px;
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timer b { font-size: 120px; font-weight: 800; }
.timer i { font-style: normal; font-size: 28px; letter-spacing: 0; margin: 0 14px 0 4px; }
.timer.long b { font-size: 96px; }
.timer.now b { font-size: 104px; color: var(--act-ink); }

.by { font-size: 24px; font-weight: 800; margin: 14px 4px 0; line-height: 1.2; font-variant-numeric: tabular-nums; }
.range { font-size: 14px; color: var(--ink-2); margin: 2px 4px 0; }
.calm-after { font-size: 15px; color: var(--ink-2); margin: 10px 4px 0; line-height: 1.4; }

.sign {
  margin: 14px 0 0;
  padding: 14px 16px 12px;
  background: var(--way);
  color: var(--on-colour);
  border-radius: 4px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}
.sign .over { font-size: 14px; }
.sign h2 { font-size: 20px; font-weight: 700; margin: 0; line-height: 1.2; }
.sign p { font-size: 15px; margin: 2px 0 0; line-height: 1.3; }

.warn {
  margin: 8px 0 0;
  padding: 12px 16px 10px;
  background: var(--soon);
  color: var(--on-soon);
  border-radius: 4px;
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  font-size: 15px;
  line-height: 1.3;
}
.note {
  margin: 14px 4px 0;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  font-size: 15px;
  line-height: 1.4;
}

.head { font-size: 56px; font-weight: 800; line-height: 1; margin: 12px 4px 0; letter-spacing: -0.02em; }
.head.small { font-size: 40px; }
.sign.dark { background: var(--ink); color: var(--ground); }
.mk.dest.refuge { background: var(--ink); }
.loading { grid-column: 1 / -1; margin: 0; padding: 14px 4px; font-size: 15px; }
.headrow { display: flex; align-items: center; gap: 16px; margin: 12px 4px 0; }
.headrow .head { margin: 0; }
.pict {
  width: 78px; height: 78px; flex-shrink: 0;
  background: var(--ink); color: var(--ground);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.say { font-size: 18px; line-height: 1.4; margin: 12px 4px 0; }

.kv {
  margin: 16px 0 0;
  padding: 12px 4px 8px;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 15px;
}
.kv b { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kv em { font-style: normal; color: var(--ink-2); }

ol.todo { list-style: none; margin: 14px 0 0; padding: 0; border-top: 2px solid var(--ink); counter-reset: n; }
.kv + ol.todo { margin-top: 0; border-top: 1px solid var(--rule); }
ol.todo li {
  counter-increment: n;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  padding: 13px 4px 11px;
  border-bottom: 1px solid var(--rule);
  font-size: 16px;
  line-height: 1.35;
}
ol.todo li::before { content: counter(n); font-weight: 800; }

/* ---------- map ---------- */
.mapwrap { position: relative; margin: 10px 16px 0; flex: 1 1 200px; min-height: 200px; display: flex; }
#map { flex: 1; border: 1px solid var(--rule); background: var(--map-land); }
.maphint {
  position: absolute; left: 8px; top: 8px;
  padding: 6px 10px 4px;
  background: var(--ink); color: var(--ground);
  font-size: 14px; font-weight: 700;
  pointer-events: none;
}
body[data-kind="nowhere"]:not([data-show-map]) .mapwrap,
body[data-kind="stay"]:not([data-show-map]) .mapwrap,
body[data-kind="nowhere"]:not([data-show-map]) .legend,
body[data-kind="stay"]:not([data-show-map]) .legend { display: none; }
/* without a map the footer follows the buttons */
body[data-kind="nowhere"]:not([data-show-map]) .foot,
body[data-kind="stay"]:not([data-show-map]) .foot { margin-top: 16px; }

/* legend under the map: the same tokens as the map layers */
.legend { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 6px 16px 0; font-size: 12px; color: var(--ink-2); }
.legend:empty { display: none; }
.legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.legend .ln { width: 18px; height: 0; border-top: 3px solid var(--road-later); }
.legend .ln.route { border-top-width: 5px; border-color: var(--way-ink); }
.legend .ln.refuge { border-top-width: 5px; border-color: var(--ink); }
.legend .ln.closed { border-top-style: dashed; border-color: var(--act-ink); }
.legend .ln.soon { border-color: var(--soon-ink); }
.legend .ln.later { border-color: var(--road-later); }
.legend .ln.never { border-top-width: 4px; border-color: var(--road-never); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 25%, transparent); }
.legend .sw { width: 14px; height: 10px; }
.legend .sw.water { background: var(--water-all); }
.legend .sw.safe { background: color-mix(in srgb, var(--way-ink) 12%, var(--map-land)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--way-ink) 40%, transparent); }

/* road labels on the map: name, then when it closes */
.maplbl.road { text-align: center; line-height: 1.15; white-space: normal; width: max-content; max-width: 200px; }
.maplbl.road .when { font-weight: 500; font-size: 12px; }
/* a tapped point outside the plan */
.mk.tap { width: 12px; height: 12px; background: var(--ink-2); border: 2px solid var(--route-casing); }
.me-dot {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ink); border: 3px solid var(--route-casing); box-shadow: 0 0 0 2px var(--ink);
}
.me-dot.sim { display: none; }

/* ---------- actions ---------- */
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 16px 0; }
.actions:empty { display: none; }
.btn {
  height: 52px;
  padding: 3px 12px 0;
  border: 1px solid var(--ink);
  border-radius: 4px;
  background: var(--ground);
  color: var(--ink);
  font: 700 17px var(--font);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
  cursor: pointer;
}
.btn.on, .btn.primary { background: var(--ink); color: var(--ground); }
.btn:focus-visible, .link:focus-visible { outline: 3px solid var(--soon); outline-offset: 2px; }

.steps { margin: 12px 16px 0; }
.steps h3 { font-size: 15px; margin: 0 0 4px; }
.steps ol { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: n; border-top: 1px solid var(--rule); }
.steps li {
  counter-increment: n;
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 4px;
  padding: 10px 4px 8px; border-bottom: 1px solid var(--rule); font-size: 15px;
}
.steps li::before { content: counter(n); font-weight: 800; }
.steps li span { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.aside { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); }
.steps li.first b::after { content: ", closes first"; font-weight: 400; color: var(--soon-ink); }
.steps li { grid-template-columns: 26px minmax(0, 1fr); }


/* ---------- footer ---------- */
.foot { padding: 10px 18px 12px; font-size: 12px; color: var(--ink-2); display: grid; gap: 2px; }
.foot .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
/* 44 px touch targets that keep the small footer line */
.foot .link { display: inline-flex; align-items: center; min-height: 44px; margin: -15px -8px; padding: 0 8px; }
.link { border: 0; background: none; padding: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }

/* ---------- places for the demo ---------- */
#btn-places, #places-close { display: inline-flex; align-items: center; min-height: 44px; margin: -12px -10px; padding: 0 10px; }
#btn-places { font-size: 14px; font-weight: 700; color: var(--ink); }
.seg2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.seg2 .btn { height: 44px; font-size: 15px; border-radius: 0; }
.seg2 .btn:first-child { border-radius: 4px 0 0 4px; }
.seg2 .btn:last-child { border-radius: 0 4px 4px 0; border-left: 0; }
.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto; background: var(--ground); padding: 16px 16px 20px; display: grid; gap: 10px; }
.sheet-head { display: flex; justify-content: space-between; align-items: baseline; }
.sheet-head h2 { font-size: 20px; font-weight: 800; margin: 0; }
.btn.wide { width: 100%; }
.actions .btn.wide, .actions .btn:only-child { grid-column: 1 / -1; }
.time { display: grid; gap: 4px; font-size: 14px; color: var(--ink-2); margin-top: 4px; }
.time b { color: var(--ink); font-variant-numeric: tabular-nums; }
.time input { width: 100%; accent-color: var(--ink); }
.case-list { display: grid; border-top: 2px solid var(--ink); margin-top: 6px; }
.case { min-height: 48px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--rule); padding: 11px 4px 9px; font: inherit; color: inherit; cursor: pointer; }
.case b { display: block; font-size: 16px; font-weight: 800; }
.case span { display: block; font-size: 13px; color: var(--ink-2); }
.case.on { box-shadow: inset 3px 0 0 var(--ink); padding-left: 12px; }

/* ---------- your location: on the map, or automatic from the device ---------- */
.loc { padding: 12px 16px 0; }
.loc-cap { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.loc-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.loc-btns .btn { width: 100%; justify-content: center; text-align: center; }
.loc-btns .btn[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
.loc-msg { margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* ---------- the dam you live near ---------- */
.dam-select { font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); background: var(--ground);
  border: 1px solid var(--ink); border-radius: 3px; padding: 6px 6px 4px; max-width: 56vw; min-height: 36px; }
.dam-select:focus-visible { outline: 3px solid var(--soon); outline-offset: 2px; }
.plan-note { padding: 10px 16px 0; font-size: 12px; color: var(--ink-2); }
.legend i.sw.pale { opacity: 0.45; }
