/* Погодный виджет главной страницы. Использует токены из style.css. */

.home-weather {
  min-width: 0;
  width: 100%;
}

.snt-weather {
  /* Оттенок --muted темнее на шаг: мелкий текст на светлых подложках держит контраст ≥ 4.5:1. */
  --weather-muted: #4d6a59;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas:
    "now side"
    "days days"
    "meta meta";
  gap: var(--space-4);
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  color: var(--text);
}

.snt-weather p {
  margin: 0;
}

/* Тема переносит текст p/li/dd «где угодно»; значения вида «+14° / +4°» и «7 м/с» переносим только по пробелам. */
.snt-weather dd,
.snt-weather li {
  overflow-wrap: normal;
}

/* Текущая погода */

.snt-weather__now {
  grid-area: now;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 184px;
  padding: var(--space-5) var(--space-6);
  border-radius: var(--radius-lg);
  --weather-muted: #3f5a4a;
  background: linear-gradient(160deg, #eef4ef 0%, #e2ebe4 100%);
  contain: paint;
}

.snt-weather__now--sun { background: linear-gradient(160deg, #fff8e3 0%, #fdeec2 100%); }
.snt-weather__now--night { background: linear-gradient(160deg, #e9edf6 0%, #d9e0ee 100%); }
.snt-weather__now--clouds { background: linear-gradient(160deg, #e3eae7 0%, #cfd9d5 100%); }
.snt-weather__now--fog { background: linear-gradient(160deg, #e6e9e8 0%, #d6dcda 100%); }
.snt-weather__now--rain { background: linear-gradient(160deg, #e7eef3 0%, #d5e1ea 100%); }
.snt-weather__now--snow { background: linear-gradient(160deg, #d4e1ee 0%, #c3d4e6 100%); }
.snt-weather__now--storm {
  background: linear-gradient(160deg, #46525e 0%, #313b45 100%);
  color: #fff;
}

.snt-weather__now-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-1);
  min-width: 0;
}

.snt-weather__eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--weather-muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.snt-weather__now--storm .snt-weather__eyebrow,
.snt-weather__now--storm .snt-weather__feels {
  color: rgba(255, 255, 255, 0.82);
}

.snt-weather__temp-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Значок соразмерен температуре: главный акцент блока — пара «значок + градусы». */
.snt-weather__icon {
  font-size: clamp(52px, 5vw, 72px);
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(28, 52, 39, 0.14));
}

.snt-weather__temp {
  font-size: clamp(48px, 5.6vw, 68px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

.snt-weather__condition {
  margin-top: var(--space-1);
  font-size: 19px;
  font-weight: 700;
  line-height: 1.25;
}

.snt-weather__feels {
  color: var(--weather-muted);
  font-size: 14px;
  line-height: 1.4;
}

/* Параметры справа */

.snt-weather__side {
  grid-area: side;
  display: grid;
  align-content: start;
  gap: var(--space-3);
  min-width: 0;
}

.snt-weather__params {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin: 0;
}

.snt-weather__param {
  min-width: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(47, 125, 50, 0.06);
}

.snt-weather__param dt {
  color: var(--weather-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.snt-weather__param dd {
  margin: var(--space-1) 0 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.snt-weather__alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  border: 1px solid rgba(58, 110, 170, 0.22);
  border-radius: var(--radius-md);
  background: rgba(58, 110, 170, 0.08);
  color: #1f3f63;
  font-size: 14px;
  line-height: 1.4;
}

.snt-weather__alert-icon {
  flex: 0 0 auto;
  font-size: 18px;
  line-height: 1.2;
}

/* Прогноз по дням */

.snt-weather__days {
  grid-area: days;
  display: grid;
  /* Число колонок уменьшается, если страница из кэша и прошедшие дни скрыты */
  grid-template-columns: repeat(var(--weather-days, 5), minmax(0, 1fr));
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.snt-weather__day {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: var(--space-3) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

/* Текущий день: зелёная рамка, фон и цвет названия — без смены размеров, раскладка не прыгает. */
.snt-weather__day.is-today {
  border-color: rgba(47, 125, 50, 0.45);
  background: rgba(47, 125, 50, 0.09);
  box-shadow: inset 0 0 0 1px rgba(47, 125, 50, 0.16);
}

.snt-weather__day.is-today .snt-weather__day-name {
  color: var(--primary-strong);
}

.snt-weather__day.is-frost .snt-weather__day-min {
  color: #2d5f96;
}

/* «Сегодня · 27 окт» одной строкой; на узкой карточке дата переносится под название. */
.snt-weather__day-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 0 6px;
  min-width: 0;
}

.snt-weather__day-name {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
}

.snt-weather__day-date {
  color: var(--weather-muted);
  font-size: 13px;
  line-height: 1.25;
  white-space: nowrap;
}

.snt-weather__day-icon {
  font-size: 40px;
  line-height: 1;
}

.snt-weather__day-temp {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.snt-weather__day-max {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.snt-weather__day-min {
  color: var(--weather-muted);
  font-size: 15px;
  font-weight: 600;
}

.snt-weather__day-extra {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px var(--space-2);
  color: var(--weather-muted);
  font-size: 13px;
  line-height: 1.3;
  white-space: nowrap;
}

/* Подвал */

.snt-weather__meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
  min-width: 0;
}

.snt-weather__updated {
  color: var(--weather-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Устаревшие данные: пометка заметнее, суточные значения прошедшего дня скрыты */
.snt-weather.is-outdated .snt-weather__updated {
  color: #8a5a00;
  font-weight: 600;
}

.snt-weather.is-day-changed [data-weather-today-only],
.snt-weather [hidden] {
  display: none !important;
}

.snt-weather__updated a {
  white-space: nowrap;
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.snt-weather__motion {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 999px;
  background: rgba(47, 125, 50, 0.08);
  color: var(--primary-strong);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.snt-weather__motion:hover {
  background: rgba(47, 125, 50, 0.12);
}

.snt-weather__motion:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.snt-weather__motion-switch {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--primary);
  transition: background-color 0.2s ease;
}

.snt-weather__motion-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 14px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.snt-weather__motion[aria-pressed="false"] .snt-weather__motion-switch {
  background: rgba(23, 48, 34, 0.28);
}

.snt-weather__motion[aria-pressed="false"] .snt-weather__motion-switch::after {
  transform: translateX(-12px);
}

/* Нет данных */

.snt-weather--unavailable {
  display: block;
}

.snt-weather__empty {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.snt-weather__empty .snt-weather__eyebrow {
  margin-bottom: var(--space-1);
}

.snt-weather__empty p {
  color: var(--weather-muted);
  line-height: 1.5;
}

.snt-weather__empty-icon {
  font-size: 32px;
}

/* ---------------------------------------------------------------------
 * Погодные эффекты. Только transform/opacity, слой не влияет на раскладку.
 * ------------------------------------------------------------------ */

.snt-weather__fx {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.snt-weather__fx > * {
  position: absolute;
  pointer-events: none;
}

/* Солнце и луна: мягкое свечение */
.snt-weather__glow {
  top: -70px;
  right: -60px;
  width: 240px;
  height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(246, 177, 26, 0.55) 0%, rgba(246, 177, 26, 0.18) 45%, rgba(246, 177, 26, 0) 70%);
  animation: snt-weather-glow 7s ease-in-out infinite alternate;
}

.snt-weather__now--night .snt-weather__glow {
  background: radial-gradient(circle, rgba(170, 186, 230, 0.6) 0%, rgba(170, 186, 230, 0.2) 45%, rgba(170, 186, 230, 0) 70%);
}

@keyframes snt-weather-glow {
  from { transform: scale(0.94); opacity: 0.75; }
  to { transform: scale(1.06); opacity: 1; }
}

/* Облака: медленный дрейф */
.snt-weather__cloud {
  top: 14%;
  left: -45%;
  width: 42%;
  height: 34%;
  border-radius: 999px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.55) 45%, rgba(255, 255, 255, 0) 72%);
  animation: snt-weather-cloud 64s linear infinite;
  will-change: transform;
}

.snt-weather__cloud:nth-child(2) {
  top: 42%;
  width: 34%;
  animation-duration: 82s;
  animation-delay: -40s;
  opacity: 0.8;
}

.snt-weather__cloud:nth-child(3) {
  top: 0;
  width: 50%;
  animation-duration: 100s;
  animation-delay: -70s;
  opacity: 0.6;
}

.snt-weather__now--fog .snt-weather__cloud {
  height: 26%;
  width: 70%;
  left: -75%;
  opacity: 0.75;
}

.snt-weather__now--storm .snt-weather__cloud {
  background: radial-gradient(ellipse at center, rgba(160, 172, 186, 0.45) 0%, rgba(160, 172, 186, 0.18) 50%, rgba(160, 172, 186, 0) 72%);
}

@keyframes snt-weather-cloud {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(360%, 0, 0); }
}

/* Частицы: элемент на всю высоту зоны, видимая точка — ::after у верхнего края */
.snt-weather__p {
  top: 0;
  left: var(--x);
  width: 8px;
  height: 100%;
  will-change: transform;
}

.snt-weather__p::after {
  content: "";
  position: absolute;
  top: -14px;
  left: 0;
}

/* Снег */
.snt-weather__now--snow .snt-weather__p {
  animation: snt-weather-snow calc(7s + var(--n) * 1.3s) linear infinite;
  animation-delay: var(--d);
}

.snt-weather__now--snow .snt-weather__p::after {
  width: calc(8px * var(--s));
  height: calc(8px * var(--s));
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.9);
  opacity: 0.9;
}

@keyframes snt-weather-snow {
  from { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(14px, 50%, 0); }
  to { transform: translate3d(-6px, 105%, 0); }
}

/* Дождь и гроза */
.snt-weather__now--rain .snt-weather__p,
.snt-weather__now--storm .snt-weather__p {
  animation: snt-weather-rain calc(1s + var(--n) * 0.18s) linear infinite;
  animation-delay: calc(var(--d) * 0.15);
}

.snt-weather__now--rain .snt-weather__p::after,
.snt-weather__now--storm .snt-weather__p::after {
  width: 2px;
  height: calc(18px * var(--s));
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(60, 105, 150, 0) 0%, rgba(60, 105, 150, 0.45) 100%);
}

.snt-weather__now--storm .snt-weather__p::after {
  background: linear-gradient(180deg, rgba(220, 230, 240, 0) 0%, rgba(220, 230, 240, 0.4) 100%);
}

@keyframes snt-weather-rain {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-10px, 108%, 0); }
}

/* Гроза: приглушённое плавное посветление без резких вспышек */
.snt-weather__flash {
  inset: 0;
  background: radial-gradient(ellipse at 70% 0%, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 65%);
  opacity: 0;
  animation: snt-weather-flash 11s ease-in-out infinite;
}

@keyframes snt-weather-flash {
  0%, 62%, 100% { opacity: 0; }
  72% { opacity: 0.7; }
  82% { opacity: 0.15; }
}

/* Звёзды ясной ночью */
.snt-weather__now--night .snt-weather__p {
  top: calc(var(--y) * 0.6);
  width: auto;
  height: auto;
  animation: snt-weather-twinkle calc(3s + var(--n) * 0.7s) ease-in-out infinite alternate;
  animation-delay: calc(var(--d) * 0.4);
}

.snt-weather__now--night .snt-weather__p::after {
  top: 0;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(70, 86, 140, 0.55);
}

@keyframes snt-weather-twinkle {
  from { opacity: 0.25; }
  to { opacity: 1; }
}

/* Выключение анимации: кнопкой посетителя, вне экрана, системной настройкой */
.snt-weather.is-motion-off .snt-weather__fx {
  display: none;
}

.snt-weather.is-paused .snt-weather__fx > * {
  animation-play-state: paused;
}

@media (prefers-reduced-motion: reduce) {
  .snt-weather__fx > * {
    animation: none !important;
  }

  .snt-weather__p,
  .snt-weather__flash {
    display: none;
  }

  .snt-weather__cloud:nth-child(1) { transform: translate3d(140%, 0, 0); }
  .snt-weather__cloud:nth-child(2) { transform: translate3d(230%, 0, 0); }
  .snt-weather__cloud:nth-child(3) { transform: translate3d(90%, 0, 0); }

  .snt-weather__motion {
    display: none;
  }
}

/* ---------------------------------------------------------------------
 * Адаптив
 * ------------------------------------------------------------------ */

@media (max-width: 1024px) {
  .snt-weather {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

@media (max-width: 780px) {
  .snt-weather {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "now"
      "side"
      "days"
      "meta";
    gap: var(--space-3);
    padding: var(--space-4);
  }

  .snt-weather__now {
    min-height: 152px;
    padding: var(--space-4) var(--space-5);
  }

  .snt-weather__params {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .snt-weather__days {
    gap: var(--space-2);
  }
}

@media (max-width: 600px) {
  .snt-weather__params {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-2);
  }

  .snt-weather__param {
    padding: 10px var(--space-3);
  }

  .snt-weather__param dd {
    font-size: 19px;
  }

  /*
   * Пять дней — строками: слева название, дата и осадки/ветер, по центру значок, справа температура.
   * Значок и температура занимают обе строки, поэтому строка дня не выше двух строк текста.
   */
  .snt-weather__days {
    grid-template-columns: minmax(0, 1fr);
  }

  .snt-weather__day {
    grid-template-columns: minmax(0, 1fr) 40px auto;
    grid-template-areas:
      "label icon temp"
      "extra icon temp";
    justify-items: start;
    align-items: center;
    gap: 2px var(--space-3);
    padding: 10px var(--space-3);
    text-align: left;
  }

  .snt-weather__day-label {
    grid-area: label;
    justify-content: flex-start;
  }

  .snt-weather__day-icon {
    grid-area: icon;
    justify-self: center;
    font-size: 32px;
  }

  .snt-weather__day-temp {
    grid-area: temp;
    justify-self: end;
    justify-content: flex-end;
  }

  .snt-weather__day-extra {
    grid-area: extra;
    justify-content: flex-start;
    justify-self: stretch;
    gap: 0 var(--space-3);
  }
}

@media (max-width: 430px) {
  .snt-weather {
    border-radius: var(--radius-lg);
  }

  .snt-weather__now {
    min-height: 136px;
    padding: var(--space-4);
    border-radius: var(--radius-md);
  }

  .snt-weather__icon {
    font-size: 48px;
  }

  .snt-weather__temp {
    font-size: 46px;
  }

  .snt-weather__param dt {
    font-size: 12px;
  }

  .snt-weather__day {
    grid-template-columns: minmax(0, 1fr) 36px auto;
    gap: 2px var(--space-2);
  }

  .snt-weather__day-icon {
    font-size: 30px;
  }
}
