﻿
:root {
  color-scheme: light dark;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #d4d4d8;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-low: #fb923c;
  --color-normal: #22c55e;
  --color-high: #f43f5e;
  --color-focus: #2563eb;
  --max-width: 720px;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  background: #0ea5e9;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  z-index: 10;
  text-decoration: none;
}

.skip-link:focus-visible {
  top: 1rem;
}

img,
svg,
video {
  max-width: 100%;
  height: auto;
}

.container {
  width: min(100%, var(--max-width));
  margin-inline: auto;
  padding: 1.5rem;
}

.stack {
  display: grid;
  gap: 1.5rem;
}

.site-header,
.site-footer {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  border-bottom: none;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 10px 30px rgb(15 23 42 / 0.06);
}

.panel__header > h2 {
  margin-top: 0;
}

.lede {
  color: var(--color-muted);
  max-width: 42ch;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid .full-span {
  grid-column: 1 / -1;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    align-items: end;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-weight: 600;
}

.field input,
.field select {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  font: inherit;
  background: #fff;
}

input.field--invalid,
select.field--invalid {
  border-color: var(--color-high);
  background: rgb(244 63 94 / 0.08);
}

.field-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-muted);
}

.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.3);
}

.field-error {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-high);
}

.primary-btn {
  border: none;
  border-radius: 999px;
  padding: 0.8rem 1.5rem;
  font-weight: 600;
  background: #0ea5e9;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgb(14 165 233 / 0.2);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.primary-btn.full-span {
  width: 100%;
  justify-self: start;
}

.secondary-btn {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.75rem 1.4rem;
  font-weight: 600;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.secondary-btn:hover {
  border-color: var(--color-focus);
  color: var(--color-focus);
}

.secondary-btn:focus-visible {
  outline: none;
  border-color: var(--color-focus);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.25);
}

.secondary-btn.full-span {
  width: 100%;
  justify-self: start;
}

.results {
  margin-top: 1.5rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgb(15 23 42 / 0.05);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.results__value {
  font-size: clamp(1.35rem, 3.5vw, 2.4rem);
  margin: 0;
}

.results__category {
  margin: 0;
  font-weight: 600;
}

.results--target .results__value {
  font-size: clamp(1.25rem, 3.2vw, 2.1rem);
  line-height: 1.2;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 640px) {
  .legend {
    flex-direction: row;
    justify-content: space-between;
  }

  .legend__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
  }
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.legend__item p {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.legend__swatch {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 0.35rem;
}

.legend__swatch--low {
  background: var(--color-low);
}

.legend__swatch--normal {
  background: var(--color-normal);
}

.legend__swatch--high {
  background: var(--color-high);
}

.category-low {
  border-color: var(--color-low);
  color: var(--color-low);
  background: rgb(251 146 60 / 0.1);
}

.category-normal {
  border-color: var(--color-normal);
  color: var(--color-normal);
  background: rgb(34 197 94 / 0.1);
}

.category-high {
  border-color: var(--color-high);
  color: var(--color-high);
  background: rgb(244 63 94 / 0.1);
}

@media (min-width: 768px) {
  .stack {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 3px;
}

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