/* Responsive helpers and final mobile polish */
@media (max-width: 1060px){
  .container{width:min(100% - 22px, var(--max));}
}

@media (max-width: 560px){
  html{scroll-padding-top:76px;}
}

/* ==========================================================================
   FINAL RESPONSIVE FIX — 15y dev pass
   Goals:
   - desktop/tablet menu is centered and readable;
   - decorative icons never overlap menu text;
   - mobile uses burger menu, not desktop nav;
   - no horizontal overflow on phones;
   - cards, photos, grids and modals adapt cleanly.
   ========================================================================== */

*,
*::before,
*::after{
  box-sizing:border-box;
}

html,
body{
  max-width:100%;
  overflow-x:hidden;
}

img,
svg,
video{
  max-width:100%;
}

.topbar{
  position:sticky;
  top:0;
  z-index:120;
}

.topbar .container{
  width:min(100% - 32px, 1500px);
}

.nav{
  width:100%;
  min-height:88px;
  display:grid;
  grid-template-columns:minmax(220px, 280px) minmax(560px, 1fr) minmax(220px, auto);
  align-items:center;
  gap:16px;
}

.brand{
  min-width:0 !important;
  display:flex;
  align-items:center;
  gap:12px;
}

.brand > div:last-child{
  min-width:0;
}

.brand strong,
.brand span{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.logo{
  flex:0 0 auto;
}

/* Desktop navigation: clean 2 rows, centered */
.navlinks{
  justify-self:center;
  align-self:center;
  width:min(100%, 760px);
  max-width:760px;
  display:grid !important;
  grid-template-columns:repeat(5, minmax(92px, 1fr));
  grid-auto-rows:42px;
  gap:8px 10px;
  padding:14px 18px;
  border-radius:32px;
  border:1px solid rgba(19,34,24,.08);
  background:linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,.72));
  box-shadow:0 18px 46px rgba(19,34,24,.08), inset 0 1px 0 rgba(255,255,255,.82);
  flex-wrap:unset !important;
}

/* Important: icons are part of the flex flow, not absolute */
.navlinks a{
  position:relative;
  width:100%;
  height:42px;
  min-height:42px;
  display:flex !important;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding:0 11px !important;
  border-radius:20px;
  border:1px solid transparent;
  background:transparent;
  box-shadow:none;
  color:#48614e;
  font-size:13px;
  font-weight:850;
  line-height:1;
  letter-spacing:-.018em;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.navlinks a::before{
  content:"";
  position:static !important;
  transform:none !important;
  flex:0 0 11px;
  width:11px !important;
  height:11px !important;
  opacity:.95;
  box-shadow:0 0 0 4px rgba(255,255,255,.72), 0 8px 16px rgba(19,34,24,.08);
  margin:0 !important;
}

.navlinks a::after{
  display:none !important;
}

.navlinks a:hover,
.navlinks a.active{
  color:#103414;
  background:linear-gradient(135deg, rgba(126,217,87,.24), rgba(255,255,255,.92));
  border-color:rgba(126,217,87,.26);
  box-shadow:0 12px 26px rgba(126,217,87,.12), inset 0 1px 0 rgba(255,255,255,.9);
  transform:none;
}

.nav-actions{
  justify-self:end;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
  min-width:0;
}

.header-phone-modal-trigger{
  appearance:none;
  border:none;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:48px;
  padding:12px 16px;
  border-radius:999px;
  background:rgba(255,255,255,.90);
  border:1px solid rgba(19,34,24,.10);
  color:#203427;
  font:inherit;
  font-size:14px;
  font-weight:950;
  letter-spacing:-.02em;
  white-space:nowrap;
  box-shadow:0 12px 30px rgba(19,34,24,.06);
  transition:transform .18s ease, background .18s ease, border-color .18s ease;
  margin:0 !important;
}

.header-phone-modal-trigger:hover{
  transform:translateY(-2px);
  background:rgba(126,217,87,.10);
  border-color:rgba(126,217,87,.30);
}

/* Desktop/tablet sizing */
@media (max-width: 1360px){
  .nav{
    grid-template-columns:minmax(205px, 250px) minmax(520px, 1fr) minmax(168px, auto);
    gap:12px;
  }

  .navlinks{
    width:min(100%, 680px);
    grid-template-columns:repeat(5, minmax(84px, 1fr));
    gap:7px 8px;
    padding:12px 14px;
  }

  .navlinks a{
    font-size:12px;
    padding:0 9px !important;
  }

  .header-phone-modal-trigger{
    display:none;
  }
}

@media (max-width: 1180px){
  .nav{
    grid-template-columns:minmax(190px, 225px) minmax(480px, 1fr) auto;
  }

  .brand span{
    display:none !important;
  }

  .navlinks{
    width:min(100%, 610px);
    grid-template-columns:repeat(5, minmax(76px, 1fr));
    gap:6px;
    padding:11px 12px;
  }

  .navlinks a{
    font-size:11px;
    gap:6px;
  }

  .navlinks a::before{
    flex-basis:9px;
    width:9px !important;
    height:9px !important;
  }
}

/* Mobile/tablet: desktop menu is hidden; burger is visible */
@media (max-width: 1099px){
  .topbar .container{
    width:min(100% - 20px, var(--max));
  }

  .nav{
    min-height:74px !important;
    display:flex !important;
    align-items:center;
    justify-content:space-between;
    gap:10px;
  }

  .brand{
    flex:1 1 auto;
    min-width:0 !important;
    gap:10px;
  }

  .brand strong{
    font-size:15px;
  }

  .logo{
    width:50px !important;
    height:50px !important;
    border-radius:16px !important;
    padding:4px !important;
  }

  #desktopNav,
  .navlinks{
    display:none !important;
  }

  .nav-actions{
    flex:0 0 auto;
    display:flex !important;
    align-items:center;
    gap:8px;
  }

  .nav-actions .btn-primary{
    display:none !important;
  }

  .header-phone-modal-trigger{
    display:inline-flex !important;
    width:48px;
    height:48px;
    min-height:48px;
    padding:0;
    border-radius:16px;
    font-size:0;
  }

  .header-phone-modal-trigger::before{
    content:"☎";
    font-size:20px;
    line-height:1;
  }

  .burger{
    display:inline-grid !important;
    place-items:center;
    width:48px;
    height:48px;
    padding:0;
    flex:0 0 48px;
  }

  .burger span{
    width:20px;
    margin:2px auto;
  }

  .mobile-panel{
    display:none;
    padding:12px 0 18px;
    border-top:1px solid rgba(19,34,24,.08);
    background:rgba(255,255,255,.78);
    backdrop-filter:blur(16px);
  }

  .mobile-panel.open{
    display:block !important;
  }

  .mobile-links{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:8px;
  }

  .mobile-links a{
    min-height:48px;
    display:flex;
    align-items:center;
    justify-content:center;
    text-align:center;
    padding:12px 10px;
    border-radius:16px;
    font-size:14px;
    font-weight:850;
    color:#23392a;
    border:1px solid rgba(19,34,24,.08);
    background:rgba(255,255,255,.88);
    box-shadow:0 8px 22px rgba(19,34,24,.04);
  }

  .mobile-links a.active{
    color:#103414;
    background:linear-gradient(135deg, rgba(126,217,87,.26), rgba(255,255,255,.92));
    border-color:rgba(126,217,87,.26);
  }
}

/* Main layout adaptivity */
@media (max-width: 1060px){
  .hero{
    padding:44px 0 38px;
  }

  .hero-grid,
  .page-hero-grid,
  .split,
  .contact-wrap,
  .business-map-wrap{
    grid-template-columns:1fr !important;
  }

  .hero-card{
    min-height:auto !important;
  }

  .page-side{
    display:grid;
    grid-template-columns:repeat(2, minmax(0, 1fr));
    gap:14px;
  }

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

  .grid-3,
  .reviews-grid,
  .case-detail-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }

  .article-hero-line,
  .case-detail-hero{
    grid-template-columns:1fr !important;
  }
}

