/* ==========================================================================
   Levelstat — shared stylesheet
   ========================================================================== */

:root {
  --c-bg: #f6f9fb;
  --c-surface: #ffffff;
  --c-surface-alt: #eef4f8;
  --c-border: #e2e8f0;
  --c-border-strong: #cbd5e1;
  --c-text: #0f172a;
  --c-text-muted: #475569;
  --c-text-faint: #94a3b8;
  --c-primary: #0369a1;
  --c-primary-hover: #075985;
  --c-accent: #06b6d4;
  --c-accent-soft: #cffafe;
  --c-success: #10b981;
  --c-danger: #ef4444;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 6px 16px -8px rgba(15, 23, 42, 0.18);
  --shadow-lg: 0 20px 40px -24px rgba(15, 23, 42, 0.28);

  --container: min(1120px, 100% - 2rem);

  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

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

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--c-primary);
  text-decoration: none;
}
a:hover {
  color: var(--c-primary-hover);
  text-decoration: underline;
}

h1,
h2,
h3 {
  color: var(--c-text);
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 {
  font-size: clamp(2rem, 1.2rem + 3vw, 3.25rem);
  letter-spacing: -0.02em;
  font-weight: 700;
}

h2 {
  font-size: clamp(1.5rem, 1.1rem + 1.2vw, 2rem);
  letter-spacing: -0.01em;
  font-weight: 700;
}

h3 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  background: var(--c-surface-alt);
  color: var(--c-primary-hover);
}

.container {
  width: var(--container);
  margin-inline: auto;
}

.eyebrow {
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--c-primary);
  margin: 0 0 0.75em;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  padding: 0.625rem 1.1rem;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease,
    color 120ms ease, transform 120ms ease;
}

.btn:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
}

.btn--sm {
  padding: 0.5rem 0.85rem;
  font-size: 0.875rem;
}
.btn--lg {
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
}

.btn--primary {
  background: var(--c-primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--c-primary-hover);
  color: #fff;
  text-decoration: none;
}

.btn--outline {
  background: transparent;
  color: var(--c-primary);
  border-color: var(--c-border-strong);
}
.btn--outline:hover {
  background: var(--c-surface);
  border-color: var(--c-primary);
  color: var(--c-primary-hover);
  text-decoration: none;
}

.btn--ghost {
  background: var(--c-surface);
  color: var(--c-text);
  border-color: var(--c-border);
}
.btn--ghost:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
  text-decoration: none;
}

/* ---------- Header / Brand / Nav ---------- */
.site-header,
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
}

.site-header__inner,
.app-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--c-primary);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand:hover {
  color: var(--c-primary-hover);
  text-decoration: none;
}
.brand__mark {
  width: 28px;
  height: 28px;
  color: var(--c-primary);
}
.brand__name {
  color: var(--c-text);
}

.site-nav,
.app-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.site-lookup {
  display: inline-flex;
  align-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 0.2rem 0.25rem 0.2rem 0.75rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.site-lookup:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.15);
}
.site-lookup input {
  font: inherit;
  border: 0;
  outline: none;
  background: transparent;
  padding: 0.35rem 0.25rem;
  width: 9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-text);
}
.site-lookup input::placeholder {
  color: var(--c-text-faint);
  letter-spacing: 0.04em;
}
.site-lookup .btn {
  padding: 0.4rem 0.75rem;
}
.site-lookup--compact input {
  width: 8rem;
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(3rem, 2rem + 6vw, 6rem) 0 4rem;
  background:
    radial-gradient(
      1200px 420px at 10% -10%,
      rgba(6, 182, 212, 0.18),
      transparent 60%
    ),
    radial-gradient(
      900px 400px at 90% 0%,
      rgba(3, 105, 161, 0.15),
      transparent 60%
    ),
    linear-gradient(180deg, #ffffff, var(--c-bg) 80%);
  overflow: hidden;
}

.hero__inner {
  max-width: 760px;
}

.hero__title {
  margin-top: 0.25em;
  margin-bottom: 0.5em;
}

.hero__title-accent {
  display: block;
  background: linear-gradient(90deg, var(--c-primary), var(--c-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__lede {
  font-size: 1.125rem;
  color: var(--c-text-muted);
  max-width: 58ch;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  margin-bottom: 1rem;
}

.hero__hint {
  font-size: 0.9rem;
  color: var(--c-text-faint);
  margin-top: 0.75rem;
}

.hero__waves {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  color: var(--c-primary);
  pointer-events: none;
}
.hero__waves svg {
  display: block;
  width: 100%;
  height: 90px;
}

/* ---------- Sections ---------- */
.section {
  padding: clamp(3rem, 2rem + 4vw, 5rem) 0;
}
.section--alt {
  background: var(--c-surface);
  border-block: 1px solid var(--c-border);
}
.section__title {
  max-width: 24ch;
}
.section__lede {
  max-width: 64ch;
  color: var(--c-text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

/* ---------- Features ---------- */
.feature-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.feature-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 180ms ease, box-shadow 180ms ease,
    border-color 180ms ease;
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--c-border-strong);
}
.feature-card h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}
.feature-card p {
  color: var(--c-text-muted);
  margin-bottom: 0;
}
.feature-card__icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--c-accent-soft);
  color: var(--c-primary);
}
.feature-card__icon svg {
  width: 22px;
  height: 22px;
}

/* ---------- Steps ---------- */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.step {
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
}
.step h3 {
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}
.step p {
  color: var(--c-text-muted);
  margin: 0;
}
.step__num {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--c-primary);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ---------- CTA ---------- */
.cta {
  padding: clamp(3rem, 2rem + 4vw, 5rem) 0;
  background: linear-gradient(
    135deg,
    #ecfeff 0%,
    #e0f2fe 50%,
    #f0f9ff 100%
  );
}
.cta__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.cta h2 {
  margin-bottom: 0.25em;
}
.cta p {
  color: var(--c-text-muted);
  margin: 0;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  padding: 1.5rem 0;
  margin-top: auto;
}
.site-footer--app {
  margin-top: 3rem;
}
.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--c-text-muted);
  font-size: 0.92rem;
}
.site-footer__inner p {
  margin: 0;
}

