/* ============================================================
   CONDITION VISUALIZATIONS
   Mini-illustrations rendered inside each condition's expanded
   form (and a static version on the show page). Driven by CSS
   custom properties that Stimulus controllers write on input:
     --fill-low / --fill-high  (thermometer band, 0..100%)
     --wind-intensity          (wind streaks, 0..1)
     --wind-fill-low / --wind-fill-high (wind band, 0..100%)
     --needle-angle            (compass needle, degrees)
   ============================================================ */

/* ---- Shared condition-form scaffolding ---- */
.condition-form {
  background: var(--color-white);
  border-radius: var(--radius-2xl);
  padding: 1.6rem 1.5rem;
  box-shadow:
    0 24px 50px -18px rgba(5, 10, 50, 0.35),
    0 0 0 1px rgba(0, 0, 0, 0.04);
}

.condition-form-head {
  margin-bottom: 1.2rem;
  padding-right: 2.5rem; /* leave room for the collapse × */
}

.condition-form-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--color-dark);
}

.condition-form-sub {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: var(--color-gray-500);
  line-height: 1.45;
}

.condition-form-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: stretch;
}

.condition-form-body--thermo {
  grid-template-columns: 110px 1fr;
}

@media (max-width: 540px) {
  .condition-form-body--thermo {
    grid-template-columns: 80px 1fr;
  }
}

.condition-form-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  align-content: start;
}

@media (max-width: 480px) {
  .condition-form-inputs {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   RANGE INPUT (paired slider + number)
   ============================================================ */

.range-input {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.range-input__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--color-surface), #e0e6f4);
  outline: none;
  margin: 0.25rem 0;
  cursor: grab;
}

.range-input__slider:active { cursor: grabbing; }

/* WebKit thumb */
.range-input__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gradient-primary);
  border: 3px solid var(--color-white);
  box-shadow: 0 3px 10px rgba(255, 107, 53, 0.4);
  cursor: grab;
  transition: transform 0.12s, box-shadow 0.15s;
}

.range-input__slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  box-shadow: 0 5px 14px rgba(255, 107, 53, 0.55);
}

.range-input__slider:active::-webkit-slider-thumb { cursor: grabbing; }

/* Firefox thumb */
.range-input__slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--color-primary);
  border: 3px solid var(--color-white);
  box-shadow: 0 3px 10px rgba(255, 107, 53, 0.4);
  cursor: grab;
}

/* Max slider gets a teal thumb to distinguish from min */
.range-input__slider--max::-webkit-slider-thumb {
  background: linear-gradient(135deg, var(--color-accent), #2e9a91);
  box-shadow: 0 3px 10px rgba(78, 205, 196, 0.45);
}
.range-input__slider--max::-moz-range-thumb {
  background: var(--color-accent);
  box-shadow: 0 3px 10px rgba(78, 205, 196, 0.45);
}

.range-input__number-wrap {
  position: relative;
}

.range-input__number {
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
  text-align: left;
}

/* ============================================================
   THERMOMETER VIZ
   ============================================================ */

.thermo-viz {
  --fill-low: 0%;
  --fill-high: 100%;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  position: relative;
}

.thermo-viz__track {
  position: relative;
  width: 38px;
  border-radius: var(--radius-full);
  background: var(--gradient-thermo);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.5),
    0 6px 14px rgba(5, 10, 50, 0.18);
  overflow: hidden;
  min-height: 200px;
}

/* The thermometer renders vertically with HOT at the top of the track
   (--gradient-thermo goes 180deg = top→bottom, hot→cold). The Stimulus
   controller writes --fill-low / --fill-high as fractions along the
   axis from MIN (-10°C, bottom) to MAX (+40°C, top), so a higher
   fraction sits closer to the top. We dim the bands outside [min, max]
   by layering two semi-opaque masks. */
.thermo-viz__track::before,
.thermo-viz__track::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.78);
  pointer-events: none;
  transition: top 0.25s ease, bottom 0.25s ease;
}

/* Top mask: dims everything above the max */
.thermo-viz__track::before {
  top: 0;
  bottom: var(--fill-high);
}

/* Bottom mask: dims everything below the min */
.thermo-viz__track::after {
  top: calc(100% - var(--fill-low));
  bottom: 0;
}

/* Handle indicators (rendered on top of the masks) */
.thermo-viz__handle {
  position: absolute;
  left: -8px;
  right: -8px;
  height: 4px;
  background: var(--color-dark);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-full);
  pointer-events: none;
  transition: bottom 0.25s ease, top 0.25s ease;
  z-index: 2;
}