@media (max-width: 820px){
  .container{
    width:min(100% - 22px, var(--max));
  }

  .hero{
    padding-top:34px;
  }

  .hero-grid{
    gap:22px;
  }

  h1{
    font-size:clamp(42px, 13vw, 64px) !important;
    line-height:.94 !important;
    letter-spacing:-.07em !important;
  }

  h2{
    font-size:clamp(32px, 9vw, 46px) !important;
  }

  .lead{
    font-size:17px;
  }

  .grid-3,
  .grid-2,
  .reviews-grid,
  .page-photo-grid,
  .page-side,
  .case-detail-grid{
    grid-template-columns:1fr !important;
  }

  .page-photo-yandex .page-photo-card,
  .page-photo-smm .page-photo-card{
    order:0 !important;
  }

  .section-head{
    display:block !important;
  }

  .section-head p{
    margin-top:14px;
  }

  .mini-metrics,
  .direction-mini,
  .case-result{
    grid-template-columns:1fr;
  }

  .photo-wrap,
  .page-photo-card,
  .portrait-card,
  .portrait-contact .portrait-card,
  .business-photo{
    aspect-ratio:4 / 5 !important;
    height:auto !important;
    min-height:0 !important;
  }

  .hero-card{
    border-radius:28px;
    padding:16px;
  }

  .page-title-card{
    padding:24px;
    border-radius:26px;
  }

  .card{
    border-radius:24px;
    padding:20px;
  }

  .floating-cta{
    right:12px;
    bottom:12px;
  }

  .floating-cta a{
    width:50px;
    height:50px;
  }

  .article-modal,
  .case-modal,
  .contact-choice-modal{
    padding:10px;
  }

  .article-modal-card,
  .case-modal-card,
  .contact-choice-card{
    border-radius:26px;
  }
}

@media (max-width: 560px){
  .topbar .container{
    width:calc(100% - 16px);
  }

  .nav{
    min-height:70px !important;
  }

  .brand strong{
    font-size:14px;
  }

  .brand span{
    display:none !important;
  }

  .logo{
    width:46px !important;
    height:46px !important;
  }

  .header-phone-modal-trigger,
  .burger{
    width:44px;
    height:44px;
    min-height:44px;
    flex-basis:44px;
  }

  .mobile-links{
    grid-template-columns:1fr;
  }

  .hero-actions .btn,
  .section-actions .btn{
    width:100%;
  }

  h1{
    font-size:clamp(38px, 13.2vw, 50px) !important;
  }

  h2{
    font-size:clamp(30px, 10vw, 40px) !important;
  }

  .grid-4{
    grid-template-columns:1fr;
  }

  .footer-grid{
    display:grid;
  }

  .contact-choice-grid,
  .article-formula{
    grid-template-columns:1fr !important;
  }

  .article-modal-body,
  .case-modal-body{
    padding:18px;
  }

  .photo-badge{
    left:12px;
    bottom:12px;
    font-size:12px;
    padding:8px 11px;
  }
}
