/* ==========================================================================
   Indoor Temperature Estimator
   Design: "instrument panel" theme, light by default with a dark mode
   toggle. Signature element is the cold→hot spectrum gauge in the result
   card, present in both themes.
   ========================================================================== */

:root {
  /* Light theme (default) */
  --bg: #f5f7fa;
  --bg-raised: #ffffff;
  --bg-card: #ffffff;
  --border: #dbe2ea;
  --text: #131a22;
  --text-muted: #57636f;
  --text-faint: #7c8794;

  /* Decorative fills — used on gradients/badges, same in both themes */
  --cold: #4fb6e8;
  --cold-strong: #2f8fc4;
  --warm: #f2994a;
  --warm-strong: #e2773f;
  --comfortable: #34c17e;

  /* Text-safe accent variants — tuned per theme for contrast */
  --accent-cold-text: #0f6fa3;
  --accent-warm-text: #a8560a;
  --accent-comfortable-text: #147a4d;

  --focus-ring: #0f6fa3;

  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;

  --max-width: 760px;
}

html[data-theme="dark"] {
  --bg: #10161d;
  --bg-raised: #171f28;
  --bg-card: #1b2430;
  --border: #2a3542;
  --text: #eef1f5;
  --text-muted: #93a0b0;
  --text-faint: #66748a;

  --comfortable: #6fcf97;

  --accent-cold-text: #7cd4ff;
  --accent-warm-text: #f2994a;
  --accent-comfortable-text: #6fcf97;

  --focus-ring: #7cd4ff;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  background: var(--bg);
  background-image:
    radial-gradient(60vw 40vh at 15% -10%, rgba(79, 182, 232, 0.1), transparent 60%),
    radial-gradient(50vw 35vh at 100% 10%, rgba(242, 153, 74, 0.08), transparent 60%);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}
@media (prefers-reduced-motion: reduce) {
  body {
    transition: none;
  }
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  background: var(--focus-ring);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 100;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 12px;
}

/* ---------- Focus states ---------- */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
input:focus-visible + label,
.text-btn:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
input[type="number"]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

/* ---------- Header ---------- */
.site-header {
  padding: 56px 0 36px;
  border-bottom: 1px solid var(--border);
}
.header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap-reverse;
}
.header-text {
  flex: 1 1 320px;
  min-width: 0;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}
.theme-toggle:hover {
  border-color: var(--accent-cold-text);
}
.theme-toggle-icon {
  font-size: 1rem;
  line-height: 1;
}
.eyebrow {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  color: var(--accent-cold-text);
  margin: 0 0 12px;
}
h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.75rem);
  line-height: 1.08;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}
.lede {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 46ch;
  margin: 0;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.005em;
  margin: 0 0 12px;
}
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 28px 0 8px;
}
p {
  margin: 0 0 12px;
}

/* ---------- Calculator ---------- */
.calculator {
  padding: 40px 20px 8px;
}

.step {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-lg);
  padding: 22px 22px 26px;
  margin: 0 0 18px;
}

legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0 4px 14px;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cold), var(--warm));
  color: #0b1016;
  font-size: 0.85rem;
  font-weight: 700;
  flex: none;
}

.subgroup + .subgroup {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px dashed var(--border);
}

.field-label {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 10px;
  font-weight: 500;
}

/* ---------- Outdoor temperature panel ---------- */
.outdoor-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.outdoor-readout {
  flex: 1 1 220px;
  min-width: 0;
}

.outdoor-value-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
}

#outdoor-temp {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  padding: 4px 0;
  appearance: textfield;
}
#outdoor-temp::-webkit-outer-spin-button,
#outdoor-temp::-webkit-inner-spin-button {
  appearance: auto;
}

.unit-suffix {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-muted);
}

