/* =================================
   PORTFOLIO STYLES - ПОВНИЙ ПЕРЕПИС
   ================================= */

/* CSS Custom Properties для viewport height */
:root {
    --vh: 1vh;
}

/* Показати контент тільки коли готовий */
.portfolio-hero {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.portfolio-ready .portfolio-hero {
    opacity: 1;
}

/* Оптимізації для мобільних */
@media (max-width: 767px) {
    .portfolio-projects {
        -webkit-overflow-scrolling: touch;
    }

    .project-section {
        will-change: auto;
    }

    body.menu-open .project-section {
        pointer-events: none;
    }
}

/* =================================
   HERO SECTION З ПАРАЛАКС ВІДЕО
   ================================= */

.portfolio-hero {
    position: relative;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 0;
}

/* Фіксоване відео на фоні */
.hero-bg-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.hero-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
}

.desktop-hero-video {
    display: block;
}

.mobile-hero-video {
    display: none;
}

/* Фіксований overlay */
.video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: -1;
}

.hero-content {
    max-width: 1000px;
    padding: 0 30px;
    z-index: 3;
    position: relative;
}

.hero-title {
    font-size: 100px;
    font-weight: 700;
    line-height: 0.85;
    letter-spacing: -2px;
    color: #FFFFFF;
    margin: 0 0 25px 0;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-title .highlight {
    color: #FFFFFF;
    display: block;
    margin-top: 10px;
    text-shadow: 2px 2px 6px rgba(0, 0, 0, 0.5);
}

.hero-title .highlight.orange {
    color: #e14811;
    text-shadow: 2px 2px 6px rgba(225, 72, 17, 0.5);
}

.hero-description {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.4;
    color: #FFFFFF;
    margin: 0;
    opacity: 0.9;
    max-width: 550px;
    margin: 0 auto;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* =================================
   PROJECT SECTIONS - ВІДЕО ДОМІНАНТА
   ================================= */

.portfolio-projects {
    position: relative;
    background: #0a0a0a;
    z-index: 10;
    border-radius: 20px 20px 0 0;
    margin-top: -20px;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
    padding-top: 40px;
}

.project-section {
    position: relative;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    background: #0a0a0a;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 2px solid #1a1a1a;
    overflow: hidden;
}

/* DESKTOP: sticky тільки на великих екранах */
@media (min-width: 1025px) {
    .project-section {
        position: sticky;
        top: 0;
        background: #0a0a0a;
    }

    .project-section.active {
        background: #121212;
        border-bottom-color: #e14811;
    }
}

/* ПЛАНШЕТИ: базова функціональність без sticky */
@media (min-width: 768px) and (max-width: 1024px) {
    .project-section {
        position: relative;
        background: #0a0a0a;
    }

    .project-section.active {
        background: #121212;
        border-bottom-color: #e14811;
    }
}

/* МОБІЛЬНІ: всі картки темні без змін фону */
@media (max-width: 767px) {
    .project-section {
        background: #0a0a0a;
        border-bottom: 1px solid #1a1a1a;
    }

    .project-section.active {
        background: #0a0a0a;
        border-bottom-color: #e14811;
    }
}

.project-section:last-child {
    border-bottom: none;
}

/* КОМПАКТНА СТРУКТУРА - FLEX КОНТЕЙНЕР */
.project-content {
    max-width: 1400px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    padding: 60px 40px;
    gap: 40px;
}

.project-video {
    flex: 1.5;
    height: 70vh;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.project-video video {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(225, 72, 17, 0.25);
}

/* DESKTOP: спрощені анімації та hover ефекти тільки на великих екранах */
@media (min-width: 1025px) {
    .project-video video {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .project-video video:hover {
        transform: scale(1.02);
        box-shadow: 0 6px 24px rgba(225, 72, 17, 0.35);
    }
}

.desktop-video {
    display: block;
}

.mobile-video {
    display: none;
}

.project-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 25px;
    padding: 0;
    text-align: left;
}

.project-title {
    font-size: 70px;
    font-weight: 700;
    line-height: 0.8;
    letter-spacing: -2px;
    color: #e14811;
    margin: 0;
    text-transform: uppercase;
}

.project-button {
    background: #e14811;
    border: 2px solid #e14811;
    color: #000000;
    padding: 20px 40px;
    font-size: 18px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 0;
    min-width: 220px;
}

/* Клас для анімації кліку */
.project-button.button-clicked {
    transform: scale(0.95);
}

/* DESKTOP: hover ефекти та анімації тільки на великих екранах */
@media (min-width: 1025px) {
    .project-button {
        transition: background-color 0.3s ease, transform 0.3s ease, color 0.3s ease;
    }

    .project-button:hover {
        background: transparent;
        color: #e14811;
        transform: translateY(-3px);
    }

    .project-button:active {
        transform: translateY(0);
    }
}

/* МОБІЛЬНІ: простий active стан для тач */
@media (max-width: 1024px) {
    .project-button {
        transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    }

    .project-button:active {
        background: transparent;
        color: #e14811;
    }
}

/* =================================
   RESPONSIVE DESIGN
   ================================= */

/* Планшети (768px - 1024px) */
@media (max-width: 1024px) {
    .hero-title {
        font-size: 75px;
        letter-spacing: -1px;
        margin-bottom: 20px;
    }

    .hero-description {
        font-size: 16px;
    }

    .project-content {
        max-width: 1200px;
        padding: 40px 30px;
        gap: 30px;
    }

    .project-video {
        height: 60vh;
    }

    .project-video video {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    .project-title {
        font-size: 55px;
        letter-spacing: -1px;
    }

    .project-info {
        gap: 20px;
    }

    .project-button {
        padding: 20px 40px;
        font-size: 18px;
        min-width: 200px;
    }
}

/* Мобільна адаптація паралакс ефекту */
@media (max-width: 767px) {
    .portfolio-projects {
        border-radius: 16px 16px 0 0;
        margin-top: -16px;
        padding-top: 30px;
    }
}

/* Мобільні пристрої (320px - 767px) - ОПТИМІЗОВАНИЙ СКРОЛ */
@media (max-width: 767px) {
    .desktop-hero-video {
        display: none;
    }

    .mobile-hero-video {
        display: block;
    }

    .hero-title {
        font-size: 48px;
        letter-spacing: -1px;
        margin-bottom: 30px;
    }

    .hero-title .highlight {
        margin-top: 10px;
    }

    .hero-description {
        font-size: 22px;
    }

    .project-section {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        min-height: 100vh;
        scroll-snap-align: start;
        scroll-snap-stop: normal;
    }

    .portfolio-projects {
        scroll-snap-type: y proximity;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .project-content {
        width: 100%;
        flex-direction: column;
        padding: 30px 20px;
        gap: 20px;
        max-width: none;
    }

    .project-video {
        width: 100%;
        height: 60vh;
        flex: none;
        order: -1;
    }

    .project-video video {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 16px;
        box-shadow: 0 6px 24px rgba(225, 72, 17, 0.3);
    }

    .desktop-video {
        display: none;
    }

    .mobile-video {
        display: block;
    }

    .project-info {
        align-items: center;
        text-align: center;
        gap: 20px;
        flex: none;
        justify-content: center;
    }

    .project-title {
        font-size: 45px;
        letter-spacing: -1px;
    }

    .project-button {
        padding: 20px 40px;
        font-size: 18px;
        min-width: 200px;
        align-self: center;
    }
}

/* Дуже маленькі екрани (320px - 480px) */
@media (max-width: 480px) {
    .hero-title {
        font-size: 36px;
    }

    .project-section {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        min-height: 100vh;
    }

    .project-content {
        padding: 25px 15px;
        gap: 15px;
    }

    .project-video {
        height: 55vh;
    }

    .project-video video {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        border-radius: 12px;
    }

    .project-title {
        font-size: 38px;
    }

    .project-info {
        gap: 18px;
    }

    .project-button {
        padding: 18px 36px;
        font-size: 16px;
        min-width: 180px;
    }
}

/* =================================
   iOS SAFARI OPTIMIZATIONS
   ================================= */

@supports (-webkit-touch-callout: none) {
    .portfolio-hero {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        min-height: 100vh;
    }

    .project-section {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
        min-height: 100vh;
        will-change: transform;
    }

    @media (max-width: 767px) {
        .project-section {
            height: 100vh;
            height: calc(var(--vh, 1vh) * 100);
            min-height: 100vh;
        }
    }

    @media (max-width: 480px) {
        .project-section {
            height: 100vh;
            height: calc(var(--vh, 1vh) * 100);
            min-height: 100vh;
        }
    }
}

/* Safe areas для iPhone з вирізами */
@supports (padding: max(0px)) {

    .portfolio-hero,
    .project-section {
        padding-left: max(20px, env(safe-area-inset-left) + 20px);
        padding-right: max(20px, env(safe-area-inset-right) + 20px);
    }
}

/* Підтримка для iPhone landscape */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .hero-title {
        font-size: 32px;
        margin-bottom: 20px;
    }

    .project-title {
        font-size: 28px;
        margin-bottom: 20px;
    }

    .hero-description {
        font-size: 14px;
        margin-bottom: 30px;
    }

    .project-button {
        padding: 12px 24px;
        font-size: 14px;
    }
}

/* =================================
   SCROLL BEHAVIOR
   ================================= */

html {
    scroll-behavior: smooth;
}

@media (max-width: 767px) {
    html {
        scroll-behavior: smooth;
        overflow-x: hidden;
    }

    body {
        overflow-x: hidden;
    }
}

/* =================================
   PERFORMANCE OPTIMIZATIONS
   ================================= */

@media (min-width: 1025px) {
    .project-section {
        contain: layout style;
    }
}

@media (max-width: 767px) {
    .project-section {
        contain: layout;
    }

    .project-video {
        will-change: auto;
    }
}

/* Стани завантаження відео */
.project-section.video-loading .project-video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #e14811;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: video-loading-spin 1s linear infinite;
    z-index: 10;
}

.project-section.video-error .project-video::after {
    content: "⚠";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #e14811;
    z-index: 10;
}

@keyframes video-loading-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Приховуємо індикатори на малих екранах */
@media (max-width: 767px) {

    .project-section.video-loading .project-video::after,
    .project-section.video-error .project-video::after {
        display: none;
    }
}

/* =================================
   PAGE TRANSITIONS
   ================================= */

body.page-transition {
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

/* =================================
   MOBILE & DESKTOP SPECIFIC CLASSES
   ================================= */

body.portfolio-mobile .project-section {
    position: relative;
}

body.portfolio-desktop .project-section {
    position: sticky;
    top: 0;
}