.thermo-viz__handle span {
  position: absolute;
  right: -2.5rem;
  top: -0.55rem;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-gray-500);
}

.thermo-viz__handle--max {
  bottom: var(--fill-high);
}

.thermo-viz__handle--min {
  bottom: var(--fill-low);
}

.thermo-viz--max-empty .thermo-viz__handle--max,
.thermo-viz--max-empty .thermo-viz__track::before {
  opacity: 0;
}

.thermo-viz--min-empty .thermo-viz__handle--min,
.thermo-viz--min-empty .thermo-viz__track::after {
  opacity: 0;
}

.thermo-viz__legend {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-gray-400);
  letter-spacing: 0.04em;
  padding: 0.25rem 0;
}

/* Mini thermometer for show-page summary */
.thermo-viz--mini .thermo-viz__track {
  min-height: 100px;
  width: 24px;
}

.thermo-viz--mini .thermo-viz__handle {
  height: 3px;
}

.thermo-viz--mini .thermo-viz__handle span { display: none; }

.thermo-viz--mini .thermo-viz__legend { font-size: 0.65rem; }

@media (prefers-reduced-motion: reduce) {
  .thermo-viz__track::before,
  .thermo-viz__track::after,
  .thermo-viz__handle {
    transition: none;
  }
}

/* ============================================================
   WIND VIZ
   ============================================================ */

.wind-viz {
  --wind-intensity: 0.3;
  --wind-fill-low: 0%;
  --wind-fill-high: 100%;
  position: relative;
  height: 110px;
  border-radius: var(--radius-xl);
  background: linear-gradient(160deg, #0d1b6e 0%, #1a3a8f 60%, #2d6abf 100%);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 8px 18px rgba(5, 10, 50, 0.25);
}

.wind-viz__sky {
  position: absolute;
  inset: 0;
}

.wind-viz__streak {
  position: absolute;
  height: 2px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85) 40%, transparent);
  /* duration shrinks as intensity grows: 4s at 0, 0.6s at 1 */
  animation: wind-streak calc(0.6s + (1 - var(--wind-intensity)) * 3.4s) linear infinite;
  opacity: calc(0.35 + var(--wind-intensity) * 0.55);
  width: calc(60px + var(--wind-intensity) * 140px);
}

.wind-viz__streak--1 { top: 16%; left: -40%; animation-delay: 0.0s; }
.wind-viz__streak--2 { top: 30%; left: -50%; animation-delay: 0.4s; }
.wind-viz__streak--3 { top: 46%; left: -35%; animation-delay: 0.9s; }
.wind-viz__streak--4 { top: 62%; left: -55%; animation-delay: 0.2s; }
.wind-viz__streak--5 { top: 76%; left: -30%; animation-delay: 0.7s; }
.wind-viz__streak--6 { top: 88%; left: -45%; animation-delay: 1.1s; }

@keyframes wind-streak {
  0%   { transform: translateX(0); }
  100% { transform: translateX(220%); }
}

.wind-viz__readout {
  position: absolute;
  right: 1.1rem;
  bottom: 0.8rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  color: var(--color-white);
  background: rgba(0, 0, 0, 0.32);
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  z-index: 2;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.wind-viz__readout-value {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}

.wind-viz__readout-unit {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.78;
}

/* Mini wind viz for show-page summary */
.wind-viz--mini {
  height: 70px;
}

.wind-viz--mini .wind-viz__readout {
  right: 0.7rem;
  bottom: 0.5rem;
  padding: 0.25rem 0.65rem;
}

.wind-viz--mini .wind-viz__readout-value { font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
  .wind-viz__streak {
    animation: none;
    transform: translateX(60%);
    opacity: 0.4;
  }
}

/* ============================================================
   COMPASS NEEDLE (center of the existing wind-direction compass)
   ============================================================ */

.compass {
  --needle-angle: 0deg;
}

.compass-needle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 78px;
  margin-top: -52px;     /* needle pivots near its base */
  margin-left: -2px;
  transform-origin: 50% calc(100% - 26px);
  transform: rotate(var(--needle-angle));
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-end) 55%, rgba(255, 217, 61, 0) 100%);
  border-radius: var(--radius-full);
  pointer-events: none;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 6px rgba(255, 107, 53, 0.45));
  z-index: 3;
}

.compass-needle::before {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--color-white);
  box-shadow:
    0 0 0 3px var(--color-primary),
    0 2px 8px rgba(0, 0, 0, 0.2);
}

.compass--no-direction .compass-needle {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .compass-needle {
    transition: none;
  }
}
