:root {
  --bg: #f3eee3;
  --fg: #1c1a16;
  --muted: #6e6759;
  --line: rgba(28, 26, 22, 0.16);
  /* San Francisco on Apple devices; Inter (its closest lookalike) everywhere else. */
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171611;
    --fg: #f1ebdf;
    --muted: #a39c8d;
    --line: rgba(241, 235, 223, 0.18);
    color-scheme: dark;
  }
}

/* It's raining: same moody slate, whatever your OS thinks. */
body[data-state="yes"] {
  --bg: #26323d;
  --fg: #e8eef3;
  --muted: #9fb1c1;
  --line: rgba(232, 238, 243, 0.2);
  color-scheme: dark;
}

body[data-state="snow"] {
  --bg: #e7edf2;
  --fg: #22303b;
  --muted: #5d6d7a;
  --line: rgba(34, 48, 59, 0.16);
}
@media (prefers-color-scheme: dark) {
  body[data-state="snow"] {
    --bg: #1b232a;
    --fg: #e4ecf2;
    --muted: #93a4b2;
    --line: rgba(228, 236, 242, 0.18);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.9s ease, color 0.9s ease;
}

#rain {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease;
}
body[data-state="yes"] #rain { opacity: 1; }

/* Lightning lights up the sky behind the text; app.js drives its opacity. */
#flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, #eef3ff 0%, #b8c6dc 60%, #8193ad 100%);
  opacity: 0;
}

/* Each kind of rain gets its own sky. */
body[data-state="yes"][data-kind="drizzle"] {
  --bg: #3c4752;
  --muted: #b0bdc8;
}
body[data-state="yes"][data-kind="freezing"] {
  --bg: #2b3a48;
  --muted: #b3c7d6;
}
body[data-state="yes"][data-kind="heavy"] {
  --bg: #1c252e;
  --muted: #8ea0b0;
}
body[data-state="yes"][data-kind="storm"] {
  --bg: #12171d;
  --muted: #8796a5;
}

main {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 16px 32px;
}

/* Matches #quip in size and weight. */
.question {
  margin: 0 0 8px;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.3;
  letter-spacing: -0.015em;
  color: var(--muted);
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(112px, 30vw, 320px);
  line-height: 1;
  letter-spacing: -0.055em;
}

/* Letters are split so they can drop in one by one. */
h1 .ch { display: inline-block; white-space: pre; }

body[data-state="loading"] h1,
body[data-state="unknown"] h1 {
  font-size: clamp(56px, 12vw, 120px);
  letter-spacing: -0.04em;
}
body[data-state="loading"] h1 { color: var(--muted); animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: 0.45; } }

#quip {
  margin: 20px 0 0;
  max-width: 30ch;
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(20px, 3vw, 26px);
  line-height: 1.3;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

#aside {
  margin: 12px 0 0;
  max-width: 40ch;
  font-size: 15px;
  line-height: 1.5;
  color: var(--muted);
}
#aside:empty { display: none; }

.actions { margin-top: 40px; display: flex; gap: 12px; }

.pill, #search button {
  appearance: none;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 20px;
  font: 500 14px/1 var(--sans);
  cursor: pointer;
  transition:
    border-color 0.25s ease,
    background-color 0.25s ease,
    transform 0.35s cubic-bezier(0.34, 1.45, 0.64, 1);
}
.pill:hover, #search button:hover {
  border-color: var(--fg);
  background-color: color-mix(in srgb, var(--fg) 6%, transparent);
  transform: translateY(-1px);
}
.pill:active, #search button:active {
  transform: scale(0.95);
  transition-duration: 0.1s;
}
#search input { transition: border-color 0.25s ease; }
#search input:focus { border-color: var(--fg); }
.linkish { transition: text-underline-offset 0.25s ease, opacity 0.25s ease; }
.linkish:hover { text-underline-offset: 5px; }
footer a { transition: opacity 0.2s ease; }
footer a:hover { opacity: 0.7; }
.pill:focus-visible, #search button:focus-visible, #search input:focus-visible, .linkish:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 3px;
}

#search {
  margin-top: 28px;
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 360px;
}
#search input {
  flex: 1;
  min-width: 0;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
  font: 400 16px/1 var(--sans);
}
#search input::placeholder { color: var(--muted); }

/* app.js animates #details' height; the spacing lives inside so it animates too. */
#details {
  width: 100%;
  max-width: 400px;
  overflow: hidden;
  text-align: left;
}
.details-inner {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.place {
  margin: 0 0 16px;
  font-family: var(--display);
  font-weight: 600;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
dt {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
dd {
  margin: 4px 0 0;
  font-size: 18px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.chart { margin-top: 24px; }
.label {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.label span { text-transform: none; letter-spacing: 0; }
.bars {
  height: 56px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border-bottom: 1px solid var(--line);
}
.bars div {
  flex: 1;
  min-height: 2px;
  background: var(--fg);
  opacity: 0.8;
  border-radius: 3px 3px 0 0;
  transform-origin: bottom;
  transition: height 0.6s ease;
}
.axis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.meta { margin: 20px 0 0; font-size: 13px; color: var(--muted); }

.linkish {
  margin-top: 8px;
  padding: 0;
  background: none;
  border: 0;
  color: var(--fg);
  font: 500 14px var(--sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

footer {
  position: relative;
  z-index: 1;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}
footer span { display: inline-block; }
.tip { margin: 0 0 6px; font-size: 13px; font-weight: 500; }
.tip a { color: var(--fg); text-decoration: none; border-bottom: 1px solid var(--line); padding-bottom: 1px; }
.tip a:hover { border-color: var(--fg); opacity: 1; }
footer a { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
