/* ==========================================================================
   Toza Suv — Material You sidebar (2026)
   Public-site left sidebar in Material You 3 / "Expressive" style.
   Mobile-first, isolated namespace (.sb-* / .nav-mat-*) so it does NOT
   collide with style-public.css or style-home-2026.css.
   ========================================================================== */

/* ---------- Local tokens (M3 mapping over existing palette) ------------- */
.sb-shell,
.sb-shell *,
.sb-shell *::before,
.sb-shell *::after { box-sizing: border-box; }

:root {
  /* Material You expressive palette tied to brand water-blue */
  --m3-primary:        #1A73E8;
  --m3-primary-hover:  #1765c8;
  --m3-on-primary:     #ffffff;
  --m3-secondary:      #0ea5e9;
  --m3-surface:        #ffffff;
  --m3-surface-1:      #f5f8fb;   /* surface tint level 1 */
  --m3-surface-2:      #eaf1f8;   /* surface tint level 2 — active item */
  --m3-surface-3:      #dbe6f3;
  --m3-on-surface:     #0f172a;
  --m3-on-surface-var: #475569;
  --m3-outline:        #e2e8f0;
  --m3-outline-var:    #cbd5e1;

  --m3-radius-sm:    12px;
  --m3-radius:       16px;
  --m3-radius-md:    20px;
  --m3-radius-lg:    28px;
  --m3-radius-pill:  999px;

  --m3-elev-1: 0 1px 2px rgba(15,23,42,.05), 0 1px 3px rgba(15,23,42,.05);
  --m3-elev-2: 0 2px 6px rgba(15,23,42,.07), 0 4px 12px rgba(15,23,42,.06);
  --m3-elev-3: 0 6px 16px rgba(15,23,42,.10), 0 12px 28px rgba(15,23,42,.08);

  --m3-t-fast: 180ms cubic-bezier(.2,0,0,1);
  --m3-t-base: 280ms cubic-bezier(.2,0,0,1);

  --sb-w-full: 280px;
  --sb-w-rail: 80px;
  --sb-topbar-h: 64px;
}

/* ---------- 1. Body shell behaviour with sidebar ------------------------ */
/* On desktop the page content gets pushed by sidebar width.
   On mobile/tablet the sidebar is a drawer — content is full-width. */
body.sb-shell {
  margin: 0;
}
@media (min-width: 1024px) {
  body.sb-shell {
    padding-left: var(--sb-w-full);
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  body.sb-shell {
    padding-left: var(--sb-w-rail);
  }
}

/* The sticky-top header from style-public.css must NOT be visible while
   the new top-bar takes over on mobile. We hide it cooperatively. */
body.sb-shell > header.site-header { display: none; }
body.sb-shell > nav.mobile-nav { display: none; }

/* ---------- 2. Top bar (visible на ВСЕХ размерах) ----------------------- */
.nav-mat-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  /* iOS notch / Dynamic Island safe-area: keep top bar visually below it. */
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--sb-topbar-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  /* Honor the side safe-areas on landscape iPhone (avoid content under camera). */
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--m3-outline);
}
/* На desktop+tablet brand скрыт (он в sidebar) — слева пусто, actions справа */
@media (min-width: 768px) {
  .nav-mat-topbar { justify-content: flex-end; }
  .nav-mat-topbar__brand { display: none; }
}
/* На desktop hamburger не нужен — sidebar всегда виден */
@media (min-width: 1024px) {
  .nav-mat-iconbtn--burger { display: none; }
}
/* Когда drawer открыт на mobile — скрыть brand в topbar (дубль с brand'ом drawer) */
@media (max-width: 767px) {
  body.sb-no-scroll .nav-mat-topbar__brand { visibility: hidden; }
}

