:root {
    --color-blue: #00BFFF;
    --color-gold: #FFD700;
    --bg-gradient: linear-gradient(135deg, #FF7F50 0%, #FFA500 100%);
    --card-bg: rgba(15, 15, 15, 0.98);
    --physics-brown: #c68642;
}

/* Γενικά */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 40px 20px;
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    color: white;
    user-select: none;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

.header-section {
    text-align: center;
    margin-bottom: 50px;
}

h1 {
    font-size: 3.5em;
    font-weight: 800;
    color: var(--color-gold);
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    margin: 0;
}

/* Grid Σύστημα - 4 ΑΝΑ ΣΕΙΡΑ */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.card-anchor {
    position: relative;
    height: 480px;
    cursor: pointer;
}

/* Η Κάρτα */
.course-card {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--physics-brown);
    border-radius: 30px;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    flex-direction: column;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.card-anchor:hover .course-card:not(.expanded) {
    transform: scale(1.03);
}

/* Overlay */
#modalOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: 0.4s;
    z-index: 9000;
}

body.modal-open #modalOverlay {
    opacity: 1;
    visibility: visible;
}

/* Expanded State - Desktop */
.course-card.expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    width: 90vw;
    height: 85vh;
    max-width: 1250px;
    z-index: 9999;
    flex-direction: row;
    background: var(--card-bg);
    border: 2px solid var(--color-gold);
    cursor: default;
    overflow: hidden;
    border-radius: 40px;
}

.media-container {
    position: relative;
    width: 100%;
    height: 250px;
    background: #000;
    flex-shrink: 0;
}

.course-card.expanded .media-container {
    width: 65%;
    height: 100%;
}

.thumbnail {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    transition: 0.4s;
}

.card-anchor:hover .thumbnail {
    opacity: 0;
}

.course-card.expanded .thumbnail {
    display: none;
}


/* =========================
   CONTROLS BASE (PC + GLOBAL)
========================= */
.video-controls {
    display: none !important;

    position: absolute;
    bottom: 15px;
    left: 0;
    width: 100%;

    padding: 0 15px;
    box-sizing: border-box;

    align-items: center;
    gap: 10px;

    z-index: 5;
}

/* 🔥 only όταν expanded */
.course-card.expanded .video-controls {
    display: flex !important;
}


/* =========================
   TIME
========================= */
.time {
    font-size: 13px;
    font-weight: 600;
    color: white;

    white-space: nowrap;
    flex-shrink: 0;

    text-shadow: 0 0 6px rgba(0,0,0,0.9);
}


/* =========================
   SEEK BAR
========================= */
.seek-bar {
    flex: 1;
    min-width: 0;

    height: 6px;
    appearance: none;
    border-radius: 10px;
    cursor: pointer;

    background: linear-gradient(
        to right,
        var(--color-gold) 0%,
        #FFA500 var(--progress, 0%),
        rgba(255,255,255,0.15) var(--progress, 0%)
    );

    box-shadow: inset 0 0 6px rgba(0,0,0,0.4);
    transition: height 0.2s ease;
}

.seek-bar:hover {
    height: 8px;
}

.seek-bar::-webkit-slider-thumb {
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;

    background: linear-gradient(135deg, var(--color-gold), #FFA500);
    box-shadow: 0 0 10px rgba(255,165,0,0.8);
    cursor: pointer;
}


/* =========================
   FULLSCREEN BUTTON
========================= */
.fullscreen-btn {
    flex-shrink: 0;

    width: 38px;
    height: 38px;

    border-radius: 10px;
    border: none;

    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;
    color: white;
    cursor: pointer;

    background: linear-gradient(135deg, var(--color-gold), #FFA500);
    box-shadow: 0 0 10px rgba(255,165,0,0.6);

    transition: transform 0.2s, box-shadow 0.2s;
}

.fullscreen-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255,165,0,0.9);
}


/* =========================
   PC FULLSCREEN
========================= */
.course-card:fullscreen {
    display: flex;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
}

/* 🎥 video */
.course-card:fullscreen .media-container {
    width: 65%;
    height: 100%;
}

/* 🧠 text stays */
.course-card:fullscreen .course-info {
    width: 35%;
    display: block;
}

/* ❌ hide X button στο fullscreen */
.course-card:fullscreen .close-btn {
    display: none !important;
}

/* controls πάνω από video */
.course-card:fullscreen .video-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    z-index: 9999;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-card.expanded video {
    object-fit: contain;
}

/* Περιοχή Κειμένου */
.course-info {
    padding: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: var(--physics-brown);
    flex-grow: 1;
}

.course-card.expanded .course-info {
    width: 35%;
    background: transparent;
    padding: 60px 30px;
    overflow-y: auto;
    display: block;
}

/* Τίτλοι */
h3 {
    margin: 0;
    font-size: 1.4em;
    font-weight: 800;
    color: #ffffff;
    text-transform: uppercase;
}

h3 span {
    display: block;
    font-size: 0.75em;
    color: #ffffff;
    opacity: 0.8;
    margin-top: 8px;
}

.course-card.expanded h3 {
    font-size: 2em;
    color: var(--color-gold);
    margin-bottom: 25px;
}

