/* Repaired merge of sub-splits */

/**
 * Site weather widget — плавающий блок погоды на главной (.zw-weather).
 *
 * Меняйте переменные ниже, overlay (ZOOKZY_DESIGN_ROOT/css/site-weather-widget.css)
 * или Design Studio — без правок index.html / шаблонов.
 */

:root {
  /* ── Слой на странице ── */
  --site-weather-z-index: 9920;
  --site-weather-z-index-dragging: 9940;
  --site-weather-anchor-top: calc(var(--header-h, 64px) + 12px);
  --site-weather-anchor-right: max(16px, env(safe-area-inset-right, 0px));
  --home-float-edge-l: max(10px, env(safe-area-inset-left, 0px));
  --home-float-edge-r: max(10px, env(safe-area-inset-right, 0px));
  --home-float-viewport-w: calc(100dvw - var(--home-float-edge-l) - var(--home-float-edge-r));

  /* ── Карточка (glass) ── */
  --site-weather-bg: rgba(15, 23, 42, 0.48);
  --site-weather-border: rgba(255, 255, 255, 0.2);
  --site-weather-text: var(--z-surface-page, #f8fafc);
  --site-weather-muted: rgba(226, 232, 240, 0.78);
  --site-weather-meta: rgba(226, 232, 240, 0.55);
  --site-weather-accent: var(--color-primary-light, #7ab6d9);
  --site-weather-blur: 14px;
  --site-weather-radius: 1.1rem;
  --site-weather-shadow: 0 8px 28px rgba(0, 0, 0, 0.24);
  --site-weather-shadow-hover: 0 10px 34px rgba(0, 0, 0, 0.28);
  --site-weather-shadow-drag: 0 14px 40px rgba(0, 0, 0, 0.32);
  --site-weather-max-width: 280px;
  --site-weather-min-height: 64px;

  /* ── Grip (перетаскивание) ── */
  --site-weather-grip-bg: rgba(15, 23, 42, 0.82);
  --site-weather-grip-border: rgba(255, 255, 255, 0.22);
  --site-weather-grip-text: rgba(248, 250, 252, 0.9);
  --site-weather-grip-active-bg: rgba(30, 41, 59, 0.95);

  /* ── Иконки SVG ── */
  --site-weather-sun-core: var(--z-amber-400, #fbbf24);
  --site-weather-sun-ray: #fcd34d;
  --site-weather-sun-glow: rgba(251, 191, 36, 0.65);
}

/* ═══════════════════════════════════════════════════════════════
   ANCHOR — fixed на главной
   ═══════════════════════════════════════════════════════════════ */

.zw-weather-anchor--floating {
  position: fixed;
  z-index: var(--site-weather-z-index) !important;
  top: var(--site-weather-anchor-top);
  right: var(--site-weather-anchor-right);
  left: auto;
  width: auto;
  max-width: var(--home-float-viewport-w);
  margin: 0;
  pointer-events: none;
  touch-action: none;
  box-sizing: border-box;
}

.zw-weather-anchor--floating.zw-weather-anchor--custom-pos {
  right: auto;
  bottom: auto;
  transform: none;
}

.zw-weather-anchor--floating.zw-home-float--layout {
  right: auto;
  bottom: auto;
  transform: none;
}

.zw-weather-anchor--floating.zw-weather-anchor--dragging {
  z-index: var(--site-weather-z-index-dragging) !important;
}

.zw-weather-anchor--hidden {
  display: none !important;
}

/* Close (×) — как у recruitment widgets */
.zw-weather-anchor__close {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 4;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--site-weather-grip-border);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: rgba(248, 250, 252, 0.92);
  font-size: 1.15rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  opacity: 0.85;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.zw-weather-anchor__close:hover {
  opacity: 1;
  background: rgba(127, 29, 29, 0.92);
  transform: scale(1.05);
}

.zw-weather-anchor:hover .zw-weather-anchor__close,
.zw-weather-anchor--dragging .zw-weather-anchor__close,
.zw-weather-anchor:focus-within .zw-weather-anchor__close {
  opacity: 0.95;
}

/* Restore tab — вертикальная вкладка у правого края (см. recruitment-widget.css) */
.zw-weather-restore,
.zw-home-float-restore {
  position: fixed;
  z-index: 9905 !important;
  top: auto;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  right: 0;
  left: auto !important;
  transform: none !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: auto;
  max-width: none;
  padding: 0.55rem 0.4rem 0.55rem 0.55rem;
  padding-right: max(0.4rem, env(safe-area-inset-right, 0px));
  border-radius: 10px 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-right: 0;
  background: rgba(15, 23, 42, 0.9);
  color: var(--z-surface-page, #f8fafc);
  font-size: clamp(0.58rem, 1.8vmin, 0.68rem);
  box-shadow: -4px 4px 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: auto;
  box-sizing: border-box;
}

.zw-weather-restore[hidden] {
  display: none !important;
}

.zw-weather-restore__btn {
  padding: 0.28rem 0.65rem;
  border: 0;
  border-radius: 999px;
  background: var(--z-amber-400, #fbbf24);
  color: #422006;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.zw-weather-restore__btn:hover {
  background: #fcd34d;
}

body:has(.homepage-hero-promo-stack):not(.search-active) .zw-home-float-restore,
body:has(.promo-banners-section):not(.search-active) .zw-home-float-restore {
  top: auto !important;
  bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  right: 0 !important;
  left: auto !important;
  transform: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════════════════════════ */

.zw-weather {
  --zw-glass: var(--site-weather-bg);
  --zw-border: var(--site-weather-border);
  --zw-text: var(--site-weather-text);
  --zw-muted: var(--site-weather-muted);
  --zw-accent: var(--site-weather-accent);

  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.95rem 0.65rem 0.75rem;
  border-radius: var(--site-weather-radius);
  background: var(--site-weather-bg);
  border: 1px solid var(--site-weather-border);
  backdrop-filter: blur(var(--site-weather-blur));
  -webkit-backdrop-filter: blur(var(--site-weather-blur));
  box-shadow: var(--site-weather-shadow);
  color: var(--site-weather-text);
  max-width: var(--site-weather-max-width);
  min-height: var(--site-weather-min-height);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  pointer-events: auto;
}

.zw-weather-anchor--dragging .zw-weather {
  transform: scale(1.02);
  box-shadow: var(--site-weather-shadow-drag);
  transition: none;
}

.zw-weather:hover {
  transform: translateY(-1px);
  box-shadow: var(--site-weather-shadow-hover);
}

.zw-weather-anchor--dragging .zw-weather:hover {
  transform: scale(1.02);
}

.zw-weather--loading {
  opacity: 0.85;
}

/* Grip */
.zw-weather__grip {
  position: absolute;
  top: -10px;
  left: -10px;
  z-index: 3;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--site-weather-grip-border);
  border-radius: 999px;
  background: var(--site-weather-grip-bg);
  color: var(--site-weather-grip-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.zw-weather-anchor:hover .zw-weather__grip,
.zw-weather-anchor--dragging .zw-weather__grip,
.zw-weather-anchor:focus-within .zw-weather__grip {
  opacity: 1;
  transform: scale(1);
}

.zw-weather__grip:active {
  cursor: grabbing;
  background: var(--site-weather-grip-active-bg);
}

/* Link wrapper */
.zw-weather__link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: inherit;
  text-decoration: none;
  width: 100%;
}

.zw-weather__link:hover {
  color: inherit;
}

/* Icon */
.zw-weather__icon-wrap {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zw-weather__icon {
  width: 44px;
  height: 44px;
}

/* Body text */
.zw-weather__body {
  flex: 1;
  min-width: 0;
}

.zw-weather__place {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--site-weather-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.1rem;
}

.zw-weather__temps {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  line-height: 1.1;
}

.zw-weather__temp {
  font-size: 1.45rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--site-weather-text);
}

.zw-weather__feels {
  font-size: 0.72rem;
  color: var(--site-weather-muted);
  font-weight: 500;
}

.zw-weather__desc {
  font-size: 0.74rem;
  color: var(--site-weather-muted);
  margin-top: 0.15rem;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.zw-weather__meta {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.15rem;
  font-size: 0.64rem;
  color: var(--site-weather-meta);
}

/* ═══════════════════════════════════════════════════════════════
   SVG ANIMATIONS
   ═══════════════════════════════════════════════════════════════ */

.zw-wx-sun__core {
  fill: var(--site-weather-sun-core);
  filter: drop-shadow(0 0 6px var(--site-weather-sun-glow));
}

.zw-wx-sun__ray {
  stroke: var(--site-weather-sun-ray);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: 0.85;
  transform-origin: 26px 26px;
  animation: zw-sun-spin 18s linear infinite;
}

@keyframes zw-sun-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.zw-wx-cloud {
  animation: zw-cloud-float 4s ease-in-out infinite;
}

@keyframes zw-cloud-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.zw-wx-drop {
  animation: zw-rain-fall 0.9s linear infinite;
  opacity: 0.7;
}

.zw-wx-drop:nth-child(2) { animation-delay: 0.15s; }
.zw-wx-drop:nth-child(3) { animation-delay: 0.3s; }
.zw-wx-drop:nth-child(4) { animation-delay: 0.45s; }

@keyframes zw-rain-fall {
  0% { transform: translateY(-2px); opacity: 0; }
  30% { opacity: 0.85; }
  100% { transform: translateY(10px); opacity: 0; }
}

.zw-wx-bolt {
  animation: zw-bolt-flash 2.5s ease-in-out infinite;
}

@keyframes zw-bolt-flash {
  0%, 92%, 100% { opacity: 0.15; }
  93%, 96% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  :root {
    --site-weather-anchor-top: calc(var(--header-h, 56px) + 8px);
    --site-weather-anchor-right: 10px;
  }

  .zw-weather-anchor--floating.zw-home-float--layout:not(.zw-weather-anchor--custom-pos) {
    top: var(--site-weather-anchor-top) !important;
    right: var(--site-weather-anchor-right) !important;
    left: auto !important;
    bottom: auto !important;
    transform: none !important;
  }

  .zw-weather {
    min-height: 0;
    max-width: min(var(--home-float-viewport-w), calc(100dvw - 24px));
    width: max-content;
    padding: 0.3rem 0.7rem 0.3rem 0.4rem;
    gap: 0.4rem;
    border-radius: 999px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    touch-action: none;
    cursor: grab;
  }

  .zw-weather-anchor--dragging .zw-weather {
    cursor: grabbing;
  }

  .zw-weather__grip {
    touch-action: none;
    cursor: grab;
  }

  .zw-weather-anchor--dragging .zw-weather__grip {
    cursor: grabbing;
  }

  .zw-weather__link {
    gap: 0.4rem;
  }

  .zw-weather__icon-wrap {
    width: 28px;
    height: 28px;
  }

  .zw-weather__icon {
    width: 26px;
    height: 26px;
  }

  .zw-weather__body {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    flex: 0 1 auto;
  }

  .zw-weather__temps {
    order: 1;
    gap: 0.25rem;
  }

.zw-weather__temp {
    font-size: 1.05rem;
    font-weight: 800;
  }

  .zw-weather__feels,
  .zw-weather__desc,
  .zw-weather__meta {
    display: none;
  }

  .zw-weather__place {
    order: 2;
    margin: 0;
    font-size: 0.6rem;
    line-height: 1.2;
    max-width: 110px;
    letter-spacing: 0.04em;
  }

  .zw-weather__grip {
    width: 30px;
    height: 30px;
    top: -12px;
    left: -12px;
    opacity: 0.9;
  }

  .zw-weather-anchor__close {
    width: 30px;
    height: 30px;
    top: -12px;
    right: -12px;
    opacity: 0.95;
  }

  /* Не трогаем restore внутри FAB — иначе top/bottom прыгают при смене языка/кэша */
  body:has(.homepage-hero-promo-stack):not(.search-active) .zw-home-float-restore:not(#siteFabStack *),
  body:has(.promo-banners-section):not(.search-active) .zw-home-float-restore:not(#siteFabStack *) {
    bottom: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    right: 0 !important;
    top: auto !important;
  }
}

@media (pointer: coarse) {
  .zw-weather-anchor__close {
    opacity: 0.95;
  }
}

@media (pointer: coarse) and (min-width: 768px) {
  .zw-weather-anchor--floating {
    touch-action: auto !important;
    z-index: 9950 !important;
  }

  .zw-weather {
    scale: 1 !important;
    touch-action: manipulation !important;
    cursor: default !important;
  }

  .zw-weather__grip {
    touch-action: none !important;
    width: 34px !important;
    height: 34px !important;
    opacity: 1 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .zw-wx-sun__ray,
  .zw-wx-cloud,
  .zw-wx-drop,
  .zw-wx-bolt {
    animation: none;
  }
}
