/* =========================================
   МОДУЛЬ ПОРТФОЛИО
========================================= */
.portfolio-container {
    max-width: 1440px;
    margin: 40px auto 80px auto;
    padding: 0 20px;
    font-family: 'Inter', sans-serif;
}

.portfolio-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 40px auto;
}

.portfolio-header h1 {
    font-family: 'Playfair Display', serif;
    font-size: 42px;
    color: #4a3c5a;
    margin-bottom: 15px;
}

.portfolio-header p {
    font-size: 16px;
    color: #555555;
    line-height: 1.6;
}

/* Фильтры */
.portfolio-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 40px;
}

.portfolio-filter-btn {
    background: #fdfafb;
    border: 1px solid #eeeeee;
    color: #555555;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.portfolio-filter-btn:hover {
    border-color: #936098;
    color: #936098;
}

.portfolio-filter-btn.active {
    background: #936098;
    color: #ffffff;
    border-color: #936098;
    box-shadow: 0 4px 10px rgba(147, 96, 152, 0.2);
}

/* СЕТКА (Базово 4 колонки) */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-flow: dense;
    gap: 25px;
}

.portfolio-item {
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #eeeeee;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.06);
}

.open-lightbox {
    cursor: pointer;
}

.portfolio-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f5f5f5;
}

/* ВЕРТИКАЛЬНЫЙ СТЕК БЭЙДЖЕЙ В ВЕРХНЕМ ЛЕВОМ УГЛУ */
.pf-meta-badge-stack {
    position: absolute;
    top: 14px;
    left: 14px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    z-index: 4;
}

.pf-meta-badge-stack .project-year,
.project-year {
    position: static;
    background: rgba(255, 255, 255, 0.94);
    color: #4a3c5a;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 800;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    line-height: 1.2;
    border: 1px solid rgba(255, 255, 255, 0.7);
}

/* СТИЛИЗОВАННЫЙ БЛОК ПРОСМОТРОВ С ГЛАЗОМ */
.project-views {
    background: rgba(45, 34, 56, 0.82);
    color: #ffffff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    line-height: 1.2;
    transition: transform 0.25s ease, background 0.25s ease;
    user-select: none;
}

.project-views svg {
    color: #ff527b;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.portfolio-item:hover .project-views {
    background: rgba(223, 27, 83, 0.9);
    transform: scale(1.04);
}

.portfolio-item:hover .project-views svg {
    color: #ffffff;
    transform: scale(1.15);
}

.project-views .view-num {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.3px;
}

.pf-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 1s ease-in-out, transform 6s linear;
    transform: scale(1);
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.pf-slide.active {
    opacity: 1;
    transform: scale(1.05);
    z-index: 1;
}

.gallery-counter {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 2;
    backdrop-filter: blur(4px);
}

/* OVERLAY И ПЛАШКА С ОПИСАНИЕМ */
.portfolio-overlay {
    position: absolute;
    inset: 0;
    background: transparent;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3;
}

.portfolio-item:hover .portfolio-overlay {
    opacity: 1;
}

.portfolio-hover-panel {
    position: absolute;
    bottom: 12px;
    left: 12px;
    right: 12px;
    background: rgba(45, 34, 56, 0.85); 
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    transform: translateY(20px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
}

.portfolio-item:hover .portfolio-hover-panel {
    transform: translateY(0);
    opacity: 1;
}

.portfolio-hover-panel p {
    color: #ffffff;
    font-size: 12px; 
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 4; 
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: left;
}

.btn-zoom-project {
    position: absolute;
    top: 40%;
    left: 50%;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    padding: 10px 20px;
    border-radius: 30px;
    color: #936098;
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transform: translate(-50%, 20px);
    transition: transform 0.3s ease, background 0.2s, top 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.portfolio-item:hover .btn-zoom-project {
    transform: translate(-50%, -50%);
    top: 45%;
}

.portfolio-info {
    padding: 18px 16px 20px 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* ВЕРХНЯЯ СТРОКА: ИМЯ КЛИЕНТА СЛЕВА, КНОПКА «ОПЦИИ» СТРОГО СПРАВА */
.portfolio-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    width: 100%;
}

.portfolio-client {
    font-size: 11px;
    font-weight: 800;
    color: #df1b53;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0 !important;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 65%;
}

/* ФИРМЕННАЯ КНОПКА «ОПЦИИ» */
.bsp-options-btn {
    appearance: none;
    border: 1px solid rgba(147, 96, 152, 0.35);
    background: #ffffff;
    color: #5A2A75;
    padding: 4px 10px;
    border-radius: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(147, 96, 152, 0.08);
    transition: all 0.25s ease;
    z-index: 10;
    white-space: nowrap;
    flex-shrink: 0;
}

.bsp-options-btn svg {
    color: #df1b53;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.bsp-options-btn:hover {
    background: linear-gradient(135deg, #df1b53 0%, #936098 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(223, 27, 83, 0.25);
    transform: translateY(-1px);
}

.bsp-options-btn:hover svg {
    color: #ffffff;
    transform: rotate(60deg);
}

.bsp-options-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.portfolio-title {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    color: #333333;
    margin: 0 0 12px 0;
    line-height: 1.3;
}

.portfolio-specs-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-top: auto;
    gap: 12px;
}

.portfolio-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
}

.spec-tag {
    background: #f5f5f5;
    color: #666666;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.portfolio-bottom-action-row {
    margin-top: 6px;
    width: 100%;
}

.portfolio-bottom-action-row .card-cta-btn {
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* =========================================
   3D КНОПКА "ХОЧУ ТАКИЕ ЖЕ..."
========================================= */
.card-cta-btn {
    width: 100%;
    box-sizing: border-box;
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 30px;
    background: linear-gradient(135deg, #df1b53 0%, #936098 100%);
    box-shadow: 
        0 4px 12px rgba(223, 27, 83, 0.25), 
        inset 0 2px 0 rgba(255, 255, 255, 0.2), 
        inset 0 -2px 0 rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    position: relative;
    overflow: hidden;
}

.card-cta-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg);
    transition: none;
}

.card-cta-btn:hover {
    transform: translateY(-4px) scale(1.03);
    box-shadow: 
        0 8px 20px rgba(147, 96, 152, 0.4), 
        inset 0 2px 0 rgba(255, 255, 255, 0.3), 
        inset 0 -2px 0 rgba(0, 0, 0, 0.15);
    color: #ffffff;
}

.card-cta-btn:hover::after {
    animation: shine 0.7s ease-out;
}

@keyframes shine {
    100% {
        left: 200%;
    }
}

.card-cta-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 
        0 2px 5px rgba(223, 27, 83, 0.3), 
        inset 0 2px 4px rgba(0,0,0,0.15);
}