.course-summary {
    display: none;
    font-size: 1.05em;
    line-height: 1.7;
    color: #dddddd;
    margin: 25px 0;
}

.course-card.expanded .course-summary {
    display: block;
}

/* UI Στοιχεία */
.badge {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--color-blue);
    color: #000;
    padding: 6px 14px;
    border-radius: 12px;
    font-weight: 900;
    z-index: 10;
}

.close-btn {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10005;
    /* Πολύ ψηλά για να πατιέται πάντα */
    cursor: pointer;
    font-size: 26px;
    border: 1px solid white;
}

.course-card.expanded .close-btn {
    display: flex;
}

.lessons-count {
    margin-top: 15px;
    color: var(--color-gold);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.05em;
    padding-bottom: 20px;
}

/* =========================================
   📱 MOBILE FINAL (STABLE + TRUE FULLSCREEN)
========================================= */
@media (max-width: 600px) {

    /* =========================
       GRID
    ========================= */
    .gallery-grid {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 20px;
    }

    .card-anchor {
        height: 450px;
    }

    /* =========================
       📦 EXPANDED (NORMAL VIEW)
    ========================= */
    .course-card.expanded {
        position: fixed !important;
        top: 0;
        left: 0;

        width: 100vw !important;
        height: 100dvh !important;

        display: flex !important;
        flex-direction: column !important;

        background: var(--card-bg);

        /* 🔥 REMOVE BORDER BUG */
        border-radius: 0 !important;
        border: none !important;

        margin: 0 !important;
        transform: none !important;

        overflow: hidden;
        z-index: 9999;

        box-sizing: border-box !important;
    }

    /* fallback */
    @supports not (height: 100dvh) {
        .course-card.expanded {
            height: 100vh !important;
        }
    }

    /* 🎥 VIDEO */
    .course-card.expanded .media-container {
        width: 100% !important;
        height: 45vh !important;
        flex-shrink: 0;
    }

    /* =========================
       🧠 TEXT (PERFECT CENTER)
    ========================= */
    .course-card.expanded .course-info {
        flex: 1;

        width: 100%;
        min-height: 0;

        display: flex;
        flex-direction: column;

        justify-content: center;
        align-items: center;

        text-align: center;

        padding: 20px 16px;
        box-sizing: border-box;

        overflow-y: auto;
    }

    /* 🔥 TITLE */
    .course-card.expanded h3 {
        width: 100%;

        font-size: 1.6em;
        line-height: 1.35;

        margin-bottom: 15px;

        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* 🔥 STEP (GRAY) */
    .course-card.expanded h3 span {
        display: block;
        color: rgba(255,255,255,0.6);
        font-size: 0.75em;
        margin-bottom: 8px;
    }

    /* ❌ DESCRIPTION outside */
    .course-summary {
        display: none;
    }

    /* ✅ DESCRIPTION inside expanded */
    .course-card.expanded .course-summary {
        display: block;

        width: 100%;

        font-size: 1em;
        line-height: 1.6;

        word-break: break-word;
        overflow-wrap: anywhere;
    }

    /* ❌ REMOVE lessons */
    .lessons-count {
        display: none !important;
    }

    /* =========================
       ❌ CLOSE BUTTON
    ========================= */
    .course-card:not(.expanded) .close-btn {
        display: none !important;
    }

    .course-card.expanded .close-btn {
        display: flex;

        position: absolute;
        top: 15px;
        right: 15px;

        z-index: 10000;
    }

    /* =========================
       🎮 CONTROLS
    ========================= */
    .video-controls {
        display: none;
    }

    .course-card.expanded .video-controls {
        display: flex;

        position: absolute;
        bottom: 10px;
        left: 0;

        width: 100%;
        padding: 0 10px;

        gap: 8px;
        align-items: center;

        z-index: 10;
    }

    /* =========================================
       📱 FULLSCREEN (REAL FIX)
    ========================================= */

    body.mobile-fullscreen {
        background: black !important;
        overflow: hidden !important;
    }

    body.mobile-fullscreen .course-card.expanded {
        position: fixed !important;
        top: 0;
        left: 0;

        width: 100vw !important;
        height: 100dvh !important;

        display: block !important;
        background: black !important;

        z-index: 999999;

        /* 🔥 REMOVE ANY SCALE BUG */
        transform: none !important;
    }

    /* ❌ REMOVE ALL UI */
    body.mobile-fullscreen .course-card.expanded > * {
        display: none !important;
    }

    /* 🎥 ONLY VIDEO */
    body.mobile-fullscreen .media-container {
        display: block !important;

        position: fixed;
        top: 0;
        left: 0;

        width: 100vw;
        height: 100dvh;
    }

    body.mobile-fullscreen video {
        width: 100vw;
        height: 100dvh;

        object-fit: contain;
        background: black;
    }

    /* 🎮 CONTROLS */
    body.mobile-fullscreen .video-controls {
        display: flex !important;

        position: fixed;
        bottom: 15px;
        left: 0;

        width: 100%;
        padding: 0 12px;

        z-index: 999999;
    }

    /* 🔥 GLOBAL SAFETY */
    .course-card.expanded * {
        max-width: 100%;
    }
}