/* ============================================
   Catalog Overlay — Цветомания
   ============================================ */

/* === Кнопка «Каталог» === */
.catalog-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 22px;
    background: #FB4469;
    color: #fff;
    border: 0;
    border-radius: 8px;
    font-family: 'Source Sans 3', system-ui, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background-color .2s ease;
}
.catalog-trigger:hover { background: #e5375a; }
.catalog-trigger[aria-expanded="true"] { background: #c22b48; }

/* === Оверлей === */
.catalog-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    opacity: 0;
    transition: opacity .2s ease;
}
.catalog-overlay[hidden] { display: none; }
.catalog-overlay.is-open { opacity: 1; }

.catalog-overlay__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 20, .35);
    backdrop-filter: blur(2px);
}
.catalog-overlay__panel {
    position: relative;
    width: min(1440px, 96vw);
    margin: 32px auto;
    padding: 40px 64px 64px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 32px 64px rgba(0,0,0,.18);
    transform: translateY(-12px);
    transition: transform .25s ease;
}
.catalog-overlay.is-open .catalog-overlay__panel { transform: translateY(0); }

.catalog-overlay__close {
    position: absolute;
    top: 20px; right: 20px;
    width: 40px; height: 40px;
    background: #FFECF0;
    color: #FB4469;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease;
    z-index: 2;
}
.catalog-overlay__close:hover { background: #ffd9e0; }

/* === Сетка карточек === */
.catalog-overlay__grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 232px;
    gap: 20px;
}

/* === Карточка (базовое) === */
.cm-card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 24px;
    border-radius: 24px;
    text-decoration: none;
    color: #262729;
    overflow: hidden;
    background: #fff;
    transition: transform .2s ease, box-shadow .2s ease;
    min-width: 0;
}
.cm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

.cm-card__bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 0;
    border-radius: 24px;
}
.cm-card__body,
.cm-card__header,
.cm-card__products,
.cm-card__btn { position: relative; z-index: 1; }

/* Размеры плиток */
.cm-card--size-1-1 { grid-column: span 1; grid-row: span 1; }
.cm-card--size-1-2 { grid-column: span 1; grid-row: span 2; }
.cm-card--size-2-1 { grid-column: span 2; grid-row: span 1; }
.cm-card--size-2-2 { grid-column: span 2; grid-row: span 2; }

/* Цвет текста */
.cm-card--text-light { color: #fff; }
.cm-card--text-light .cm-card__subtitle { color: #E4E5E7; }
.cm-card--text-dark  .cm-card__subtitle { color: #A8A9AB; }
.cm-card--text-light::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, rgba(0,0,0,.05) 60%);
    z-index: 0;
    border-radius: 24px;
}

/* Типографика карточки */
.cm-card__title {
    font-family: 'Source Sans 3', system-ui, sans-serif;
    font-size: 24px;
    font-weight: 500;
    line-height: 1.1;
    margin: 0;
}
.cm-card__subtitle {
    font-size: 16px;
    line-height: 20px;
    margin-top: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Плоская карточка */
.cm-card--flat { background-color: #F4F5F7; }

/* Карточка с подкатегориями */
.cm-card--sub .cm-card__subcats {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.cm-card--sub .cm-card__subcat-link {
    display: inline-block;
    font-size: 14px;
    color: #626365;
    text-decoration: none;
    line-height: 20px;
    transition: color .15s ease;
}
.cm-card--sub .cm-card__subcat-link:hover { color: #FB4469; }

/* Большая карточка с фото: заголовок внизу */
.cm-card--big .cm-card__body { margin-top: auto; }

/* Карточка «Рекомендуем» */
.cm-card--products {
    background: #F4F5F7;
    cursor: default;
}
.cm-card--products:hover { transform: none; box-shadow: none; }
.cm-card__header { margin-bottom: 16px; }
.cm-card__btn {
    display: block;
    margin-top: 16px;
    padding: 12px 16px;
    background: #FB4469;
    color: #fff;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
    transition: background-color .15s ease;
}
.cm-card__btn:hover { background: #e5375a; }

/* === Товары в «Рекомендуем» === */
.cm-products {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.cm-product {
    background: #fff;
    border-radius: 24px;
    padding: 8px;
    display: flex;
    flex-direction: column;
}
.cm-product__media {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 16px;
    overflow: hidden;
    background: #f7f7f7;
}
.cm-product__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cm-product__body {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}
.cm-product__name {
    font-size: 14px;
    line-height: 18px;
    color: #262729;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}
.cm-product__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}
.cm-product__price-old {
    text-decoration: line-through;
    color: #A8A9AB;
    font-size: 12px;
    margin-right: 6px;
}
.cm-product__price-new {
    color: #FB4469;
    font-weight: 600;
    font-size: 16px;
}
.cm-product__add {
    width: 32px;
    height: 32px;
    background: #FFECF0;
    color: #FB4469;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease;
}
.cm-product__add:hover { background: #ffd9e0; }

/* Блокировка скролла body при открытом оверлее */
body.catalog-overlay-open { overflow: hidden; }

/* === Адаптив === */
@media (max-width: 1200px) {
    .catalog-overlay__grid { grid-template-columns: repeat(4, 1fr); }
    .cm-card--size-2-2, .cm-card--size-2-1 { grid-column: span 2; }
}
@media (max-width: 900px) {
    .catalog-overlay__panel { padding: 24px 24px 40px; border-radius: 16px; margin: 16px 8px; }
    .catalog-overlay__grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 180px; }
    .cm-card--size-2-2, .cm-card--size-2-1 { grid-column: span 2; }
    .cm-card--size-1-2 { grid-row: span 2; }
    .cm-card__title { font-size: 20px; }
}
@media (max-width: 560px) {
    .catalog-overlay__grid { grid-template-columns: 1fr; grid-auto-rows: auto; }
    .cm-card { min-height: 140px; grid-column: span 1 !important; grid-row: span 1 !important; }
    .cm-card--big, .cm-card--products { min-height: 320px; }
}