.nav-mat-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--m3-on-surface);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.01em;
  min-width: 0;
}
.nav-mat-topbar__brand img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}
.nav-mat-topbar__brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-mat-topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-mat-iconbtn {
  --size: 44px;
  min-width: var(--size);
  height: var(--size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--m3-on-surface);
  border-radius: var(--m3-radius-pill);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: background var(--m3-t-fast), color var(--m3-t-fast);
}
.nav-mat-iconbtn:hover { background: var(--m3-surface-2); }
.nav-mat-iconbtn:active { background: var(--m3-surface-3); }
.nav-mat-iconbtn .material-symbols-rounded { font-size: 22px; }
.nav-mat-iconbtn__text { white-space: nowrap; }
/* На mobile показываем только иконку у lang+login (компактно) */
@media (max-width: 767px) {
  .nav-mat-iconbtn--lang .nav-mat-iconbtn__text,
  .nav-mat-iconbtn--cta .nav-mat-iconbtn__text { display: none; }
  .nav-mat-iconbtn--lang,
  .nav-mat-iconbtn--cta { padding: 0; width: var(--size); }
}
/* CTA «Войти» — синий M3 primary */
.nav-mat-iconbtn--cta {
  background: var(--m3-primary);
  color: var(--m3-on-primary);
}
.nav-mat-iconbtn--cta:hover { background: var(--m3-primary-hover); color: #fff; }
.nav-mat-iconbtn--cta:active { background: var(--m3-primary-hover); }

/* ---------- 3. Sidebar (drawer on mobile, rail on tablet, full on desktop) - */
.nav-mat-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sb-w-full);
  /* Pad the drawer to clear notch / home indicator on iOS. */
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  z-index: 95;
  display: flex;
  flex-direction: column;
  background: var(--m3-surface);
  border-right: 1px solid var(--m3-outline);
  box-shadow: var(--m3-elev-2);
  transform: translateX(-100%);
  transition: transform var(--m3-t-base), width var(--m3-t-base);
  overflow: hidden;
}

/* Mobile drawer: closed by default, open when .is-open */
.nav-mat-sidebar.is-open {
  transform: translateX(0);
}

/* Tablet: collapse to a 80px rail (icons only), always visible */
@media (min-width: 768px) and (max-width: 1023px) {
  .nav-mat-sidebar {
    width: var(--sb-w-rail);
    transform: translateX(0);
    box-shadow: var(--m3-elev-1);
  }
  .nav-mat-sidebar .nav-mat-sidebar__brand-text,
  .nav-mat-sidebar .nav-mat-sidebar__lang,
  .nav-mat-sidebar .nav-mat-sidebar__footer,
  .nav-mat-link__label {
    display: none;
  }
  .nav-mat-link {
    justify-content: center;
    padding: 14px 0;
  }
  .nav-mat-link__icon { margin-right: 0; }
  .nav-mat-sidebar__brand {
    justify-content: center;
    padding: 16px 8px;
  }
}

/* Desktop: always visible, full width */
@media (min-width: 1024px) {
  .nav-mat-sidebar {
    transform: translateX(0);
    box-shadow: none;
    border-right: 1px solid var(--m3-outline);
  }
}

/* ---------- 4. Sidebar internals ---------------------------------------- */
.nav-mat-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px 14px;
  text-decoration: none;
  color: var(--m3-on-surface);
  border-bottom: 1px solid var(--m3-outline);
  flex-shrink: 0;
}
.nav-mat-sidebar__brand img {
  height: 36px;
  width: 36px;
  max-width: 36px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.06));
}
.nav-mat-sidebar__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
  min-width: 0;
}
.nav-mat-sidebar__brand-title {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.02em;
  color: var(--m3-on-surface);
}
.nav-mat-sidebar__brand-slogan {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--m3-primary);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

/* Lang picker — компактный dropdown, position рассчитывается JS под кнопкой */
.nav-mat-langdrop {
  position: fixed;
  /* top/left устанавливаются JS-ом из langBtn.getBoundingClientRect() */
  background: var(--m3-surface);
  border-radius: var(--m3-radius);
  box-shadow: var(--m3-elev-3);
  padding: 6px;
  min-width: 130px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 105;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--m3-t-fast), transform var(--m3-t-fast), visibility 0s linear var(--m3-t-fast);
}
.nav-mat-langdrop.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity var(--m3-t-fast), transform var(--m3-t-fast);
}
.nav-mat-langdrop__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--m3-radius-sm);
  text-decoration: none;
  color: var(--m3-on-surface);
  font-size: 14px;
  font-weight: 600;
  transition: background var(--m3-t-fast);
  white-space: nowrap;
}
.nav-mat-langdrop__item:hover { background: var(--m3-surface-1); }
.nav-mat-langdrop__item.is-active { background: var(--m3-surface-2); color: var(--m3-primary); }
.nav-mat-langdrop__flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,.1);
  flex-shrink: 0;
}
.nav-mat-langdrop__flag svg {
  width: 100%;
  height: 100%;
  display: block;
}
.nav-mat-langdrop__code { letter-spacing: .02em; }

