:root {
  color-scheme: dark;
  --white: #ffffff;
  --soft-white: rgba(255, 255, 255, 0.82);
  --muted-white: rgba(255, 255, 255, 0.66);
  --glass: rgba(8, 17, 28, 0.48);
  --glass-strong: rgba(8, 17, 28, 0.62);
  --line: rgba(255, 255, 255, 0.24);
  --line-soft: rgba(255, 255, 255, 0.13);
  --temp: #ffd166;
  --rain: #77d6ff;
  --accent: #ff3d5a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--white);
  background: #0b121c;
  letter-spacing: 0;
}

button {
  font: inherit;
}

.weather-stage {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  padding: clamp(18px, 4vw, 48px);
  background:
    linear-gradient(180deg, rgba(2, 10, 18, 0.08) 0%, rgba(2, 10, 18, 0.08) 34%, rgba(2, 10, 18, 0.28) 100%),
    url("assets/bg.jpg") center center / cover no-repeat;
}

.weather-stage::before {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(110deg, rgba(3, 10, 18, 0.46), transparent 42%),
    linear-gradient(250deg, rgba(3, 10, 18, 0.44), transparent 46%),
    linear-gradient(0deg, rgba(3, 10, 18, 0.18), transparent 48%);
  pointer-events: none;
}

.glass-panel {
  position: absolute;
  z-index: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--glass);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.25);
}

.date-picker {
  position: absolute;
  top: clamp(14px, 2.2vh, 24px);
  left: 50%;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(56px, 1fr));
  gap: 5px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: rgba(8, 17, 28, 0.34);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(14px) saturate(1.2);
  transform: translateX(-50%);
}

.date-picker button {
  display: grid;
  min-height: 42px;
  min-width: 0;
  align-content: center;
  gap: 1px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--soft-white);
  background: transparent;
  cursor: pointer;
}

.date-picker button:hover,
.date-picker button:focus-visible {
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

.date-picker button.is-active {
  border-color: rgba(255, 209, 102, 0.5);
  color: var(--white);
  background: rgba(255, 209, 102, 0.16);
}

.date-picker button[disabled] {
  cursor: progress;
  opacity: 0.65;
}

.date-picker span {
  font-size: 0.73rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.date-picker strong {
  font-size: 0.82rem;
  font-weight: 780;
  white-space: nowrap;
}

.summary-panel {
  top: clamp(82px, 11vh, 118px);
  left: clamp(18px, 4vw, 58px);
  width: min(460px, calc(100vw - 36px));
  padding: clamp(18px, 2.6vw, 28px);
}

.chart-panel {
  top: clamp(82px, 11vh, 118px);
  right: clamp(18px, 4vw, 58px);
  width: clamp(380px, 38vw, 560px);
  padding: 18px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--muted-white);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 5.1rem);
  line-height: 0.95;
  letter-spacing: 0;
  text-wrap: balance;
}

h2 {
  font-size: clamp(1.25rem, 1.8vw, 1.7rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.metrics article {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.09);
}

.metrics span {
  display: block;
  color: var(--muted-white);
  font-size: 0.82rem;
}

.metrics strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.42rem, 2.5vw, 2rem);
  line-height: 1;
  overflow-wrap: anywhere;
}

.summary-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}

.chart-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--soft-white);
  font-size: 0.78rem;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 22px;
  height: 10px;
}

.temp-key {
  border-top: 3px solid var(--temp);
}

.rain-key {
  border-radius: 3px 3px 0 0;
  background: rgba(119, 214, 255, 0.55);
}

.chart-wrap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 0;
  min-height: 250px;
}

#weather-chart {
  display: block;
  width: 100%;
  height: 250px;
}

.rain-scale {
  display: grid;
  height: 250px;
  grid-template-rows: 18px 1fr 2fr 1fr 30px;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.64rem;
  width: max-content;
  min-width: 0;
  margin-left: 0;
}

