/**
 * Стили главной страницы — минималистичный дизайн
 */

/* ===== MAIN LAYOUT ===== */
html, body {
  height: 100%;
  overflow-x: hidden;
}

.main {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 40px 28px;
  background: #f8fafc;
  position: relative;
}

.search-container {
  width: 100%;
  max-width: 980px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
}

/* ===== HERO BLOCK (центр первого экрана) ===== */
.hero-block {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding: 0 0 14px;
}

/* ===== HERO TITLE ===== */
.hero-title {
  font-size: 2.25rem;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
  margin-bottom: 0;
  line-height: 1.2;
}

.hero-title-line1,
.hero-title-line2 {
  display: inline;
}

.hero-direction-wrapper {
  display: inline-block;
  position: relative;
  min-width: 50px;
}

.hero-direction {
  display: inline-block;
  color: var(--color-brand-primary);
  transition: opacity 0.3s, transform 0.3s;
}

.hero-direction.fade-out {
  opacity: 0;
  transform: translateY(-8px);
}

.hero-direction.fade-in {
  opacity: 1;
  transform: translateY(0);
}

.hero-subtitle {
  font-size: 1rem;
  color: #6b7280;
  text-align: center;
  width: 100%;
  max-width: none;
  line-height: 1.5;
}

/* ===== CATEGORY BUBBLES (desktop-only) ===== */
.category-bubbles {
  display: none; /* mobile: скрыто (мобильная верстка остаётся прежней) */
}

@media (min-width: 1024px) {
  /* Десктоп: центрируем ВЕСЬ контент главной по вертикали (как “видимый центр”). */
  .main {
    align-items: center;
  }

  /* На десктопе показываем кружочки и скрываем старые карточки категорий */
  .category-bubbles {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
    margin-bottom: 4px;
  }

}

.category-bubbles__nav {
  width: 38px;
  height: 38px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: pointer;
  flex: 0 0 auto;
}

.category-bubbles__nav:disabled {
  opacity: 0.35;
  cursor: default;
}

.category-bubbles__nav-icon {
  width: 18px;
  height: 18px;
}

.category-bubbles__track {
  flex: 1 1 auto;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 6px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
}

.category-bubbles__track::-webkit-scrollbar {
  display: none;
}

.category-bubble {
  flex: 0 0 auto;
  width: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: #111827;
  scroll-snap-align: start;
}

.category-bubble__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Приглушаем иконки, чтобы не отвлекать от поисковой строки */
  color: #9ca3af;
  transition: background 0.2s, transform 0.2s;
}

.category-bubble:hover .category-bubble__icon {
  background: #fef2f2;
  transform: translateY(-1px);
}

.category-bubble:hover .category-bubble__icon,
.category-bubble:focus-visible .category-bubble__icon {
  color: var(--color-brand-primary);
}

.category-bubble__icon-svg {
  width: 22px;
  height: 22px;
}

.category-bubble__label {
  font-size: 0.6875rem; /* чуть меньше, чтобы не отвлекать от поиска */
  font-weight: 500;
  color: #111827;
  text-align: center;
  line-height: 1.2;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hero-free {
  color: #22c55e;
  font-weight: 600;
}

/* ===== SEARCH BOX (в стиле Яндекса) ===== */
.search-form {
  width: 100%;
}

.search-box {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 24px;
  padding: 6px 16px 6px 6px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.search-box:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-box:focus-within {
  border-color: var(--color-brand-primary);
  box-shadow: 0 2px 8px rgba(230, 0, 0, 0.15);
}

/* ===== SEARCH FOCUS MODE (затемнение вокруг поиска) ===== */
body.ae-search-focus .main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.25);
  z-index: 9000;
  pointer-events: none;
}

/* Поиск и подсказки должны быть выше затемнения */
body.ae-search-focus #search-form {
  position: relative;
  z-index: 9500;
}

/* Останавливаем карусель при фокусе в поиске */
body.ae-search-focus #carousel {
  animation-play-state: paused;
}

.search-logo {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-right: 8px;
}

.logo-img {
  width: 32px;
  height: 32px;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 12px 8px;
  background: transparent;
  color: #1f2937;
}

.search-input::placeholder {
  color: #9ca3af;
}

/* ===== SEARCH ACTIONS (mic, enter) ===== */
.search-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

.search-action-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.search-action-btn:hover {
  background: #f3f4f6;
}

.search-action-btn:active {
  background: #e5e7eb;
}

