/* When Will It Rain? */

:root {
  --paper: #f6f3ea;
  --ink: #26231c;
  --muted: #79756a;
  --rule: #d9d4c5;
  --rain: #2d5e9e;
  --alert: #b3361c;
  --mono: "IBM Plex Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.875rem;
  line-height: 1.55;
}

.page {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 40px);
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a { color: inherit; text-underline-offset: 3px; }

.kicker {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- header ---------- */

.masthead { padding-top: clamp(22px, 4vw, 40px); }

.masthead-title {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 18px;
}

.locbar {
  display: flex;
  align-items: baseline;
  gap: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--ink);
}

.search {
  position: relative;
  flex: 1;
  min-width: 0;
}

#search-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  font: inherit;
  color: var(--ink);
  padding: 5px 1px;
  border-radius: 0;
}
#search-input::placeholder { color: var(--muted); }
#search-input:focus { outline: none; border-bottom-color: var(--ink); }

#search-results {
  position: absolute;
  z-index: 10;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--ink);
  max-height: 300px;
  overflow-y: auto;
}

#search-results li {
  padding: 8px 12px;
  font-size: 0.8125rem;
  cursor: pointer;
}
#search-results li .where { color: var(--muted); }
#search-results li[aria-selected="true"],
#search-results li:hover {
  background: var(--ink);
  color: var(--paper);
}
#search-results li[aria-selected="true"] .where,
#search-results li:hover .where { color: var(--rule); }

button {
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 4px 14px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { background: var(--ink); color: var(--paper); }
button:focus-visible { outline: 2px solid var(--rain); outline-offset: 2px; }

.linklike {
  border: 0;
  padding: 0;
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { background: transparent; color: var(--ink); }

.note {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 10px 0 0;
}

/* ---------- status (empty / loading / error) ---------- */

.status {
  padding: clamp(60px, 12vw, 110px) 0;
  text-align: center;
}

.status p {
  color: var(--muted);
  margin: 0 0 20px;
}

/* ---------- hero ---------- */

.hero { padding: clamp(30px, 5vw, 50px) 0 clamp(24px, 4vw, 42px); }

.hero-figure {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 clamp(12px, 2.5vw, 24px);
  margin: 14px 0 0;
}

.hero-number {
  font-size: clamp(4.5rem, 16vw, 9.5rem);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
}

.hero-label {
  max-width: 14em;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  line-height: 1.3;
  text-wrap: balance;
}

.hero-sub {
  font-size: 0.8125rem;
  color: var(--muted);
  margin: 16px 0 0;
}

/* ---------- stats ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0 clamp(20px, 4vw, 48px);
  border-top: 1px solid var(--ink);
}

.stat { padding: 16px 0 22px; }

.stat .kicker { margin: 0 0 10px; }

.stat-value {
  font-size: clamp(1.05rem, 2.2vw, 1.3rem);
  font-weight: 500;
  margin: 0;
  line-height: 1.3;
}

.stat-detail {
  font-size: 0.78rem;
  color: var(--muted);
  margin: 6px 0 0;
}

/* ---------- forecast strip ---------- */

.forecast { padding: clamp(8px, 2vw, 20px) 0 clamp(36px, 6vw, 56px); }

.section-title { display: block; margin: 0 0 12px; }
.flag-rain { color: var(--rain); }

.strip {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ink);
}

.strip.has-arrow { margin-top: 40px; }

.day {
  --p: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 6px 14px;
  border-left: 1px solid var(--rule);
  background: color-mix(in srgb, var(--rain) calc(var(--p) * 0.34%), transparent);
  text-align: center;
}
.day:first-child { border-left: 0; }

.day.rain-soonest::before {
  content: "↓";
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translate(-50%, 0);
  color: var(--alert);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  animation: bob 1.6s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 7px); }
}

@media (prefers-reduced-motion: reduce) {
  .day.rain-soonest::before { animation: none; }
}

.day-name {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.day.today .day-name { text-decoration: underline; text-underline-offset: 3px; }

.day-date {
  font-size: 0.66rem;
  color: var(--muted);
}

.day-glyph svg {
  width: 28px;
  height: 28px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.day-prob {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1;
}
.day-prob small {
  font-size: 0.65em;
  font-weight: 400;
  color: var(--muted);
}

.day-amt {
  font-size: 0.7rem;
  color: var(--rain);
  min-height: 1.1em;
}
.day-amt:empty::before { content: "—"; color: var(--rule); }

.day-temp {
  font-size: 0.7rem;
  color: var(--muted);
}

/* ---------- colophon ---------- */

.colophon {
  border-top: 1px solid var(--ink);
  padding: 16px 0 36px;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.7;
}
.colophon p { margin: 0 0 10px; max-width: 64em; }

.colophon-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.units button {
  border: 0;
  padding: 0 2px;
  font-size: inherit;
  color: var(--muted);
}
.units button:hover { background: transparent; color: var(--ink); }
.units button[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.units-sep { padding: 0 4px; }

.feedback { margin-top: 14px; }

#feedback-form { margin: 10px 0 0; max-width: 34em; }
#feedback-form input[name="botcheck"] { display: none; }

#feedback-text {
  width: 100%;
  border: 1px solid var(--rule);
  background: transparent;
  font: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  padding: 8px 10px;
  resize: vertical;
}
#feedback-text:focus { outline: none; border-color: var(--ink); }

.feedback-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin: 10px 0 0;
}
.feedback-row .note { margin: 0; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .locbar { flex-direction: column; align-items: stretch; gap: 14px; }
  #geo-btn { align-self: flex-start; }

  .stats { grid-template-columns: 1fr; gap: 0; }
  .stat { border-top: 1px solid var(--rule); padding: 14px 0 16px; }
  .stat:first-child { border-top: 0; }

  .forecast { overflow-x: auto; margin: 0 calc(-1 * clamp(18px, 4vw, 40px)); padding-left: clamp(18px, 4vw, 40px); padding-right: clamp(18px, 4vw, 40px); }
  .strip { grid-template-columns: repeat(10, minmax(72px, 1fr)); min-width: 740px; }
}