.rain-unit {
  align-self: start;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 700;
  padding-left: 0;
  white-space: nowrap;
}

.rain-band {
  display: flex;
  align-items: center;
  padding-left: 2px;
  white-space: nowrap;
}

.rain-band.heavy {
  color: rgba(255, 210, 220, 0.82);
}

.rain-band.moderate {
  color: rgba(255, 226, 160, 0.82);
}

.rain-band.light {
  color: rgba(170, 228, 255, 0.82);
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--soft-white);
  text-align: center;
  background: rgba(8, 17, 28, 0.62);
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  width: max-content;
  max-width: min(230px, calc(100vw - 48px));
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--white);
  background: rgba(8, 17, 28, 0.9);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.35);
  font-size: 0.84rem;
  pointer-events: none;
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 980px) {
  .weather-stage {
    display: flex;
    min-height: 100svh;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    overflow: auto;
    background-position: center top;
  }

  .glass-panel,
  .date-picker {
    position: relative;
    inset: auto;
  }

  .date-picker {
    width: min(100%, 360px);
    align-self: center;
    transform: none;
  }

  .summary-panel,
  .chart-panel {
    width: min(100%, 620px);
  }
}

@media (max-width: 520px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .weather-stage {
    display: grid;
    height: 100svh;
    min-height: 100svh;
    grid-template-rows: auto auto auto;
    gap: 8px;
    padding: 10px;
    overflow: hidden;
    touch-action: pan-y;
  }

  .summary-panel,
  .chart-panel {
    width: 100%;
    align-self: start;
    padding: 12px;
    overflow: hidden;
  }

  .date-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    padding: 4px;
  }

  .date-picker button {
    min-height: 42px;
    padding: 4px 6px;
  }

  .date-picker span {
    font-size: 0.68rem;
  }

  .date-picker strong {
    font-size: 0.78rem;
  }

  .eyebrow {
    margin-bottom: 6px;
    font-size: 0.68rem;
  }

  h1 {
    font-size: clamp(2.15rem, 11vw, 2.75rem);
    line-height: 0.93;
  }

  h2 {
    font-size: 1.16rem;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    margin-top: 12px;
  }

  .metrics article {
    min-height: 58px;
    padding: 9px 10px;
  }

  .metrics span {
    font-size: 0.72rem;
  }

  .metrics strong {
    margin-top: 4px;
    font-size: clamp(1.15rem, 6.6vw, 1.52rem);
  }

  .chart-heading {
    align-items: end;
    flex-direction: row;
    gap: 8px;
    margin-bottom: 8px;
  }

  .legend {
    justify-content: flex-start;
    gap: 8px;
    font-size: 0.68rem;
  }

  .legend i {
    width: 18px;
    height: 8px;
  }

  .chart-wrap {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 0;
    min-height: 205px;
  }

  #weather-chart,
  .rain-scale {
    height: 205px;
  }

  .rain-scale {
    font-size: 0.62rem;
    grid-template-rows: 18px 1fr 2fr 1fr 20px;
  }

  .chart-empty {
    font-size: 0.86rem;
  }
}

@media (max-width: 380px), (max-width: 520px) and (max-height: 720px) {
  .weather-stage {
    gap: 7px;
    padding: 8px;
  }

  .summary-panel,
  .chart-panel {
    padding: 10px;
  }

  .date-picker button {
    min-height: 38px;
  }

  h1 {
    font-size: clamp(1.95rem, 10vw, 2.35rem);
  }

  .metrics {
    gap: 6px;
    margin-top: 10px;
  }

  .metrics article {
    min-height: 52px;
    padding: 8px;
  }

  .metrics strong {
    font-size: clamp(1.05rem, 5.8vw, 1.34rem);
  }

  .chart-wrap {
    min-height: 178px;
  }

  #weather-chart,
  .rain-scale {
    height: 178px;
  }
}