/* Menu list */
.nav-mat-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  /* Kinetic / momentum scroll on iOS for the drawer's link list. */
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px;
  list-style: none;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-mat-sidebar__nav::-webkit-scrollbar { width: 6px; }
.nav-mat-sidebar__nav::-webkit-scrollbar-thumb { background: var(--m3-outline); border-radius: 3px; }

.nav-mat-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  min-height: 52px;
  border-radius: var(--m3-radius-pill); /* M3 expressive pill highlight */
  font-size: 15px;
  font-weight: 500;
  color: var(--m3-on-surface);
  text-decoration: none;
  transition: background var(--m3-t-fast), color var(--m3-t-fast);
  cursor: pointer;
}
.nav-mat-link:hover {
  background: var(--m3-surface-1);
  color: var(--m3-primary);
}
.nav-mat-link:active {
  background: var(--m3-surface-2);
}
.nav-mat-link.is-active {
  background: var(--m3-surface-2);
  color: var(--m3-primary);
  font-weight: 600;
}
.nav-mat-link.is-active .nav-mat-link__icon {
  color: var(--m3-primary);
}

.nav-mat-link__icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: var(--m3-on-surface-var);
  flex-shrink: 0;
  transition: color var(--m3-t-fast);
}
.nav-mat-link__icon .material-symbols-rounded {
  font-size: 22px;
}
.nav-mat-link__label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tablet rail tooltip on hover */
@media (min-width: 768px) and (max-width: 1023px) {
  .nav-mat-link[data-label]::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--m3-on-surface);
    color: var(--m3-surface);
    padding: 6px 10px;
    border-radius: var(--m3-radius-sm);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--m3-t-fast);
    box-shadow: var(--m3-elev-2);
    z-index: 5;
  }
  .nav-mat-link:hover[data-label]::after {
    opacity: 1;
  }
}

/* Footer area inside sidebar (login/account + phone) */
.nav-mat-sidebar__footer {
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--m3-outline);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.nav-mat-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--m3-primary);
  color: var(--m3-on-primary);
  padding: 12px 18px;
  min-height: 48px;
  border-radius: var(--m3-radius-pill);
  font-weight: 600;
  font-size: 14.5px;
  text-decoration: none;
  transition: background var(--m3-t-fast), box-shadow var(--m3-t-base), transform var(--m3-t-fast);
  box-shadow: 0 4px 12px -4px rgba(26,115,232,.4);
}
.nav-mat-cta:hover {
  background: var(--m3-primary-hover);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -6px rgba(26,115,232,.5);
}
.nav-mat-cta .material-symbols-rounded { font-size: 20px; }

.nav-mat-phone {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--m3-radius);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--m3-on-surface-var);
  text-decoration: none;
  background: var(--m3-surface-1);
  transition: background var(--m3-t-fast), color var(--m3-t-fast);
}
.nav-mat-phone:hover {
  background: var(--m3-surface-2);
  color: var(--m3-primary);
}
.nav-mat-phone .material-symbols-rounded { font-size: 18px; }

/* ---------- 5. Scrim (mobile drawer backdrop) --------------------------- */
.nav-mat-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(2px);
  z-index: 94;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--m3-t-base), visibility 0s linear var(--m3-t-base);
}
.nav-mat-scrim.is-open {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--m3-t-base);
}
@media (min-width: 1024px) {
  .nav-mat-scrim { display: none; }
}

/* ---------- 6. Body scroll lock when drawer open ------------------------ */
body.sb-no-scroll {
  overflow: hidden;
}
@media (min-width: 1024px) {
  body.sb-no-scroll {
    overflow: auto;
  }
}

/* ---------- 7. Reduced motion ------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .nav-mat-sidebar,
  .nav-mat-scrim,
  .nav-mat-link,
  .nav-mat-cta,
  .nav-mat-iconbtn {
    transition-duration: 0.01ms !important;
  }
}

/* ---------- 8. Narrow phones (≤360px, iPhone SE / older Android) -------- */
/* On 320–360px screens 280px drawer leaves only 40px visible scrim, which
   makes "tap-outside-to-close" hard. Cap drawer at 88vw so there's always a
   reachable scrim strip for closing the menu. */
@media (max-width: 360px) {
  .nav-mat-sidebar {
    width: min(var(--sb-w-full), 88vw);
  }
}
