/**
 * Slides System Base CSS
 * Styles de base pour le système de présentation
 */

/* Import de Montserrat */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

/* ========================================
   RESET ET BASE
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-size: 16px;
    /* Hide scrollbars globally */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

body {
    font-family: 'Montserrat', 'Arial', sans-serif;
    line-height: 1.6;
}

/* ========================================
   CONTENEUR PRINCIPAL
   ======================================== */

.presentation-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    /* Hide scrollbars */
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.presentation-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* ========================================
   SLIDES
   ======================================== */

.slide {
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 80px;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    overflow-y: auto;
    overflow-x: hidden;
}

.slide.active {
    display: flex;
    opacity: 1;
    z-index: 1;
}

/* Hide scrollbars for slides */
.slide {
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.slide::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* ========================================
   NAVIGATION
   ======================================== */

.nav-arrow {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    /* Hide by default in desktop mode */
    display: none;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.nav-arrow:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

#prev {
    left: 20px;
}

#next {
    right: 20px;
}

/* ========================================
   COMPTEUR DE SLIDES
   ======================================== */

.slide-counter {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    z-index: 1000;
}

/* ========================================
   BOUTON MODE TRIEUSE
   ======================================== */

.sorter-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background-color: #333;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    transition: background-color 0.3s;
    width: 44px;
    height: 44px;
}

.sorter-toggle:hover {
    background-color: #555;
}

/* Hide text, show only icon */
.sorter-toggle span {
    display: none;
}

.sorter-toggle svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   MODE TRIEUSE
   ======================================== */

.slide-sorter-mode {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 2000;
    display: none;
    flex-direction: column;
}

.slide-sorter-mode.active {
    display: flex;
}

.slide-sorter-header {
    padding: 20px 40px;
    background: #2c3e50;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slide-sorter-header h2 {
    margin: 0;
    font-size: 1.5em;
}

.close-sorter {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.close-sorter:hover {
    background: #c0392b;
}

.slide-sorter-grid {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 30px;
    align-content: start;
}

/* ========================================
   MINIATURES DE SLIDES - SCALED THUMBNAILS
   ======================================== */

.slide-thumbnail {
    background: white;
    border-radius: 12px;
    overflow: visible;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    position: relative;
}

.slide-thumbnail:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.slide-thumbnail.current {
    box-shadow: 0 0 0 5px #3498db;
}

.slide-thumbnail-content {
    position: relative;
    background: white;
    width: 100%;
    overflow: visible;
    /* Height will be set by JavaScript based on scaled content */
}

/* Scale down slide content using transform */
.slide-thumbnail-inner {
    transform-origin: top left;
    transform: scale(0.2);
    width: 1920px;
    min-height: 1080px;
    padding: 80px 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    background: white;
}

/* All slide content inherits normal slide styling */
.slide-thumbnail-inner * {
    font-family: inherit;
}

.slide-thumbnail-number {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #3498db;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 16px;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.slide-thumbnail-title {
    padding: 12px 20px;
    background: linear-gradient(135deg, #5b2c6f, #8e44ad);
    text-align: center;
    font-weight: 600;
    color: white;
    font-size: 14px;
}

/* Custom scrollbar for thumbnail content */
.slide-thumbnail-content::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

.slide-thumbnail-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.slide-thumbnail-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 2px;
}

.slide-thumbnail-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   RESPONSIVE - MODE MOBILE
   ======================================== */

@media screen and (max-width: 768px) {
    html {
        /* Enable smooth scrolling for mobile */
        scroll-behavior: smooth;
    }

    body {
        overflow-y: auto;
        overflow-x: hidden;
        /* iOS momentum scrolling */
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbars in mobile */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    body::-webkit-scrollbar {
        display: none;
    }

    .presentation-container {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
        /* Enable snap scrolling for fluid presentation feel */
        scroll-snap-type: y mandatory;
        -webkit-overflow-scrolling: touch;
        /* Hide scrollbars in mobile */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .presentation-container::-webkit-scrollbar {
        display: none;
    }

    .slide {
        position: relative;
        display: flex;
        opacity: 1;
        padding: 60px 65px 40px 65px;
        min-height: 100vh;
        /* Snap each slide to viewport */
        scroll-snap-align: start;
        scroll-snap-stop: always;
        /* Add subtle separator between slides */
        border-bottom: 2px solid rgba(91, 44, 111, 0.1);
        /* Better touch scrolling */
        -webkit-overflow-scrolling: touch;
        /* Ensure proper stacking and isolation */
        z-index: 1;
        background-color: #ffffff;
        /* Prevent content overflow */
        overflow: visible;
        /* Contain layout to prevent overlap */
        contain: layout style;
    }

    /* Last slide doesn't need border */
    .slide:last-child {
        border-bottom: none;
    }

    /* Progress indicator bar */
    .mobile-progress-bar {
        position: fixed;
        top: 0;
        left: 0;
        height: 4px;
        background: linear-gradient(90deg, #5b2c6f, #d35400, #8e44ad);
        z-index: 3000;
        transition: width 0.3s ease-out;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
        width: 0;
    }

    /* Show and reposition navigation buttons for mobile */
    .nav-arrow {
        display: flex !important;
        width: 45px;
        height: 45px;
        font-size: 18px;
        background-color: rgba(91, 44, 111, 0.85);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        border: 2px solid rgba(255, 255, 255, 0.15);
        /* Reset the transform */
        transform: none;
    }

    .nav-arrow:active {
        transform: scale(0.9);
        background-color: rgba(91, 44, 111, 1);
    }

    .nav-arrow:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

    /* Position buttons on the sides, vertically centered in viewport */
    #prev {
        left: 10px;
        right: auto;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }

    #next {
        right: 10px;
        left: auto;
        top: 50%;
        bottom: auto;
        transform: translateY(-50%);
    }

    #prev:active:not(:disabled) {
        transform: translateY(-50%) scale(0.9);
    }

    #next:active:not(:disabled) {
        transform: translateY(-50%) scale(0.9);
    }

    /* Enhanced slide counter with better visibility */
    .slide-counter {
        bottom: 12px;
        right: 12px;
        font-size: 12px;
        padding: 6px 12px;
        background-color: rgba(91, 44, 111, 0.9);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
        border: 1.5px solid rgba(255, 255, 255, 0.15);
        font-weight: 600;
    }

    /* Overview button repositioned to bottom left - icon only */
    .sorter-toggle {
        bottom: 12px;
        left: 12px;
        padding: 10px;
        width: 42px;
        height: 42px;
        background-color: rgba(91, 44, 111, 0.9);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
        border: 1.5px solid rgba(255, 255, 255, 0.15);
        border-radius: 50%;
    }

    .sorter-toggle svg {
        width: 18px;
        height: 18px;
    }

    .sorter-toggle:active {
        transform: scale(0.9);
        background-color: rgba(91, 44, 111, 1);
    }

    .slide-sorter-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 15px;
    }

    /* Smaller scale on mobile */
    .slide-thumbnail-inner {
        transform: scale(0.15);
    }

    /* Ensure buttons stay visible and are touch-friendly */
    .nav-arrow,
    .slide-counter,
    .sorter-toggle {
        z-index: 2500;
        position: fixed;
        /* Prevent text selection on touch */
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
        /* Prevent buttons from interfering with scrolling */
        pointer-events: auto;
    }

    /* Better spacing for mobile content */
    .slide h1 {
        margin-top: 0;
        font-size: 2em;
    }

    .slide h2 {
        font-size: 1.6em;
    }

    .slide h3 {
        font-size: 1.3em;
    }

    .slide p,
    .slide li {
        font-size: 1em;
        line-height: 1.7;
    }

    .slide code {
        font-size: 0.9em;
    }

    /* Improve table responsiveness on mobile */
    .slide table {
        font-size: 0.85em;
        overflow-x: auto;
        display: block;
    }

    /* Better iframe handling on mobile */
    .slide iframe {
        max-width: 100%;
        height: auto;
        min-height: 300px;
    }
}

