/* ================================================================
   TerraFloor — materials.css
   ================================================================ */

.materials-section {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding-block: 100px;
}

/* ---- Заголовок ---- */
.materials-section__head {
    display: flex;
    flex-direction: column;
    gap: 36px;
    margin-bottom: 40px;
}

.materials-section__eyebrow {
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--color-brown);
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
}
.materials-section__eyebrow-line {
    display: block;
    width: 19px;
    height: 0;
    border-top: 2px solid var(--color-brown);
    flex-shrink: 0;
}

.materials-section__title {
    color: var(--color-black);
    font-size: 45px;
    line-height: 51px;
    font-weight: 600;
    margin: 0;
}

.materials-section__desc {
    color: var(--color-gray);
    font-size: 17px;
    line-height: 27px;
    margin: 0;
}

/* ---- Сетка карточек 2×2 ---- */
.materials-grid__track {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
}

/* ---- Карточка материала ---- */
.material-card {
    background: linear-gradient(180deg, #fdf9f6 0%, #f8f8f8 100%);
    border-radius: 20px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 17px;
}

.material-card__title {
    color: var(--color-black);
    font-size: 30px;
    line-height: 34px;
    font-weight: 500;
    margin: 0;
}

.material-card__subtitle {
    color: var(--color-gray);
    font-size: 15px;
    line-height: 21px;
    margin: 0;
}

/* ---- Грид миниатюр — auto-fill, мин 100px ---- */
.material-card__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

/* ---- Миниатюра ---- */
.material-thumb {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    height: 100px;
    cursor: pointer;
    padding: 0;
    border: none;
    background: var(--color-light-gray);
    display: block;
    width: 100%;
}

.material-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}
.material-thumb:hover img { transform: scale(1.05); }

/* Подпись снизу */
.material-thumb__label {
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: #f6f0eb;
    border-radius: 104px;
    padding: 4px 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-black);
    line-height: 1.3;
    backdrop-filter: blur(11.5px);
    -webkit-backdrop-filter: blur(11.5px);
    white-space: nowrap;
    max-width: calc(100% - 44px);
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Иконка зума сверху справа */
.material-thumb__zoom {
    position: absolute;
    right: 5px;
    top: 5px;
    width: 29px;
    height: 29px;
    background: #f6f0eb;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-black);
    opacity: 0;
    transition: opacity 0.2s;
}
.material-thumb:hover .material-thumb__zoom { opacity: 1; }

/* ================================================================
   ЛАЙТБОКС
   ================================================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox[hidden] { display: none; }

.lightbox__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    cursor: pointer;
}

.lightbox__dialog {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.lightbox__close {
    position: absolute;
    top: -44px;
    right: 0;
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    cursor: pointer;
    transition: background 0.2s;
}
.lightbox__close:hover { background: rgba(255,255,255,0.3); }

.lightbox__img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 12px;
    object-fit: contain;
    display: block;
}

.lightbox__caption {
    color: var(--color-white);
    font-size: 15px;
    font-weight: 500;
    margin: 0;
    text-align: center;
    opacity: 0.85;
}

/* ================================================================
   Адаптив
   ================================================================ */
@media (max-width: 1280px) {
    .materials-section__title { font-size: 34px; line-height: 40px; }
    .material-card__title     { font-size: 22px; }
}

@media (max-width: 1024px) {
    .materials-grid__track { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .materials-section { padding-block: 50px; }
    .materials-section__title { font-size: 28px; line-height: 32px; }
    .material-card__grid { grid-template-columns: repeat(2, 1fr); }
    .material-thumb { height: 85px; }
}




/* 2 колонки */
.material-card__grid--grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.material-card__grid--grid-2  .material-thumb:nth-child(3),
.material-card__grid--grid-2  .material-thumb:nth-child(4) {
    grid-column: span 2;
}


/* Смешанная 3+3+1 — последний элемент на всю ширину */
.material-card__grid--grid-mix {
    grid-template-columns: repeat(3, 1fr);
}
.material-card__grid--grid-mix .material-thumb:last-child:nth-child(3n+1) {
    grid-column: 1 / -1;
}



/* 3 колонки базовая — последний ряд выравнивается по левому краю */
.material-card__grid--grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Если последний элемент одиночный — не растягивать */
.material-card__grid--grid-3 .material-thumb:last-child:nth-child(3n - 2) {
    grid-column: span 1;
}



.material-card__grid--grid-3 {
    grid-template-columns: repeat(6, 1fr);
}


/* 5 элементов: 3+2 — последние два не растягиваются */
.material-card__grid--grid-3 .material-thumb:nth-child(1),
.material-card__grid--grid-3 .material-thumb:nth-child(2),
 .material-card__grid--grid-3 .material-thumb:nth-child(3) {
    grid-column: span 2;
}


/* 5 элементов: 3+2 — последние два не растягиваются */
.material-card__grid--grid-3 .material-thumb:nth-child(4),
.material-card__grid--grid-3 .material-thumb:nth-child(5) {
    grid-column: span 3;
}



@media (max-width: 768px) {
  .material-card {
    padding: 20px;
 gap: 10px;
}
.material-thumb__label {
    padding: 2px 6px;
    font-size: 11px;
    max-width: calc(100% - 12px);
}
.materials-section__head {
    gap: 20px;
    margin-bottom: 20px;
}
.materials-section__eyebrow {
    font-size: 14px;
}
.materials-section__desc {
    font-size: 14px;
    line-height: 20px;
}




}