/* =========================================
   СТИЛИ ДЛЯ ВСТРАИВАЕМОГО МОДУЛЯ ПОРТФОЛИО
========================================= */
.pf-showcase-section {
    width: 100%;
    padding: clamp(35px, 5vw, 70px) 0;
    box-sizing: border-box;
}

.pf-showcase-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 clamp(15px, 2.5vw, 30px);
    width: 100%;
    box-sizing: border-box;
}

.pf-showcase-header {
    text-align: center;
    max-width: 900px;
    margin: 0 auto clamp(28px, 4vw, 48px) auto;
}

.pf-showcase-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(26px, 3.2vw, 40px);
    color: #4a3c5a;
    margin: 0 0 clamp(14px, 1.8vw, 22px) 0;
    line-height: 1.25;
    letter-spacing: -0.2px;
}

.pf-showcase-subtitle {
    font-family: 'Inter', sans-serif;
    font-size: clamp(14.5px, 1.2vw, 17px);
    color: #555555;
    line-height: 1.6;
    margin: 0 auto;
    max-width: 820px;
}

/* =========================================
   ЛАЙТБОКС С ЛУПОЙ (ZOOM) И ФОРМУЛОЙ ТЕПЛА
========================================= */
.portfolio-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.portfolio-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
}

.lightbox-content {
    position: relative;
    background: #ffffff;
    width: 95%;
    max-width: 1200px;
    border-radius: 12px;
    overflow: hidden;
    z-index: 2;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    max-height: 90vh;
}

.portfolio-lightbox.active .lightbox-content {
    transform: scale(1);
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #f5f5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    color: #333333;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: background 0.2s, color 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.lightbox-close:hover {
    background: #df1b53;
    color: #ffffff;
}

.lightbox-body {
    display: flex;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.lightbox-image-col {
    width: 65%;
    background: #fdfafb; 
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: zoom-in;
}

.lightbox-loader {
    position: absolute;
    color: #936098;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
}

#lightbox-img-visual {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    z-index: 1;
    transition: opacity 0.3s ease, transform 0.1s ease-out; 
    pointer-events: none; 
}

#lightbox-img {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    z-index: 2;
    opacity: 0.001; 
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.lb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 10;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.lb-nav-btn:hover {
    background: #df1b53;
    border-color: #df1b53;
}

.lb-prev { left: 20px; }
.lb-next { right: 20px; }

.lb-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 13px;
    z-index: 10;
}

.lightbox-text-col {
    width: 35%;
    padding: 40px 40px 0 40px;
    display: block;
    overflow-y: auto; 
    scrollbar-width: thin;
    scrollbar-color: #dcdcdc transparent;
    height: 100%;
}

.lightbox-text-col::after {
    content: '';
    display: block;
    height: 60px;
}

.lightbox-text-col::-webkit-scrollbar {
    width: 6px;
}
.lightbox-text-col::-webkit-scrollbar-thumb {
    background-color: #dcdcdc;
    border-radius: 4px;
}

.lightbox-client {
    font-size: 13px;
    font-weight: 800;
    color: #df1b53;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    display: block;
}

.lightbox-title {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: #4a3c5a;
    margin: 0 0 20px 0;
    line-height: 1.2;
}

.lightbox-desc {
    font-size: 14px;
    color: #555555;
    line-height: 1.5;
    margin: 0 0 10px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: all 0.3s ease;
}