/* ========================================
   TITLE SLIDE STYLES
   ======================================== */

.title-slide {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 60px 80px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.title-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.title-slide .main-title {
    font-size: 4em;
    font-weight: 700;
    margin: 0;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.title-slide .subtitle {
    font-size: 1.8em;
    font-weight: 300;
    margin: 20px 0 0 0;
    color: rgba(255,255,255,0.95);
}

.title-slide .lecture-number {
    font-size: 1.4em;
    font-weight: 500;
    margin: 40px 0 10px 0;
    color: rgba(255,255,255,0.9);
}

.title-slide .lecture-description {
    font-size: 1.2em;
    font-weight: 300;
    margin: 0;
    color: rgba(255,255,255,0.85);
}

.title-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: 60px;
    padding-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.3);
}

.logos {
    display: flex;
    align-items: center;
}

.way-up-logo {
    height: 60px;
    filter: brightness(0) invert(1);
}

.attribution {
    text-align: right;
}

.cc-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cc-logo {
    height: 31px;
}

.cc-text {
    text-align: left;
}

.cc-text p {
    margin: 0;
    font-size: 0.75em;
    line-height: 1.4;
    color: rgba(255,255,255,0.9);
}

.cc-text a {
    color: white;
    text-decoration: underline;
}

.cc-text .copyright {
    margin-top: 5px;
    font-size: 0.85em;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    /* Hide navigation and UI elements */
    .nav-arrow,
    .slide-counter,
    .sorter-toggle,
    .slide-sorter-mode {
        display: none !important;
    }

    /* Reset body and container for printing */
    html, body {
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    .presentation-container {
        width: 100%;
        height: auto;
        overflow: visible;
        counter-reset: slide-number;
    }

    /* One slide per page */
    .slide {
        position: relative;
        display: flex !important;
        opacity: 1 !important;
        page-break-after: always;
        page-break-inside: avoid;
        width: 100%;
        min-height: 100vh;
        margin: 0;
        padding: 60px 80px;
        box-sizing: border-box;
    }

    /* Ensure last slide doesn't have page break */
    .slide:last-child {
        page-break-after: auto;
    }

    /* Print decorations */
    .slide::before {
        opacity: 0.4 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Show slide number in bottom right */
    .slide {
        counter-increment: slide-number;
    }

    .slide::after {
        content: counter(slide-number);
        position: fixed;
        bottom: 20px;
        right: 30px;
        font-size: 0.9em;
        font-weight: 500;
        color: #666;
        background: none !important;
        width: auto !important;
        height: auto !important;
        opacity: 1 !important;
        transform: none !important;
        z-index: 1000;
    }

    /* Ensure title slides print with background */
    .title-slide {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Ensure all content is visible */
    .slide > * {
        position: relative;
        z-index: 1;
    }

    /* Handle long content */
    .slide pre,
    .slide code,
    .slide table {
        page-break-inside: avoid;
    }

    /* Mermaid diagrams */
    .mermaid svg {
        max-width: 100% !important;
        height: auto !important;
    }
}

