/* ============================================================================
   Meteo Online — погодные секции
   ========================================================================== */

/* --- Карточка ------------------------------------------------------------- */
.card {
  min-width: 0;
  padding: var(--sp-4);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.card-head h2 {
  font-size: var(--text-base);
}

.card-meta {
  color: var(--ink-3);
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* --- Иконки погоды -------------------------------------------------------- */
.weather-icon {
  display: inline-block;
  flex: none;
}

.weather-icon svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* ============================================================================
   Главный блок
   ========================================================================== */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-width: 0;
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  border-radius: var(--r-xl);
  background:
    radial-gradient(120% 100% at 100% 0%, var(--glow-a), transparent 62%),
    radial-gradient(100% 80% at 0% 100%, var(--glow-b), transparent 60%),
    var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
}

/* Подсветка по погоде и времени суток */
.hero[data-cond="clear"][data-day="1"] {
  --glow-a: rgba(42, 99, 240, 0.18);
  --glow-b: rgba(255, 176, 32, 0.16);
}

.hero[data-cond="clear"][data-day="0"] {
  --glow-a: rgba(76, 63, 196, 0.24);
  --glow-b: rgba(42, 99, 240, 0.1);
}

.hero[data-cond="cloudy"] {
  --glow-a: rgba(100, 116, 150, 0.18);
  --glow-b: rgba(42, 99, 240, 0.1);
}

.hero[data-cond="rain"] {
  --glow-a: rgba(31, 85, 214, 0.2);
  --glow-b: rgba(15, 166, 149, 0.14);
}

.hero[data-cond="snow"] {
  --glow-a: rgba(91, 155, 232, 0.2);
  --glow-b: rgba(18, 181, 165, 0.12);
}

.hero[data-cond="storm"] {
  --glow-a: rgba(94, 58, 196, 0.26);
  --glow-b: rgba(245, 158, 11, 0.12);
}

.hero[data-cond="fog"] {
  --glow-a: rgba(120, 132, 160, 0.26);
  --glow-b: rgba(100, 116, 150, 0.12);
}

[data-theme="dark"] .hero[data-cond="clear"][data-day="1"] {
  --glow-a: rgba(109, 151, 255, 0.24);
  --glow-b: rgba(255, 176, 32, 0.14);
}

[data-theme="dark"] .hero[data-cond="clear"][data-day="0"] {
  --glow-a: rgba(129, 112, 255, 0.26);
  --glow-b: rgba(109, 151, 255, 0.12);
}

[data-theme="dark"] .hero[data-cond="cloudy"] {
  --glow-a: rgba(140, 160, 200, 0.2);
  --glow-b: rgba(109, 151, 255, 0.1);
}

[data-theme="dark"] .hero[data-cond="rain"] {
  --glow-a: rgba(70, 120, 240, 0.28);
  --glow-b: rgba(44, 211, 192, 0.14);
}

[data-theme="dark"] .hero[data-cond="snow"] {
  --glow-a: rgba(110, 170, 255, 0.24);
  --glow-b: rgba(44, 211, 192, 0.12);
}

[data-theme="dark"] .hero[data-cond="storm"] {
  --glow-a: rgba(140, 96, 240, 0.3);
  --glow-b: rgba(251, 191, 36, 0.14);
}

[data-theme="dark"] .hero[data-cond="fog"] {
  --glow-a: rgba(150, 165, 195, 0.22);
  --glow-b: rgba(140, 160, 200, 0.1);
}

.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
}

.hero-place {
  min-width: 0;
}

.eyebrow {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-title {
  margin-top: 2px;
  font-size: clamp(var(--text-2xl), 8vw, var(--text-3xl));
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.sep {
  flex: none;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-3);
}

.fav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.fav-btn:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.fav-btn:active {
  transform: scale(0.92);
}

.fav-btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}

.fav-btn[aria-pressed="true"] .icon-star {
  display: none;
}

.fav-btn[aria-pressed="false"] .icon-star-filled {
  display: none;
}

.fav-btn.is-pop .icon-star-filled {
  animation: star-pop var(--dur-slow) var(--ease-spring);
}

@keyframes star-pop {
  0% {
    transform: scale(0.4) rotate(-30deg);
  }
  100% {
    transform: none;
  }
}

.fav-label {
  display: none;
}

