/* Vioshoko — unified mobile layout (load after b2c.css / b2b.css) */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  max-width: 100%;
  overflow-x: clip;
  overscroll-behavior-x: none;
}

/* —— Safe top clearance under fixed topbar —— */
@media (max-width: 900px) {
  :root {
    --mobile-top: max(92px, calc(16px + env(safe-area-inset-top, 0px) + 56px));
  }

  .b2b-page,
  .catalog-page,
  .account-page,
  .legal-page,
  .case-page,
  .page-auth-b2c .auth-page,
  .page-auth-b2b .auth-page {
    padding-top: var(--mobile-top);
  }

  body.b2b-landing .b2b-page {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
  }

  .page-auth-b2c .auth-page,
  .page-auth-b2b .auth-page {
    padding-bottom: 40px;
    align-items: flex-start;
  }

  .container {
    width: min(100% - 32px, var(--container));
  }

  /* —— Topbar —— */
  .topbar-fixed {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
  }

  .topbar {
    gap: 8px;
    padding: 8px 10px 8px 14px;
    min-width: 0;
  }

  .logo {
    font-size: 0.92rem;
    letter-spacing: 0.02em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .logo--img img {
    width: 88px;
    height: 11px;
  }

  .topbar__right {
    gap: 6px;
    flex-shrink: 0;
  }

  .topbar .btn--outline {
    display: none !important;
  }

  .topbar .auth-user,
  .topbar .b2b-authed-only.btn {
    display: none !important;
  }

  .h2 {
    font-size: clamp(1.35rem, 5.8vw, 1.8rem);
    letter-spacing: -0.01em;
  }

  .section {
    padding: 40px 0;
  }

  .block {
    padding: 36px 0;
  }

  /* —— B2C hero —— */
  .hero {
    min-height: 0;
    height: auto;
  }

  .hero__center {
    padding: calc(var(--mobile-top) + 8px) 16px 44px;
    min-height: min(58vh, 480px);
  }

  .hero__brand {
    font-size: clamp(1.85rem, 9vw, 2.6rem);
    letter-spacing: 0.04em;
    line-height: 1.05;
    margin-bottom: 18px;
  }

  .hero__actions {
    flex-direction: column;
    align-items: stretch;
    width: min(100%, 300px);
    gap: 10px;
  }

  .hero__actions .btn {
    width: 100%;
  }

  /* —— B2B hero —— */
  .b2b-hero {
    display: flex;
    flex-direction: column;
    gap: 14px;
    grid-template-columns: unset;
    grid-template-rows: unset;
    grid-template-areas: unset;
    border-radius: 24px;
    padding: 18px 16px;
    overflow: hidden;
  }

  .b2b-hero > h1,
  .b2b-hero__meta,
  .benefit-list,
  .b2b-hero .b2b-slider,
  .b2b-hero__cta {
    grid-area: unset;
    width: 100%;
    min-width: 0;
  }

  .b2b-hero > h1 {
    font-size: clamp(1.3rem, 6vw, 1.75rem);
    line-height: 1.15;
  }

  .b2b-hero__meta {
    font-size: 0.95rem;
    line-height: 1.45;
    justify-self: start;
    text-align: left;
  }

  .benefit-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .benefit-card {
    flex: none !important;
    min-height: 0 !important;
    height: auto !important;
    align-items: start;
    padding: 12px 14px;
  }

  .b2b-hero .b2b-slider {
    flex: none;
    min-height: 220px;
    height: 220px;
  }

  /* —— Grids → 1 column (catalog: 2-up; why-grid: stays 2×2) —— */
  .works-grid,
  .cat-grid,
  .account-grid,
  .about-band,
  .tasks-grid,
  .prod-grid,
  .mosaic,
  .mosaic--row,
  .holiday-grid {
    grid-template-columns: 1fr !important;
    gap: 14px;
    width: 100%;
  }

  .page-catalog .catalog-layout,
  .page-catalog .catalog-main,
  .page-catalog .catalog-products,
  .page-catalog .catalog-grid,
  #catalogGrid.catalog-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .page-catalog .catalog-grid,
  #catalogGrid.catalog-grid,
  .catalog-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px 10px;
    width: 100%;
  }

  .catalog-grid .product-card,
  .catalog-grid .product-card--hit {
    width: 100%;
    max-width: none;
    min-width: 0;
    justify-self: stretch;
  }

  .catalog-grid .product-card h3 {
    font-size: 0.92rem;
    line-height: 1.25;
  }

  .catalog-grid .product-card .price {
    font-size: 0.95rem;
  }

  .product-card .product-actions {
    width: 100%;
    gap: 6px;
    margin-top: 8px;
  }

  .product-card .product-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 36px;
    padding: 8px 8px;
    font-size: 0.72rem;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
  }

  .pagination {
    justify-content: center;
    width: 100%;
  }

  /* Почему нас выбирают — 2×2 как на десктопе, ровные карточки */
  #why .why-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
    margin-bottom: 14px;
    align-items: stretch;
  }

  #why .why-card {
    min-height: clamp(148px, 36vw, 240px);
    height: 100%;
    padding: clamp(14px, 3.6vw, 22px) !important;
    gap: 10px;
    border-radius: 20px;
    box-sizing: border-box;
  }

  #why .why-card__head {
    margin-bottom: 0;
    gap: 8px;
    align-items: flex-start;
  }

  #why .why-card__head h3 {
    font-size: clamp(0.78rem, 3.1vw, 1.05rem);
    line-height: 1.2;
    flex: 1 1 auto;
    min-width: 0;
  }

  #why .why-badge {
    width: clamp(30px, 8vw, 38px);
    height: clamp(24px, 6.4vw, 30px);
    border-radius: 999px;
    font-size: clamp(0.72rem, 2.8vw, 0.9rem);
  }

  #why .why-metrics {
    gap: 10px;
  }

  #why .why-metric small {
    font-size: clamp(0.68rem, 2.6vw, 0.82rem);
    line-height: 1.25;
  }

  #why .why-metric strong {
    font-size: clamp(1rem, 4.2vw, 1.45rem);
    line-height: 1.1;
  }

  #why .why-card p,
  #why .why-card .why-stat-label {
    font-size: clamp(0.68rem, 2.6vw, 0.88rem);
    line-height: 1.35;
  }

  #why .why-card .why-stat {
    /* Тот же размер, что у .why-metric strong выше */
    font-size: clamp(1rem, 4.2vw, 1.45rem);
    margin: 0 0 4px;
    line-height: 1.1;
  }

  /* 150+ готовых решений */
  #solutions .solutions-banner {
    grid-template-columns: 1fr !important;
    padding: 0;
    gap: 0;
    border-radius: 32px;
    min-height: 0;
  }

  #solutions .solutions-banner__copy {
    padding: 22px 20px 20px;
  }

  #solutions .solutions-banner h2 {
    max-width: none;
    font-size: clamp(1.15rem, 4.8vw, 1.45rem);
    line-height: 1.3;
  }

  #solutions .solutions-banner__title-lead {
    white-space: normal;
  }

  #solutions .solutions-banner__bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  #solutions .solutions-banner .btn {
    width: auto;
    color: var(--ink);
  }

  #solutions .solutions-banner .b2b-slider {
    min-height: 200px;
    height: 220px;
    width: 100%;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 0;
    overflow: hidden;
  }

  #solutions .solutions-banner .b2b-slider__slide {
    min-height: 200px;
  }

  .mosaic {
    min-height: 0;
  }

  .mosaic__item,
  .mosaic__item--tall,
  .mosaic__item--sm {
    grid-column: auto !important;
    grid-row: auto !important;
    height: auto;
    min-height: 136px;
  }

  .mosaic__item:not(.mosaic__item--plain) .mosaic__bg {
    background-position: right center;
  }

  .mosaic__item:not(.mosaic__item--plain) .mosaic__label {
    margin: 6px 4px;
    padding: 14px 16px 12px 14px;
    max-width: min(52%, 180px);
    border-radius: 0;
  }

  .mosaic__item:not(.mosaic__item--plain) .mosaic__label::before {
    inset: -8px -18px -10px -12px;
  }

  .mosaic__label {
    padding: 16px 18px;
  }

  .mosaic__label small {
    font-size: 0.78rem;
    color: #4a5060;
  }

  .mosaic__label strong,
  .mosaic__item--sm .mosaic__label strong {
    font-size: 1.08rem;
    line-height: 1.2;
    color: #12131a;
  }

  /* —— Catalog —— */
  .catalog-page {
    padding-top: var(--mobile-top);
    padding-bottom: 56px;
  }

  .filters {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filters__left,
  .filters__right {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .field,
  .vs-select--field,
  .vs-select--field .vs-select__trigger,
  .filter-select,
  .filter-select__control {
    min-width: 0 !important;
    width: 100%;
    flex: 1 1 100%;
    box-sizing: border-box;
  }

  .catalog-layout {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .catalog-groups {
    position: static;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2px 2px 8px;
    margin: 0 0 4px;
  }

  .catalog-group {
    display: contents;
  }

  .catalog-group__item {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.92rem;
    line-height: 1.2;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 999px;
    background: var(--soft);
    color: var(--ink);
  }

  .catalog-group__item.is-active {
    background: var(--navy);
    color: #fff;
    font-weight: 700;
  }

  .popular-carousel .product-card {
    flex: 0 0 min(78vw, 260px);
  }

  .carousel-nav__btn {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .product-card h3 {
    font-size: 1.05rem;
    line-height: 1.3;
  }

  .cat-hero,
  .cat-hero__content {
    min-height: 0;
  }

  .cat-hero__content {
    grid-template-columns: 1fr;
    padding: 22px 18px;
  }

  .cat-hero__copy h1 {
    max-width: none;
    font-size: clamp(1.35rem, 6vw, 1.85rem);
  }

  .cat-hero__actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cat-hero__actions .btn {
    width: 100%;
  }

  .prod-card {
    aspect-ratio: 16 / 10;
    min-height: 0;
  }

  .prod-card__label {
    font-size: clamp(0.92rem, 4vw, 1.15rem);
    line-height: 1.25;
  }

  .task-card {
    aspect-ratio: 1 / 1;
    min-height: 0;
  }

  .logo-marquee__group {
    gap: 16px;
  }

  .logo-slot {
    width: clamp(135px, 36vw, 180px);
    height: 66px;
  }

  .reviews-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Отзывы — свайп пальцем */
  .reviews-track-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    touch-action: pan-x;
  }

  .reviews-track {
    transform: none !important;
  }

  .review-card {
    flex: 0 0 min(300px, 88vw);
    scroll-snap-align: start;
  }

  /* —— Modals —— */
  .product-modal__dialog {
    width: min(100%, 920px);
    max-height: 92vh;
    overflow: auto;
    padding: 16px;
    border-radius: 22px;
  }

  .product-card--modal {
    flex-direction: column;
    gap: 16px;
  }

  .product-card--modal .media {
    flex: none;
    width: 100%;
    max-width: 100%;
    max-height: min(42vh, 320px);
    aspect-ratio: 16 / 10;
  }

  .product-card--modal .media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
  }

  .product-card--modal h3 {
    padding-right: 44px;
  }

  .product-modal__label {
    font-size: 0.8rem;
  }

  .b2b-modal__grid {
    display: flex !important;
    flex-direction: column;
    gap: 16px;
  }

  .b2b-modal__col-photo {
    position: static !important;
    grid-row: auto !important;
    width: 100%;
  }

  .b2b-modal__media img {
    aspect-ratio: 1 / 1;
    min-height: 220px;
    max-height: 320px;
    object-fit: cover;
  }

  .b2b-modal__col-price {
    position: absolute;
    top: 16px;
    right: 52px;
    z-index: 2;
  }

  .b2b-modal__fav {
    width: 42px;
    height: 42px;
    font-size: 1.35rem;
  }

  .b2b-modal__title {
    font-size: clamp(1.25rem, 5.5vw, 1.65rem) !important;
    line-height: 1.2;
    padding-right: 88px;
  }

  .b2b-modal__dialog {
    padding: 16px;
    border-radius: 22px;
    max-height: 92dvh;
    width: 100%;
  }

  .b2b-modal {
    z-index: 700;
    padding: 10px;
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
    align-items: end;
    place-items: end center;
  }

  .b2b-modal__close {
    top: 10px;
    right: 10px;
    z-index: 6;
    background: #fff;
  }

  #taskLeadModal .b2b-modal__dialog {
    max-height: min(92dvh, calc(100dvh - 20px));
    padding: 54px 14px 18px;
    border-radius: 22px 22px 16px 16px;
  }

  #taskLeadModal .b2b-modal__title {
    font-size: clamp(1.12rem, 4.8vw, 1.35rem) !important;
    padding-right: 0 !important;
    margin-bottom: 8px;
  }

  #taskLeadModal .b2b-modal__copy {
    font-size: 0.88rem;
    line-height: 1.4;
  }

  .b2b-modal__col-info {
    gap: 14px;
  }

  .b2b-modal__tiers {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .b2b-modal__tier {
    white-space: normal;
    flex: none;
    width: 100%;
    min-height: 48px;
    padding: 14px 10px 10px;
    font-size: 0.84rem;
  }

  .b2b-modal__tier-badge {
    top: -6px;
    right: 8px;
    font-size: 0.68rem;
  }

  .b2b-modal__nav-btn {
    width: 36px;
    height: 36px;
  }

  .b2b-modal__textarea {
    min-height: 88px;
  }

  .b2b-modal__col-info > .btn {
    width: 100%;
    justify-content: center;
  }

  /* —— Case pages —— */
  .case-page {
    padding-top: var(--mobile-top);
    padding-bottom: 48px;
  }

  .case-article {
    max-width: 100%;
    padding-inline: 2px;
  }

  .case-article h1 {
    font-size: clamp(1.9rem, 8vw, 2.6rem);
    max-width: 100%;
  }

  .case-lead {
    font-size: 1.25rem;
    line-height: 1.6;
  }

  .case-body h2 {
    font-size: 1.55rem;
    margin-top: 34px;
  }

  .case-body p {
    font-size: 1.18rem;
    line-height: 1.8;
  }

  .case-cta {
    flex-direction: column;
    align-items: stretch;
  }

  .case-cta .btn {
    width: 100%;
    justify-content: center;
  }

  /* —— Account / auth —— */
  .account-page {
    padding-top: var(--mobile-top);
    padding-bottom: 56px;
  }

  .cab-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .account-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
  }

  .account-tabs__item {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.88rem;
    padding: 10px 14px;
  }

  .cab-kpis,
  .cab-promo-kpis {
    grid-template-columns: 1fr 1fr;
  }

  .account-row {
    grid-template-columns: 72px 1fr;
  }

  .account-row__side {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: space-between;
    flex-direction: row;
  }

  .cart-summary {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .page-auth-b2c .auth-card,
  .page-auth-b2b .auth-card {
    padding: 24px 18px 22px;
    border-radius: 22px;
  }

  .page-auth-b2c .auth-card .h2,
  .page-auth-b2b .auth-card .h2 {
    font-size: clamp(1.3rem, 6vw, 1.65rem);
  }

  .auth-stub__code {
    font-size: clamp(1.15rem, 5.5vw, 1.5rem);
    letter-spacing: 0.12em;
  }

  .auth-pass {
    flex-wrap: wrap;
  }

  /* —— Legal —— */
  .legal-page {
    padding-top: var(--mobile-top);
    padding-bottom: 48px;
  }

  .legal-card {
    padding: 24px 18px 22px;
    border-radius: 22px;
  }

  /* —— Collab / about —— */
  .collab h2 {
    font-size: clamp(1.25rem, 5.5vw, 1.7rem);
    letter-spacing: 0.03em;
  }

  .collab__watermark {
    white-space: normal;
    font-size: clamp(1.4rem, 8vw, 2.2rem);
  }

  .about-box {
    padding: 28px 18px;
    border-radius: 22px;
  }

  /* —— CMS custom page (page.html) —— */
  .custom-page__wrap {
    width: min(100% - 32px, 1120px);
    padding: 20px 0 48px;
  }

  .cp-hero {
    min-height: clamp(220px, 55vw, 360px);
    padding: 32px 16px;
  }

  .cp-hero h1 {
    font-size: clamp(1.6rem, 7vw, 2.4rem);
    letter-spacing: 0.04em;
  }

  .cp-mosaic,
  .cp-tasks,
  .cp-prod,
  .cp-works,
  .cp-about {
    grid-template-columns: 1fr !important;
    min-height: 0;
  }

  .cp-mosaic a:first-child {
    grid-row: auto !important;
  }

  .cp-mosaic a {
    min-height: 140px;
  }

  .cp-text {
    padding: 24px 18px;
  }

  .cp-reviews article {
    flex: 0 0 min(280px, 85vw);
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 24px, var(--container));
  }

  .cab-kpis,
  .cab-promo-kpis {
    grid-template-columns: 1fr;
  }

  .cab-kpi__count {
    font-size: 1.4rem;
  }

  .b2b-hero .b2b-slider {
    min-height: 200px;
    height: auto;
    aspect-ratio: 16 / 10;
  }

  .verify-page {
    padding: var(--mobile-top) 16px 40px;
  }
}

@media (max-width: 480px) {
  /* Узкие телефоны: цена в модалке уходит в поток, не наезжает на заголовок */
  .b2b-modal__col-price {
    position: static;
    margin: 4px 0 0;
  }

  .b2b-modal__title {
    padding-right: 52px;
  }
}

@media (max-width: 640px) {
  .legal-body a,
  .legal-body td {
    overflow-wrap: anywhere;
  }

  .footer__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }

  .footer__contacts {
    justify-content: flex-start;
  }

  .footer__logo {
    width: calc(36px * 1477 / 553);
    height: 36px;
  }

  .footer__bottom {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .footer__btns {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .footer__legal {
    align-items: flex-start;
    text-align: left;
    justify-self: start;
    max-width: none;
  }
}
