/*
 * RentalSPb — базовые стили и вёрстка каркаса (mobile-first).
 *
 * Зависит от tokens.css (подключается ПЕРЕД этим файлом в base.html).
 * Все цвета/шрифты/радиусы берём из токенов — не хардкодим.
 */

/* ---------- Сброс ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--color-text);
  text-wrap: balance;
  letter-spacing: -0.025em;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: var(--fw-h1); }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: var(--fw-h2); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-h3); }
h4 { font-size: var(--fs-h4); line-height: var(--lh-h4); font-weight: var(--fw-h4); }
p { text-wrap: pretty; }

a { color: var(--color-primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
[x-cloak] { display: none !important; }

/* ---------- Контейнер ---------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}
.container--wide { max-width: var(--container-wide-max); }

/* ---------- Утилиты ---------- */
.text-muted { color: var(--color-text-muted); }
.text-measure { max-width: var(--text-measure); }

/* ---------- Иконки (SVG, Lucide-style) ---------- */
/* Все иконки используют currentColor, размер через width/height или font-size */
.icon {
  display: inline-block;
  vertical-align: middle;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon--lg { width: 24px; height: 24px; }
.icon--sm { width: 16px; height: 16px; }
.icon--xl { width: 32px; height: 32px; }
/* Иконка с заливкой (для активного избранного и т.п.) */
.icon--filled { fill: currentColor; stroke: currentColor; }
.text-center { text-align: center; }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.hide { display: none !important; }

/* ---------- Шапка ---------- */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-header);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--header-height);
}
.site-header__actions {
  display: flex;
  gap: var(--space-4);
  align-items: center;
}
@media (min-width: 1024px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
  }
  .site-header__inner > .logo { justify-self: start; }
  .site-header__inner > .site-nav { justify-self: center; }
  .site-header__actions { justify-self: end; }
  .site-header__menu { display: none; }
}

.logo {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  text-decoration: none;
}
.logo:hover { text-decoration: none; }
.logo__asset,
.logo__wordmark,
.logo__compact { display: block; }
.logo__wordmark { width: auto; height: 43px; }
.logo__compact { display: none; width: 44px; height: 44px; }

@media (max-width: 767px) {
  .site-header .logo__wordmark { display: none; }
  .site-header .logo__compact { display: block; }
}

/* Навигация */
.site-nav { display: none; }
@media (min-width: 1024px) {
  .site-nav { display: flex; gap: var(--space-4); }
  .site-nav a {
    color: var(--color-text);
    font-weight: 500;
    font-size: var(--fs-body-sm);
  }
  .site-nav a:hover { color: var(--color-primary); text-decoration: none; }
}

@media (min-width: 1024px) and (max-width: 1199px) {
  .site-nav { gap: var(--space-3); }
  .site-header__actions { gap: var(--space-2); }
  .site-header__actions .header-action {
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
  .site-header__actions .header-action__label { display: none; }
}

.header-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text);
  font-size: var(--fs-body-sm);
  font-weight: 500;
  white-space: nowrap;
}
.header-action:hover { color: var(--color-primary); text-decoration: none; }
.header-action__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--color-primary);
  color: var(--color-text-invert);
  font-size: 10px;
  font-weight: 700;
}
.header-action__count[hidden] { display: none; }

@media (max-width: 767px) {
  .header-action__label { display: none; }
  .site-header__actions { margin-left: auto; gap: var(--space-2); }
  .header-action {
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
  }
  .header-action__count {
    position: absolute;
    top: 1px;
    right: 0;
  }
}

/* Бургер (Alpine.js) */
.burger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; height: 44px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 20px;
  color: var(--color-text);
}
.burger-btn:hover { background: var(--color-surface); }
@media (min-width: 1024px) { .burger-btn { display: none; } }

/* Мобильное меню (выезжает) */
.mobile-menu {
  position: fixed;
  top: var(--header-height); left: 0; right: 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4) var(--container-pad);
  z-index: calc(var(--z-sticky) - 1);
}
.mobile-menu a {
  display: block;
  padding: var(--space-3) 0;
  color: var(--color-text);
  font-weight: 500;
  border-bottom: 1px solid var(--color-surface-alt);
}
.mobile-menu a:last-child { border-bottom: none; }

/* ---------- Подвал ---------- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  margin-top: var(--section-gap);
  padding: var(--space-8) 0 var(--space-5);
  font-size: var(--fs-body-sm);
  color: var(--color-text-muted);
}
.home-page .site-footer { margin-top: 0; }
.site-footer a { color: var(--color-text-muted); }
.site-footer a:hover { color: var(--color-primary); }
.site-footer__grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr;
}
.site-footer__brand { max-width: 300px; }
.site-footer__brand p { margin-top: var(--space-4); }
.site-footer__column { display: flex; flex-direction: column; gap: var(--space-2); }
.site-footer__column h4 {
  margin-bottom: var(--space-2);
  color: var(--color-text);
  font-size: var(--fs-body);
}
.site-footer__bottom {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
}
.site-footer__bottom div { display: flex; flex-wrap: wrap; gap: var(--space-4); }
@media (min-width: 768px) {
  .site-footer__grid { grid-template-columns: 1.6fr repeat(3, 1fr); }
  .site-footer__bottom { flex-direction: row; justify-content: space-between; }
}

/* ---------- Секции страницы ---------- */
.section { padding: var(--section-padding-block) 0; }
.section--alt { background: var(--color-surface); }

/* ---------- Focus-visible (доступность) ---------- */
:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 3px;
}

/* Движение остаётся необязательным: интерфейс полностью работает без него. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .btn:hover,
  .btn:active,
  .chip:hover,
  .chip:active,
  .apartment-card:hover,
  .apartment-card:hover .apartment-card__photo-link img,
  .apartment-card__action:hover,
  .apartment-card__action:active,
  .home-district-card:hover img,
  .cookie-notice-enter-start,
  .cookie-notice-leave-end {
    transform: none !important;
  }
}