.hero-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-5);
  margin-top: var(--sp-5);
}

.hero-temp-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.hero-icon {
  width: 96px;
  height: 96px;
  filter: drop-shadow(0 12px 20px rgba(42, 99, 240, 0.16));
}

.hero-temp-wrap {
  display: flex;
  align-items: flex-start;
}

.hero-temp {
  font-size: clamp(4.5rem, 23vw, 5.5rem);
  font-weight: var(--weight-heavy);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.hero-degree {
  margin-top: 0.1em;
  font-size: clamp(2.25rem, 11.5vw, 2.75rem);
  font-weight: var(--weight-heavy);
  line-height: 1;
}

.hero-cond {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.hero-summary {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
}

.hero-feels {
  color: var(--ink-2);
}

.hero-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.hero-facts li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.hero-facts span {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.hero-facts strong {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

/* На телефонах от 360 px факты — в одну строку: первый экран компактнее */
@media (min-width: 360px) {
  .hero-facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sp-1);
  }

  .hero-facts li {
    padding: var(--sp-2);
  }

  .hero-facts span {
    font-size: 11px;
  }

  .hero-facts strong {
    font-size: var(--text-sm);
  }
}

.hour-wind .icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 1px;
  vertical-align: -1px;
}

/* ============================================================================
   Почасовой прогноз
   ========================================================================== */
.hourly-scroll {
  margin-inline: calc(var(--sp-4) * -1);
  padding: 2px var(--sp-4) var(--sp-2);
}

.hourly-track {
  position: relative;
  display: inline-flex;
  min-width: 100%;
}

.hourly-list {
  display: flex;
}

.hourly-curve {
  position: absolute;
  left: 0;
  width: 100%;
  height: 40px;
  pointer-events: none;
  overflow: visible;
}

.hourly-curve .curve-area {
  fill: var(--accent-soft);
}

.hourly-curve .curve-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.hourly-curve .curve-dot {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.hour {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 64px;
  padding-bottom: var(--sp-1);
}

.hour-time {
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.hour:first-child .hour-time {
  color: var(--accent);
}

.hour-precip {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  min-height: 16px;
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: var(--weight-bold);
}

.hour-precip.is-wet {
  color: var(--rain-ink);
}

.hour-precip .icon {
  width: 10px;
  height: 10px;
}

.hour-icon {
  width: 32px;
  height: 32px;
  margin-top: 2px;
}

.hour-band {
  height: 40px;
}

.hour-temp {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
}

.hour-wind {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 11px;
  white-space: nowrap;
}

/* ============================================================================
   Прогноз на 7 дней
   ========================================================================== */
.day {
  display: grid;
  grid-template-columns: minmax(78px, auto) 30px 34px minmax(40px, 1fr) 34px;
  align-items: center;
  gap: var(--sp-2);
  min-height: 50px;
  padding: var(--sp-1) 0;
}

.day + .day {
  border-top: 1px solid var(--line);
}

.day-name {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: var(--leading-snug);
}

.day-weekday {
  font-weight: var(--weight-bold);
}

.day:first-child .day-weekday {
  color: var(--accent);
}

.day-date {
  color: var(--ink-3);
  font-size: var(--text-xs);
}

/* Вероятность осадков: обычная — приглушённая, от 30% — цветом дождя */
.day-precip-inline {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.day-precip-inline.is-wet {
  color: var(--rain-ink);
}

.day-precip-inline:empty,
.day-precip:empty {
  display: none;
}

.day-precip {
  display: none;
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.day-precip.is-wet {
  color: var(--rain-ink);
}

/* Количество осадков показывается только на широких экранах */
.day-precip-amount {
  display: none;
  margin-left: 4px;
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
}

.day-precip .icon {
  width: 10px;
  height: 10px;
  margin-right: 1px;
}

.day-icon {
  width: 28px;
  height: 28px;
}

.day-min,
.day-max {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  text-align: right;
}

.day-min {
  color: var(--ink-3);
}

.day-range-track {
  position: relative;
  display: block;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}

.day-range-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 6px;
  border-radius: var(--r-pill);
}

.day-now {
  position: absolute;
  top: 50%;
  left: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--surface);
  transform: translate(-50%, -50%);
}

/* ============================================================================
   Подробно
   ========================================================================== */
.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-2);
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 116px;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* Ветер: текст слева, компас справа; на телефоне плитка на всю ширину */
.tile--wind {
  grid-column: 1 / -1;
}

.tile-title {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.tile-title .icon {
  width: 14px;
  height: 14px;
}

.tile-value {
  margin-top: var(--sp-2);
  font-size: var(--text-xl);
  font-weight: var(--weight-heavy);
  line-height: 1.2;
}

.tile-value small {
  margin-left: 2px;
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}

.tile-sub {
  color: var(--ink-3);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}

.tile-visual {
  margin-top: auto;
  padding-top: var(--sp-2);
}

/* Ветер: текст слева, компас справа */
.tile--wind {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto 1fr;
  column-gap: var(--sp-3);
  align-items: start;
}

.tile--wind .tile-title,
.tile--wind .tile-value,
.tile--wind .tile-sub {
  grid-column: 1;
}

.tile--wind .tile-visual {
  grid-column: 2;
  grid-row: 1 / -1;
  align-self: center;
  margin: 0;
  padding: 0;
}

.compass {
  width: 76px;
  height: 76px;
}

.compass-ring {
  fill: none;
  stroke: var(--line-strong);
  stroke-width: 1.5;
}

.compass-tick {
  fill: var(--ink-3);
  font-size: 8px;
  font-weight: var(--weight-bold);
  text-anchor: middle;
  dominant-baseline: central;
}

.compass-arrow {
  fill: var(--accent);
}

.compass-hub {
  fill: var(--surface);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.meter {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--rain);
}

.trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.sun-arc {
  width: 100%;
  height: auto;
}

.sun-arc-track {
  fill: none;
  stroke: var(--surface-3);
  stroke-width: 3;
  stroke-linecap: round;
}

.sun-arc-past {
  fill: none;
  stroke: var(--sun);
  stroke-width: 3;
  stroke-linecap: round;
}

.sun-arc-sun {
  fill: var(--sun);
}

.sun-times {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

/* ============================================================================
   Осадки и облачность
   ========================================================================== */
.charts {
  display: contents;
}

.stat-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px var(--sp-4);
}

.stat-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-heavy);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-value small {
  margin-left: 2px;
  color: var(--ink-2);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  letter-spacing: 0;
}

.stat-sub {
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.stat-secondary {
  margin-top: 2px;
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.stat-secondary strong {
  color: var(--ink);
}

.chart {
  margin-top: var(--sp-4);
}

.chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-bar-rain {
  fill: var(--rain);
}

.chart-bar-snow {
  fill: var(--snow);
}

.chart-bar-mix {
  fill: #7c8ee6;
}

.chart-prob {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
  stroke-linecap: round;
}

.chart-axis {
  fill: var(--ink-3);
  font-size: 11px;
  font-weight: var(--weight-bold);
  text-anchor: middle;
}

.chart-clouds-line {
  fill: none;
  stroke: var(--ink-2);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-clouds-area {
  fill: var(--surface-3);
}

/* ============================================================================
   Состояния: загрузка, обновление, вход
   ========================================================================== */
.is-skeleton {
  color: transparent !important;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  animation: shimmer 1200ms var(--ease-in-out) infinite alternate;
  user-select: none;
}

.weather-view.is-entering > .hero {
  animation: rise-in var(--dur-slow) var(--ease-out) both;
}

.weather-view.is-entering > .card,
.weather-view.is-entering > .charts > .card {
  animation: rise-in var(--dur-slow) var(--ease-out) both;
}

.weather-view.is-entering > :nth-child(2),
.weather-view.is-entering > .charts > :nth-child(1) {
  animation-delay: 40ms;
}

.weather-view.is-entering > :nth-child(3) {
  animation-delay: 80ms;
}

.weather-view.is-entering > :nth-child(4) {
  animation-delay: 120ms;
}

.weather-view.is-entering > :nth-child(5) {
  animation-delay: 160ms;
}

/* Скелетон-строки до первой загрузки */
.sk-hour,
.sk-day {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.sk-hour {
  flex: none;
  width: 64px;
  height: 150px;
}

.sk-day {
  height: 50px;
}

.sk-line {
  height: 16px;
  margin-top: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--surface-3);
}

/* ============================================================================
   Подвал
   ========================================================================== */
.page-foot {
  display: grid;
  gap: 4px;
  padding: 0 var(--sp-2);
  color: var(--ink-3);
  font-size: var(--text-xs);
}

.page-foot a {
  color: var(--ink-2);
  text-underline-offset: 2px;
}

/* ============================================================================
   Узкие телефоны (≥400): подписи сохранения и осадков помещаются
   ========================================================================== */
@media (min-width: 400px) {
  .fav-btn {
    padding: 0 var(--sp-4) 0 var(--sp-3);
  }

  .fav-label {
    display: inline;
  }

  .day {
    grid-template-columns: 88px 30px auto 36px minmax(44px, 1fr) 36px;
    gap: var(--sp-2);
  }

  .day-precip {
    display: block;
  }

  .day-precip-inline {
    display: none;
  }
}

@media (min-width: 480px) {
  .hero {
    padding: var(--sp-6) var(--sp-5) var(--sp-5);
  }

  .hero-icon {
    width: 116px;
    height: 116px;
  }

  .hour {
    width: 72px;
  }
}

/* ============================================================================
   Планшет и десктоп (≥768)
   ========================================================================== */
@media (min-width: 768px) {
  .card {
    padding: var(--sp-5);
  }

  .card-head {
    margin-bottom: var(--sp-4);
  }

  .card-head h2 {
    font-size: var(--text-lg);
  }

  .hero {
    padding: var(--sp-6);
  }

  .hero-title {
    font-size: var(--text-3xl);
  }

  .hero-main {
    gap: var(--sp-4) var(--sp-7);
    margin-top: var(--sp-6);
  }

  .hero-icon {
    width: 136px;
    height: 136px;
  }

  .hero-temp {
    font-size: 7.5rem;
  }

  .hero-degree {
    font-size: 3.5rem;
  }

  .hero-summary {
    font-size: var(--text-xl);
  }

  .hero-facts {
    margin-top: var(--sp-6);
  }

  .hero-facts li {
    padding: var(--sp-3) var(--sp-4);
  }

  .hero-facts strong {
    font-size: var(--text-base);
  }

  .hour {
    width: 76px;
  }

  .hour-temp {
    font-size: var(--text-lg);
  }

  .day {
    min-height: 54px;
    grid-template-columns: 112px 32px auto 40px minmax(80px, 1fr) 40px;
    gap: var(--sp-4);
  }

  .day-icon {
    width: 32px;
    height: 32px;
  }

  .day-min,
  .day-max {
    font-size: var(--text-lg);
  }

  .day-date {
    font-size: var(--text-sm);
  }

  .day-precip {
    font-size: var(--text-sm);
  }

  .day-precip-amount {
    display: inline;
    font-size: var(--text-sm);
  }

  .details-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--sp-3);
  }

  .tile--wind {
    grid-column: span 2;
  }

  .tile {
    min-height: 132px;
    padding: var(--sp-4);
  }

  .tile-value {
    font-size: var(--text-2xl);
  }

  .tile-sub {
    font-size: var(--text-sm);
  }

  .charts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--section-gap);
  }

  .stat-value {
    font-size: var(--text-3xl);
  }

  .page-foot {
    font-size: var(--text-sm);
  }
}

/* Десктоп: секции подстраиваются под фактическую ширину колонки погоды */
@container weather (width >= 620px) {
  .hero-main {
    flex-wrap: nowrap;
  }

  .hero-temp {
    font-size: 8rem;
  }
}

@container weather (width < 620px) {
  .charts {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Мелкие доводки -------------------------------------------------------- */
.hero.is-loading .hero-icon {
  opacity: 0.35;
}

.hour-icon-wrap {
  display: inline-block;
  line-height: 0;
}

.chart-baseline {
  stroke: var(--line-strong);
  stroke-width: 1;
}

/* «07:08 – 15:07» должно помещаться в узкую плитку одной строкой */
.sun-times-value {
  font-size: var(--text-base);
  white-space: nowrap;
}

/* Ошибка без данных: секции со скелетонами не показываем, остаётся главный блок с причиной */
.weather-view[data-state="error"] > .card,
.weather-view[data-state="error"] > .charts,
.weather-view[data-state="error"] > .page-foot {
  display: none;
}

/* Без JavaScript: скелетоны не нужны, показываем текст */
.notice--noscript {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + var(--sp-4));
  z-index: var(--z-toast);
  font-size: var(--text-sm);
}