/* ==========================================================================
   App / data page
   ========================================================================== */

.page-app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  padding: clamp(1.5rem, 1rem + 2vw, 3rem) 0 3rem;
  display: grid;
  gap: 1.5rem;
}

.site-summary {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-summary__heading h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.5vw, 2.5rem);
  margin-bottom: 0.15em;
}
.site-summary__location {
  color: var(--c-text-muted);
  margin: 0;
}

.site-summary__controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.site-summary__status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.85rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  font-size: 0.9rem;
  color: var(--c-text-muted);
}

.unit-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.unit-switcher__field {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  padding: 0.25rem 0.35rem 0.25rem 0.85rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.unit-switcher__field:hover {
  border-color: var(--c-border-strong);
}
.unit-switcher__field:focus-within {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
}
.unit-switcher__label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--c-text-muted);
}
.unit-switcher__field select {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--c-text);
  background: transparent;
  border: 0;
  padding: 0.25rem 1.4rem 0.25rem 0.25rem;
  border-radius: 999px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23475569' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--c-text-faint);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}
.status-dot--ok {
  background: var(--c-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}
.site-summary__updated::before {
  content: "·";
  margin: 0 0.35rem;
  color: var(--c-text-faint);
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.stat-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
}
.stat-card--primary {
  background: linear-gradient(180deg, #f0f9ff, #ffffff 60%);
  border-color: #bae6fd;
}
.stat-card__label {
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  color: var(--c-text-muted);
  margin: 0 0 0.35rem;
  font-weight: 600;
}
.stat-card__value {
  font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
  color: var(--c-text);
}
.stat-card__value--small {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0;
}
.stat-card__unit {
  font-size: 0.55em;
  font-weight: 500;
  color: var(--c-text-muted);
  margin-left: 0.25rem;
}
.stat-card__delta {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--c-text-muted);
  min-height: 1.2em;
}
.stat-card__delta--up {
  color: var(--c-success);
}
.stat-card__delta--down {
  color: var(--c-danger);
}

.chart-card,
.readings-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.chart-card__header,
.readings-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.chart-card__header h2,
.readings-card__header h2 {
  font-size: 1.15rem;
  margin: 0;
}
.chart-card__header p,
.readings-card__header p {
  margin: 0;
  color: var(--c-text-muted);
  font-size: 0.9rem;
}

.chart-card__chart {
  width: 100%;
  height: 220px;
}
.chart-card__chart svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.chart-card__caption {
  margin: 0.75rem 0 0;
  color: var(--c-text-muted);
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
}

.readings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  background: var(--c-surface);
}
.readings-table th,
.readings-table td {
  padding: 0.65rem 0.9rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
}
.readings-table th {
  background: var(--c-surface-alt);
  color: var(--c-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.readings-table tbody tr:last-child td {
  border-bottom: 0;
}
.readings-table__empty {
  text-align: center;
  color: var(--c-text-muted);
  font-style: italic;
  padding: 1.25rem;
}

.disclaimer {
  font-size: 0.85rem;
  color: var(--c-text-muted);
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 0.9rem 1.1rem;
}
.disclaimer p {
  margin: 0;
}

/* ---------- Not-found view ---------- */
.not-found {
  max-width: 640px;
  margin-inline: auto;
  text-align: center;
  padding: clamp(2rem, 1rem + 4vw, 4rem) 1.5rem;
}
.not-found__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-accent-soft);
  color: var(--c-primary);
}
.not-found__icon svg {
  width: 40px;
  height: 40px;
}
.not-found h1 {
  font-size: clamp(1.75rem, 1.3rem + 1.5vw, 2.5rem);
  margin-top: 0.25em;
  margin-bottom: 0.5em;
}
.not-found__lede {
  color: var(--c-text-muted);
  font-size: 1.05rem;
  max-width: 52ch;
  margin-left: auto;
  margin-right: auto;
}
.not-found__lede code {
  background: var(--c-surface-alt);
  padding: 0.1em 0.45em;
  border-radius: var(--radius-sm);
  font-size: 0.95em;
  color: var(--c-primary-hover);
}
.not-found__tips {
  margin: 1.75rem auto;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  text-align: left;
  max-width: 52ch;
  box-shadow: var(--shadow-sm);
}
.not-found__tips h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--c-primary);
  margin: 0 0 0.75rem;
}
.not-found__tips ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--c-text);
}
.not-found__tips li {
  margin-bottom: 0.5rem;
  line-height: 1.5;
}
.not-found__tips li:last-child {
  margin-bottom: 0;
}
.not-found__support {
  color: var(--c-text-muted);
  max-width: 52ch;
  margin: 0.5rem auto 1.5rem;
}
.not-found__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

/* ---------- Small screens ---------- */
@media (max-width: 640px) {
  .site-header__inner,
  .app-header__inner {
    flex-wrap: wrap;
  }
  .site-nav,
  .app-nav {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .site-lookup input {
    width: 7.5rem;
  }
  .hero__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .hero__actions .btn {
    justify-content: center;
  }
}
