/* =========================================
   adaptive_compare.css — DNS-like mobile (Teanar style)
   Подключать ПОСЛЕ compare.css
   ========================================= */

@media (max-width: 720px){

  :root{
    --cmp-sticky-top: 0px;        /* fallback */
    --cmp-fixedbar-gap: 0px;      /* JS выставит высоту fixed-панели */
  }

  /* чтобы страница точно листалась вниз */
  html, body{
    height: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  .cmp{
    --cmp-accent: #111;
    --cmp-card-radius: 16px;
    --cmp-soft: #f6f7f8;
  }

  .cmp.container{
    margin: 0 auto;
    border-radius: 0;
    box-shadow: none;
    padding: 14px 10px 110px;
  }

  /* ✅ убираем любые “внутренние” скроллы на мобилке */
  .cmp-table-wrap,
  .cmp__scroll,
  #cmpScroll{
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  /* chips — одна строка со скроллом */
  .chips{
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .chip{ flex: 0 0 auto; }

  /* стрелки/края (десктоп) на мобилке не нужны */
  .cmp__nav, .edge{ display:none !important; }

  .cmp-scroll-inner{
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* десктопные карточки и таблица скрываем */
  .cmp-cards{ display:none !important; }
  .cmp-table{ display:none !important; }

  /* ===== TOP (2 колонки) ===== */
  .cmp-mtop{
    display:grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 0;
    margin: 12px 0 12px;
    border: 1px solid var(--cmp-border);
    border-radius: var(--cmp-card-radius);
    background:#fff;
    overflow:hidden;
  }

  .cmp-slot{
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: hidden;
    touch-action: pan-y;
  }
  .cmp-slot + .cmp-slot{
    border-left: 1px solid #eee;
  }

  .cmp-slot__body{ padding: 10px; }

  /* ✅ ЖЕЛЕЗНЫЙ FIX картинок: абсолютное центрирование */
  .cmp-slot__img{
    width: 100%;
    height: 110px;
    border-radius: 14px;
    background: var(--cmp-soft);
    overflow:hidden;

    display:block !important;
    position: relative !important;
    padding: 0 !important;
    line-height: 0 !important;
  }

  .cmp-slot__img img{
    position:absolute !important;
    inset: 0 !important;
    margin:auto !important;

    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;

    display:block !important;
  }

  .cmp-slot__img .ph{
    position:absolute;
    inset: 0;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size: 12px;
    color: var(--cmp-muted2);
    line-height: 1.2;
    text-align:center;
    padding: 8px;
  }

  .cmp-slot__name{
    margin-top: 10px;
    font-weight: 900;
    font-size: 12px;
    line-height: 1.15;
    max-height: 2.3em;
    overflow: hidden;
  }

  .cmp-slot__price{
    margin-top: 6px;
    font-weight: 900;
    font-size: 13px;
  }

  .cmp-slot__actions{
    margin-top: 10px;
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 8px;
  }

  .cmp-slot__rm{
    font-size: 12px;
    color: #c00;
    text-decoration: none;
    font-weight: 800;
  }

  .cmp-slot__nav{
    border-top: 1px solid #eee;
    background: #fff;
    padding: 8px 10px;
    display:flex;
    align-items:center;
    justify-content: space-between;
    gap: 8px;
  }

  .cmp-navbtn{
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid #e6e6e6;
    background: #fff;
    display:inline-flex;
    align-items:center;
    justify-content:center;
    font-size: 18px;
    line-height: 1;
    color: #111;
    user-select:none;
  }
  .cmp-navbtn:active{ transform: scale(.98); }

  .cmp-slot__count{
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--cmp-muted);
    font-weight: 800;
  }

  /* ===== FIXED mini bar (порталим в body через JS) ===== */
  .cmp-msticky{
    position: fixed;
    left: 0;
    right: 0;

    top: calc(var(--cmp-sticky-top, 0px) + env(safe-area-inset-top, 0px));
    z-index: 9999;

    display: none;
    margin: 0;
    padding: 8px 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);

    box-sizing: border-box;
  }
  .cmp-msticky.is-visible{ display:block; }

  .cmp-msticky__grid{
    display:grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 0;
    border: 1px solid #eee;
    border-radius: 14px;
    overflow:hidden;
    background:#fff;
  }

  .cmp-mini{
    position: relative;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 8px 10px;
    min-height: 64px;
    touch-action: pan-y;
  }
  .cmp-mini + .cmp-mini{
    border-left: 1px solid #eee;
  }

  .cmp-mini__row{
    display:grid;
    grid-template-columns: 44px 1fr;
    gap: 10px;
    align-items:center;
  }

  /* ✅ ЖЕЛЕЗНЫЙ FIX мини-картинок: абсолютное центрирование */
  .cmp-mini__img{
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--cmp-soft);
    overflow:hidden;

    display:block !important;
    position: relative !important;
    padding: 0 !important;
    line-height: 0 !important;
  }

  .cmp-mini__img img{
    position:absolute !important;
    inset: 0 !important;
    margin:auto !important;

    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    object-position: center !important;

    display:block !important;
  }

  .cmp-mini__img .ph{
    position:absolute;
    inset: 0;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size: 10px;
    color: var(--cmp-muted2);
    line-height: 1.1;
    text-align:center;
    padding: 3px;
  }

  .cmp-mini__name{
    font-weight: 900;
    font-size: 12px;
    line-height: 1.1;
    max-height: 2.2em;
    overflow:hidden;
  }

  .cmp-mini__arr{
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 1px solid #e6e6e6;
    background: rgba(255,255,255,.95);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    color: #111;
    user-select: none;
    z-index: 2;
  }
  .cmp-mini__arr:active{ transform: translateY(-50%) scale(.98); }
  .cmp-mini__arr:disabled{ opacity: .35; pointer-events: none; }
  .cmp-mini__arr--prev{ left: 8px; }
  .cmp-mini__arr--next{ right: 8px; }

  /* ===== MOBILE характеристики ===== */
  .cmp-mobile{
    display:block;
    padding-top: var(--cmp-fixedbar-gap, 0px); /* ✅ чтобы контент не прятался под fixed-панель */
  }

  .cmp-sec{
    border-top: 1px solid var(--cmp-border);
    padding-top: 6px;
  }

  .cmp-sec > summary{
    list-style:none;
    cursor:pointer;
    font-weight: 900;
    font-size: 16px;
    padding: 12px 2px;
    display:flex;
    align-items:center;
    justify-content:space-between;
    user-select:none;
  }
  .cmp-sec > summary::-webkit-details-marker{ display:none; }

  .cmp-sec > summary::after{
    content:"";
    width:8px;height:8px;
    border-right:2px solid #111;
    border-bottom:2px solid #111;
    transform: rotate(45deg);
    transition: transform .15s ease;
    opacity:.9;
  }
  .cmp-sec[open] > summary::after{ transform: rotate(-135deg); }

  .cmp-mrow{
    padding: 12px 2px;
    border-top: 1px solid #eee;
  }

  .cmp-mname{
    display:flex;
    align-items:center;
    gap:8px;
    font-size: 13px;
    color: var(--cmp-muted);
    font-weight: 800;
  }
  .cmp-mname::before{
    content:"";
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--cmp-accent);
    flex: 0 0 auto;
    opacity: .9;
  }

  .cmp-mvals{
    margin-top: 10px;
    display:grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow:hidden;
    border: 1px solid #eee;
    border-radius: 14px;
    background: #fff;
  }

  .cmp-mval{
    padding: 12px;
    font-size: 13px;
    line-height: 1.25;
    color: #111;
    word-break: break-word;
  }
  .cmp-mval + .cmp-mval{
    border-left: 1px dashed #e5e5e5;
  }

  .cmp-mrow:not(.is-equal) .cmp-mvals{
    background: var(--cmp-diff);
    border-color: #f0d7c2;
  }
  .cmp-mrow.is-equal .cmp-mvals{ opacity: .92; }
}

/* НЕ СВАЛИВАЕМСЯ В 1 КОЛОНКУ */
@media (max-width: 420px){
  .cmp-mtop,
  .cmp-msticky__grid{
    grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  }
  .cmp-slot__img{ height: 96px; }
  .cmp-slot__name{ font-size: 11px; }
  .cmp-navbtn{ width: 32px; height: 32px; }
}
@media (max-width: 720px){
  .cmp-msticky{ max-width: 100vw; }
}