.outdoor-status {
  margin: 10px 2px 0;
  font-size: 0.85rem;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.outdoor-status.is-detected::before {
  content: "📍";
}
.outdoor-status.is-manual::before {
  content: "✍️";
}
.outdoor-status.is-error {
  color: var(--accent-warm-text);
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent-cold-text);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 2px 0;
  cursor: pointer;
  text-decoration: underline;
}

.unit-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  flex: none;
}
.unit-toggle input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.unit-toggle label {
  padding: 10px 18px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.unit-toggle input:checked + label {
  background: var(--bg-card);
  color: var(--text);
}

/* ---------- Toggle groups (radio-as-button) ---------- */
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.toggle-group input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.toggle-group label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  text-align: center;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.toggle-group label:hover {
  border-color: var(--cold);
}
.toggle-group input:checked + label {
  background: linear-gradient(135deg, var(--cold), var(--cold-strong));
  border-color: var(--cold);
  color: #04202e;
  font-weight: 600;
}
.toggle-group--duration label {
  padding: 10px 14px;
  font-size: 0.86rem;
  flex: 1 1 auto;
}

.duration-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.target-row {
  margin-bottom: 18px;
}
.target-row .field-label {
  margin-bottom: 8px;
}
.select-field {
  display: block;
  width: 100%;
  max-width: 220px;
  padding: 11px 14px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 15px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.select-field:hover {
  border-color: var(--accent-cold-text);
}
.select-field:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.hint {
  margin: 12px 2px 0;
  font-size: 0.82rem;
  color: var(--accent-warm-text);
}

/* ---------- Errors & submit ---------- */
.form-error {
  background: rgba(242, 153, 74, 0.12);
  border: 1px solid var(--warm);
  color: var(--accent-warm-text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.9rem;
  margin: 0 0 18px;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 16px 20px;
  min-height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--cold), var(--warm));
  color: #0b1016;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  margin: 8px 0 40px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary:hover {
  box-shadow: 0 8px 24px rgba(79, 182, 232, 0.25);
}
.btn-primary:active {
  transform: translateY(1px);
}

/* ---------- Result card ---------- */
.result-card {
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 26px;
  margin: 0 0 48px;
  text-align: center;
  animation: rise 0.4s ease both;
}

@media (prefers-reduced-motion: reduce) {
  .result-card {
    animation: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-heading {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.result-headline {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.result-temp {
  font-family: var(--font-display);
  font-size: clamp(3.2rem, 12vw, 4.6rem);
  font-weight: 700;
  line-height: 1;
}
.result-temp-secondary {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--text-muted);
}

.result-range {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* Signature: cold-to-hot spectrum gauge */
.gauge {
  position: relative;
  max-width: 420px;
  margin: 0 auto 26px;
}
.gauge-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    var(--cold) 0%,
    var(--comfortable) 45%,
    var(--comfortable) 60%,
    var(--warm) 100%
  );
}
.gauge-marker {
  position: absolute;
  top: -7px;
  left: 0%;
  width: 24px;
  height: 24px;
  margin-left: -12px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--text);
  box-shadow: 0 0 0 4px rgba(238, 241, 245, 0.12);
  transition: left 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
@media (prefers-reduced-motion: reduce) {
  .gauge-marker {
    transition: none;
  }
}
.gauge-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.gauge-labels span:nth-child(2) {
  flex: 1;
  text-align: center;
}

.result-tags {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 28px;
}
.tag {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(111, 207, 151, 0.15);
  color: var(--accent-comfortable-text);
  border: 1px solid rgba(111, 207, 151, 0.3);
}
.tag--muted {
  background: rgba(147, 160, 176, 0.12);
  color: var(--text-muted);
  border-color: var(--border);
}
.tag[data-tone="cold"] {
  background: rgba(79, 182, 232, 0.15);
  color: var(--accent-cold-text);
  border-color: rgba(79, 182, 232, 0.3);
}
.tag[data-tone="warm"] {
  background: rgba(242, 153, 74, 0.15);
  color: var(--accent-warm-text);
  border-color: rgba(242, 153, 74, 0.3);
}
.tag[data-tone="comfortable"] {
  background: rgba(111, 207, 151, 0.15);
  color: var(--accent-comfortable-text);
  border-color: rgba(111, 207, 151, 0.3);
}

.why-heading {
  text-align: left;
  margin-top: 0;
}
.why-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  text-align: left;
  display: grid;
  gap: 8px;
}
.why-list li {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
}

.explanation {
  text-align: left;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0;
  padding-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ---------- Info / SEO content ---------- */
.info {
  padding: 20px 20px 60px;
  border-top: 1px solid var(--border);
  margin-top: 20px;
}
.info p {
  color: var(--text-muted);
  max-width: 68ch;
}

.faq {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}
.faq details {
  border: 1px solid var(--border);
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  padding: 4px 18px;
}
.faq summary {
  cursor: pointer;
  padding: 14px 0;
  font-weight: 600;
  font-family: var(--font-display);
  list-style: none;
}
.faq summary::-webkit-details-marker {
  display: none;
}
.faq summary::before {
  content: "+";
  color: var(--accent-cold-text);
  font-weight: 700;
  margin-right: 10px;
}
.faq details[open] summary::before {
  content: "–";
}
.faq details p {
  padding-bottom: 14px;
  margin: 0;
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0 60px;
}
.disclaimer {
  color: var(--text-faint);
  font-size: 0.82rem;
  max-width: 62ch;
  margin: 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  /* Header: stack and center everything instead of the two-column
     layout, which could strand the theme toggle awkwardly on narrow
     screens. */
  .header-row {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 18px;
  }
  .header-text {
    flex: none;
    width: 100%;
  }
  .lede {
    margin: 0 auto;
  }
  .theme-toggle {
    align-self: center;
  }

  .calculator {
    padding: 28px 16px 4px;
  }
  .step {
    padding: 18px 16px 22px;
  }

  /* Duration buttons: full-width stack instead of a cramped row. */
  .toggle-group--duration {
    flex-direction: column;
  }
  .toggle-group--duration label {
    width: 100%;
  }

  /* Non-duration toggle groups (2–3 buttons) previously packed to the
     left with dead space on the right — center them instead. */
  .toggle-group:not(.toggle-group--duration) {
    justify-content: center;
  }
  .toggle-group:not(.toggle-group--duration) label {
    flex: 1 1 0;
  }

  /* Outdoor temperature row: stack the reading above the °C/°F toggle
     and center the toggle instead of letting it hug the left edge. */
  .outdoor-panel {
    flex-direction: column;
    align-items: center;
  }
  .outdoor-readout {
    width: 100%;
  }
  .unit-toggle {
    align-self: center;
  }

  /* AC/heater set-temperature dropdown: fill the row instead of
     being capped at 220px and left-aligned with empty space beside it. */
  .select-field {
    max-width: 100%;
  }

  .result-tags {
    flex-direction: column;
    align-items: center;
  }
}

/* ---------- Mobile fixes ---------- */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

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

@media (max-width: 600px) {
  .wrap {
    width: 100%;
    max-width: 100%;
    padding-left: 16px;
    padding-right: 16px;
  }

  .site-header {
    padding: 32px 0 24px;
  }

  h1 {
    font-size: 2rem;
  }

  .lede {
    font-size: 0.95rem;
  }

  .calculator {
    width: 100%;
    padding: 24px 12px 4px;
  }

  .step {
    width: 100%;
    padding: 16px 14px 20px;
  }

  .toggle-group {
    width: 100%;
  }

  .toggle-group label {
    min-width: 0;
    max-width: 100%;
  }

  .outdoor-value-row {
    width: 100%;
  }

  #outdoor-temp {
    width: 100%;
    min-width: 0;
    font-size: 1.75rem;
  }

  .result-card {
    width: 100%;
    padding: 26px 16px;
  }

  .result-temp {
    font-size: 3.2rem;
  }
}