/* ==========================================================================
   realhumidity.com — site styles
   Single stylesheet. No framework, no build step.
   ========================================================================== */

/* --- Design tokens ------------------------------------------------------ */

:root {
  color-scheme: light dark;

  --bg: #eef5fb;
  --bg-glow-1: rgba(21, 133, 216, 0.14);
  --bg-glow-2: rgba(56, 200, 255, 0.12);
  --surface: #ffffff;
  --surface-sunk: #f5f9fd;
  --text: #0e2233;
  --muted: #5c7488;
  --border: #dae7f2;
  --accent: #1585d8;
  --accent-hover: #0d6fb8;
  --accent-ink: #ffffff;
  --accent-soft: #e5f1fc;
  --ring: rgba(21, 133, 216, 0.35);
  --shadow-sm: 0 1px 2px rgba(14, 34, 51, 0.05),
    0 4px 16px rgba(14, 34, 51, 0.05);
  --shadow-lg: 0 2px 4px rgba(14, 34, 51, 0.04),
    0 18px 48px rgba(14, 34, 51, 0.1);

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --measure: 62ch;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1622;
    --bg-glow-1: rgba(21, 133, 216, 0.22);
    --bg-glow-2: rgba(56, 200, 255, 0.1);
    --surface: #122232;
    --surface-sunk: #0e1c29;
    --text: #e9f2fa;
    --muted: #93aabe;
    --border: #23394d;
    --accent: #4cb3f5;
    --accent-hover: #6ec4f8;
    --accent-ink: #06121d;
    --accent-soft: #162e42;
    --ring: rgba(76, 179, 245, 0.4);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.3), 0 18px 48px rgba(0, 0, 0, 0.45);
  }
}

/* --- Base --------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(
      70rem 40rem at 15% -10%,
      var(--bg-glow-1),
      transparent 60%
    ),
    radial-gradient(55rem 35rem at 95% 0%, var(--bg-glow-2), transparent 55%);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 650;
}

p {
  margin: 0;
}

svg {
  display: block;
}

.wrap {
  width: 100%;
  max-width: 62rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

:where(a, button, input):focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
}

/* --- Header ------------------------------------------------------------- */

.site-header {
  padding-block: clamp(1.25rem, 4vw, 2rem);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: inherit;
  text-decoration: none;
  font-weight: 650;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand svg {
  width: 1.6rem;
  height: 1.6rem;
  color: var(--accent);
}

/* --- Hero --------------------------------------------------------------- */

.hero {
  padding-block: clamp(1rem, 5vw, 3rem) clamp(2rem, 6vw, 3.5rem);
}

.hero h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
  max-width: 18ch;
}

.lede {
  margin-top: 1rem;
  max-width: var(--measure);
  font-size: clamp(1rem, 2.2vw, 1.15rem);
  color: var(--muted);
  text-wrap: pretty;
}

/* --- Search form -------------------------------------------------------- */

.search {
  margin-top: clamp(1.75rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.search__field {
  flex: 1 1 18rem;
  min-width: 0;
}

.search input[type="text"] {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease;
}

.search input[type="text"]::placeholder {
  color: var(--muted);
}

.search input[type="text"]:hover {
  border-color: var(--accent);
}

.btn {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 0.85rem 1.35rem;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
  background: var(--accent-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border-color: var(--border);
}

.btn--ghost:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn--ghost svg {
  width: 1.1rem;
  height: 1.1rem;
}

.btn[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Below ~480px the two buttons can't share a row without looking ragged,
   so give each its own full-width row instead. */
@media (max-width: 30rem) {
  .search .btn {
    flex: 1 1 100%;
    justify-content: center;
  }
}

.form-note {
  margin-top: 0.85rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.form-note[data-state="error"] {
  color: #c0392b;
}

@media (prefers-color-scheme: dark) {
  .form-note[data-state="error"] {
    color: #ff8b7a;
  }
}

/* --- Result region ------------------------------------------------------ */

.result {
  padding-bottom: clamp(3rem, 8vw, 5rem);
}

.result:empty {
  padding-bottom: 0;
}

/* Reading card: the headline number */

.reading {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(1.75rem, 5vw, 3rem);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.reading::before {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), #38c8ff);
}

.reading__place {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.reading__value {
  margin-top: 0.75rem;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  font-size: clamp(3.25rem, 14vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.reading__unit {
  font-size: clamp(1.1rem, 3.5vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--muted);
}

.reading__unit sup {
  font-size: 0.62em;
  vertical-align: super;
  line-height: 0;
}

.reading__label {
  margin-top: 1rem;
  color: var(--muted);
}

/* Out-of-range variant (temperature below 0 °C) */

.reading--unavailable .reading__value {
  font-size: clamp(1.4rem, 5vw, 2rem);
  letter-spacing: -0.02em;
}

.reading--unavailable::before {
  background: linear-gradient(90deg, #7d93a8, #a9bccd);
}

/* --- Stat tiles --------------------------------------------------------- */

.stats {
  margin-top: 1.25rem;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stat__head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--muted);
}

.stat__icon {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.stat__icon svg {
  width: 1.2rem;
  height: 1.2rem;
}

.stat__name {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.stat__value {
  font-size: clamp(1.35rem, 3.5vw, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}

/* --- States: loading, empty, error -------------------------------------- */

.state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 9rem;
  padding: 2rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

.spinner {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2s;
  }
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-block: 1.5rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  justify-content: space-between;
}

.site-footer a {
  color: inherit;
  text-decoration-color: var(--border);
  text-underline-offset: 3px;
}

.site-footer a:hover {
  color: var(--accent);
}

/* --- Utilities ---------------------------------------------------------- */

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