/* ============================================================
   Tokens
   ============================================================ */
:root {
  --bg: #0b1420;
  --surface: #121f30;
  --surface-raised: #16273a;
  --border: rgba(234, 239, 245, 0.09);
  --border-strong: rgba(234, 239, 245, 0.16);

  --text-primary: #eaeff5;
  --text-secondary: #8296ad;
  --text-muted: #56687e;

  --cold: #4fa8ff;
  --mid: #b98cff;
  --hot: #ff6b4a;
  --error: #ff5470;

  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 14px;
}

* {
  box-sizing: border-box;
}

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

html, body {
  height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(79, 168, 255, 0.10), transparent 60%),
    radial-gradient(1000px 500px at 100% 110%, rgba(255, 107, 74, 0.10), transparent 60%),
    var(--bg);
  color: var(--text-primary);
  font-family: var(--font-display);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

/* ============================================================
   Layout
   ============================================================ */
.panel {
  display: flex;
  align-items: stretch;
  gap: 28px;
  width: 100%;
  max-width: 480px;
}

/* Vertical thermometer tube — the "hero": a live reading of the
   entered value against the hot/cold scale of the instrument. */
.tube {
  position: relative;
  width: 10px;
  border-radius: 999px;
  background: linear-gradient(to top, var(--cold) 0%, var(--mid) 50%, var(--hot) 100%);
  opacity: 0.28;
  flex-shrink: 0;
}

.tube__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0%;
  border-radius: 999px;
  background: linear-gradient(to top, var(--cold) 0%, var(--mid) 50%, var(--hot) 100%);
  transition: height 0.4s ease;
}

.tube__marker {
  position: absolute;
  left: 50%;
  bottom: 0%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, 50%);
  border-radius: 50%;
  background: var(--text-primary);
  box-shadow: 0 0 0 4px var(--bg), 0 0 16px rgba(234, 239, 245, 0.5);
  transition: bottom 0.4s ease;
}

.card {
  flex: 1;
  background: linear-gradient(180deg, var(--surface-raised), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.6);
}

/* ============================================================
   Header
   ============================================================ */
.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.card__header h1 {
  margin: 0 0 10px;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.sub {
  margin: 0 0 28px;
  color: var(--text-secondary);
  font-size: 14.5px;
  line-height: 1.55;
  max-width: 38ch;
}

/* ============================================================
   Form
   ============================================================ */
form {
  border: none;
  padding: 0;
  margin: 0;
}

.field {
  border: none;
  padding: 0;
  margin: 0 0 20px;
}

label, legend {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding: 0;
}

#tempValue {
  width: 100%;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 13px 14px;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-primary);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#tempValue::placeholder {
  color: var(--text-muted);
}

#tempValue:focus {
  outline: none;
  border-color: var(--cold);
  box-shadow: 0 0 0 3px rgba(79, 168, 255, 0.18);
}

#tempValue[aria-invalid="true"] {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(255, 84, 112, 0.16);
}

.field__error {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--error);
}

/* Segmented unit selector */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
}

.segmented input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  margin: 0;
  padding: 10px 6px;
  text-align: center;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  user-select: none;
}

.segmented label span {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.segmented input:checked + label {
  background: var(--surface-raised);
  color: var(--text-primary);
  box-shadow: 0 1px 0 var(--border-strong), 0 4px 14px -6px rgba(0, 0, 0, 0.6);
}

.segmented input:checked + label span {
  color: var(--cold);
}

.segmented input:focus-visible + label {
  outline: 2px solid var(--cold);
  outline-offset: 2px;
}

/* Convert button */
.convert-btn {
  width: 100%;
  padding: 13px 16px;
  margin-top: 4px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cold), var(--mid) 60%, var(--hot));
  color: #0b1420;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease;
}

.convert-btn:hover {
  filter: brightness(1.08);
}

.convert-btn:active {
  transform: translateY(1px);
}

.convert-btn:focus-visible {
  outline: 2px solid var(--text-primary);
  outline-offset: 3px;
}

/* ============================================================
   Edge case message (absolute zero, etc.)
   ============================================================ */
.edge-message {
  display: none;
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 84, 112, 0.35);
  background: rgba(255, 84, 112, 0.08);
  color: #ffb3c0;
  font-size: 13.5px;
  line-height: 1.5;
}

.edge-message.is-visible {
  display: block;
}

/* ============================================================
   Results
   ============================================================ */
.results {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 4px;
  border-radius: 8px;
  transition: background 0.15s ease;
}

.result__label {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.result__value {
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 500;
  color: var(--text-primary);
}

.result__unit {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 3px;
}

.result.is-active {
  background: rgba(79, 168, 255, 0.07);
}

.result.is-active .result__value {
  color: var(--cold);
}

/* ============================================================
   Footer
   ============================================================ */
.card__footer {
  margin-top: 24px;
}

.card__footer p {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 460px) {
  .panel {
    gap: 16px;
  }

  .card {
    padding: 28px 22px;
  }

  .segmented label span {
    display: none;
  }
}