.action-icon {
  width: 20px;
  height: 20px;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.search-action-btn:hover .action-icon {
  opacity: 1;
}

.search-action-btn:disabled {
  cursor: default;
  opacity: 0.35;
  pointer-events: none;
}

/* Состояние записи микрофона */
.search-action-btn.recording {
  background: #fef2f2;
}

.search-action-btn.recording .action-icon {
  opacity: 1;
  filter: invert(27%) sepia(94%) saturate(5538%) hue-rotate(355deg) brightness(91%) contrast(126%);
}

/* ===== WIDGETS ===== */
.widgets {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  gap: 24px;
  flex-wrap: wrap;
}

/* ===== MODAL (route not found) ===== */
.ae-modal-open {
  overflow: hidden;
}

.ae-modal-overlay[hidden] {
  display: none;
}

.ae-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.ae-modal {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid #e5e7eb;
}

.ae-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid #e5e7eb;
}

.ae-modal__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
}

.ae-modal__close {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 24px;
  line-height: 1;
  color: #6b7280;
}

.ae-modal__close:hover {
  background: #f3f4f6;
  color: #111827;
}

.ae-modal__body {
  padding: 16px 18px 0;
}

.ae-modal__text {
  font-size: 0.975rem;
  color: #374151;
  line-height: 1.55;
}

.ae-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 18px 18px;
}

/* Конкретно для модалки "маршрут не найден" — кнопку по центру */
#route-not-found-modal .ae-modal__actions {
  justify-content: center;
}

.widget {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  color: #6b7280;
  cursor: default;
}

.widget-icon {
  width: 18px;
  height: 18px;
  color: #9ca3af;
}

.widget-text {
  font-weight: 500;
}

/* ===== TRAFFIC WIDGET (светофор + текст) ===== */
.traffic-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}

.traffic-light {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.3s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.traffic-level {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.traffic-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
}

/* Цвета по уровню пробок */
.traffic-light.green { background: #22c55e; }
.traffic-light.yellow { background: #eab308; }
.traffic-light.red { background: #ef4444; }

/* ===== CAROUSEL SECTION ===== */
.carousel-section {
  width: 100%;
  max-width: 100vw;
  margin-top: 6px;
  position: relative;
  overflow: hidden;
  /* Эффект fade на краях */
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 15%,
    black 85%,
    transparent 100%
  );
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 15%,
    black 85%,
    transparent 100%
  );
}

.carousel-track {
  display: flex;
  gap: 16px;
  width: max-content;
  animation: carousel-scroll 30s linear infinite;
  padding: 8px 0;
}

.carousel-track:hover {
  animation-play-state: paused;
}

@keyframes carousel-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* ===== CAROUSEL CARDS ===== */
.carousel-card {
  flex: 0 0 auto;
  min-width: 140px;
  max-width: 180px;
  scroll-snap-align: start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.carousel-card:hover {
  border-color: var(--color-brand-primary);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.carousel-card__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carousel-card__meta {
  font-size: 0.75rem;
  color: #6b7280;
}

.carousel-card__meta strong {
  /* Приглушаем акцент по умолчанию, чтобы не отвлекать от поиска */
  color: #9ca3af;
}

/* На hover/focus возвращаем фирменный красный (как у кружочков категорий) */
.carousel-card:hover .carousel-card__meta strong,
.carousel-card:focus-visible .carousel-card__meta strong {
  color: var(--color-brand-primary);
}

/* Footer — унифицирован в css/common.css */

/* ===== SUGGEST DROPDOWN ===== */
.search-box .suggest-dropdown {
  left: 0;
  right: 0;
  border-radius: 16px;
  margin-top: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  .main {
    padding: 24px 16px;
    align-items: center;
    justify-content: center;
  }

  .hero-block {
    min-height: auto;
    padding: 0 0 10px;
    justify-content: flex-start;
    gap: 14px;
  }
  
  .search-container {
    gap: 14px;
  }
  
  .hero-title {
    font-size: 1.625rem;
  }
  
  .hero-title-line1 {
    display: block;
  }
  
  .hero-title-line2 {
    display: block;
  }
  
  .hero-subtitle {
    font-size: 0.9375rem;
  }
  
  .search-box {
    border-radius: 20px;
    padding: 4px 4px 4px 4px;
  }
  
  .search-logo {
    width: 38px;
    height: 38px;
    margin-right: 4px;
  }
  
  .logo-img {
    width: 26px;
    height: 26px;
  }
  
  .search-input {
    font-size: 16px; /* iOS Safari зумирует поле при font-size < 16px */
    padding: 10px 6px;
  }

  .search-action-btn {
    width: 40px;
    height: 40px;
  }

  .search-actions {
    flex-shrink: 0;
    gap: 0;
    margin-left: 0;
  }
  
  .widgets {
    gap: 16px;
  }
  
  .widget {
    font-size: 0.875rem;
  }
  
  .carousel-card {
    min-width: 120px;
    padding: 10px 12px;
  }
  
  .carousel-card__title {
    font-size: 0.875rem;
  }

}

@media (min-width: 1200px) {
  .main {
    padding-left: 56px;
    padding-right: 56px;
  }

  .search-container {
    max-width: 1100px;
  }
}