.lightbox-desc.expanded {
    -webkit-line-clamp: unset;
}

.lb-read-more-btn {
    background: none;
    border: none;
    color: #936098;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    margin-bottom: 25px;
    text-decoration: underline;
}

.lb-read-more-btn:hover {
    color: #df1b53;
}

.lightbox-meta {
    background: #fdfafb;
    border: 1px solid #eeeeee;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.meta-item {
    font-size: 14px;
    color: #333333;
    display: flex;
    align-items: center;
}

.meta-item strong {
    color: #936098;
    margin-right: 5px;
}

.lightbox-formula-container {
    margin-bottom: 0; 
}
.lightbox-formula-container .formula-tepla-module {
    background: #ffffff;
    border: 1px solid #eeeeee;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
    overflow: hidden;
}
.lightbox-formula-container .ft-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px dashed #eeeeee;
}
.lightbox-formula-container .ft-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #936098; 
}
.lightbox-formula-container .ft-header-left span {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.lightbox-formula-container .ft-fire-icon {
    width: 16px !important;
    height: 16px !important;
    stroke: currentColor;
}
.lightbox-formula-container .ft-chevron {
    width: 16px;
    height: 16px;
    color: #936098;
    transition: transform 0.3s ease;
}
.lightbox-formula-container .formula-tepla-module.is-open .ft-chevron { 
    transform: rotate(180deg); 
}
.lightbox-formula-container .ft-accordion-content {
    max-height: 0; 
    opacity: 0; 
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
}
.lightbox-formula-container .formula-tepla-module.is-open .ft-accordion-content {
    max-height: 2000px; 
    opacity: 1; 
    padding: 15px;
}

.lightbox-formula-container .ft-tabs-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.lightbox-formula-container .ft-tab {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #fdfafb;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #f0f0f0;
    min-width: 0; 
}

.lightbox-formula-container .ft-tab-icon {
    padding-top: 2px;
    flex-shrink: 0; 
}

.lightbox-formula-container .ft-tab-icon svg {
    width: 16px !important;
    height: 16px !important;
}

.lightbox-formula-container .ft-tab-content {
    display: flex;
    flex-direction: column;
    min-width: 0; 
}

.lightbox-formula-container .ft-tab-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    font-weight: 700;
    color: #888888;
}

.lightbox-formula-container .ft-tab-value {
    font-size: 12px;
    font-weight: 600;
    color: #333333;
    line-height: 1.3;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    word-wrap: break-word; 
}

.lightbox-formula-container .ft-inner-badge {
    display: inline-block;
    background: #f4f5f7;
    border: 1px solid #e0e4e8;
    color: #555565;
    padding: 2px 4px;
    border-radius: 20px;
    font-size: 8px;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 4px;
    white-space: nowrap;
}

.lightbox-formula-container .ft-theme-blue .ft-tab-icon svg { color: #4a90e2; }
.lightbox-formula-container .ft-theme-dark .ft-tab-icon svg { color: #5a4a69; }
.lightbox-formula-container .ft-theme-green .ft-tab-icon svg { color: #42a976; }
.lightbox-formula-container .ft-theme-purple .ft-tab-icon svg { color: #9c5c9a; }
.lightbox-formula-container .ft-theme-orange .ft-tab-icon svg, 
.lightbox-formula-container .ft-theme-red .ft-tab-icon svg { color: #e37222; }

/* ========================================================
   ПРАВИЛА АДАПТИВНОСТИ: ЕСЛИ НЕ ПОМЕЩАЕТСЯ 4, ПОКАЗЫВАЕМ 3
   И СКРЫВАЕМ 4-УЮ, ЧТОБЫ ОНА НЕ ПЕРЕХОДИЛА НА НОВУЮ СТРОКУ
   ======================================================== */
@media screen and (min-width: 1201px) {
    .pf-showcase-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* При сужении от 993px до 1200px (когда 4 карточки начинают сжиматься) */
@media screen and (max-width: 1200px) and (min-width: 993px) {
    .pf-showcase-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 20px;
    }
    /* Если в модуль было передано 4 работы, скрываем 4-ю */
    .pf-showcase-grid > .portfolio-item:nth-child(n+4) {
        display: none !important;
    }
}

/* Планшеты: ровно 2 колонки */
@media screen and (max-width: 992px) and (min-width: 601px) {
    .portfolio-grid,
    .pf-showcase-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 18px;
    }
}

/* Мобильные экраны: 1 колонка */
@media screen and (max-width: 600px) {
    .portfolio-grid,
    .pf-showcase-grid {
        grid-template-columns: 1fr !important;
        gap: 20px;
    }
    .lightbox-formula-container .ft-tabs-container {
        grid-template-columns: 1fr;
    }
    .lightbox-body {
        flex-direction: column;
    }
    .lightbox-image-col, .lightbox-text-col {
        width: 100%;
    }
    .lightbox-image-col {
        height: 50vh;
        min-height: 320px;
    }
    .lightbox-text-col {
        padding: 25px 18px;
        height: auto;
    }
}