/* On force le body et les sections à être transparents */
body,
main,
section {
    background-color: transparent !important;
}

/* Reset simple */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

h1{
    font-size: 48px;
}

h2{
    font-size: 32px;
}

body {
    font-family: 'Red Hat Text', sans-serif;
    font-size: 17px;
    color: #eee;
    line-height: 1.6;
    background-color: #0d0d14;
    /* Couleur de fallback pendant le chargement du canvas */
}

#wisp-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99; /* bring the wisp canvas back to the foreground */
    pointer-events: none;
}

/* Le Canvas en arrière-plan */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -2; /* behind the wisp canvas and all content */

    background: linear-gradient(45deg,
            #0f2027,
            #203a43,
            #2c6064);
}

/* Mise en page simple */
header {
    padding: 2rem;
}

/* Navigation: horizontal layout by default */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 20px;
}

nav a {
    text-decoration: none;
    color: white;
    font-weight: bold;
}

.introduction {
    /* height: 80vh; */
    min-height: 80vh; /* allow the section to grow if content is taller */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: white;
}

.avatar {
    width: 25em;
    height: 25em;
    margin-bottom: 20px;
}

.demo-image {
    width: 100%;
    height: auto;
    display: block;
    margin-bottom: 1em;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

/* Grid containers: both share a common base */
.grid,
.dual-grid {
    display: grid;
    gap: 20px;
    padding: 40px;
    grid-template-columns: 1fr; /* mobile: single column */
}

/* Dual-grid aligns items to stretch on desktop */
.dual-grid {
    align-items: stretch;
}

/* Sections: normal flow with stacking context and responsive padding */
section {
    position: relative;
    z-index: 1; /* above background canvases */
    display: block;
    clear: both;
    padding-top: clamp(24px, 6vh, 64px);
    padding-bottom: clamp(24px, 6vh, 64px);
}

/* Minigame container: centered layout */
.dual-grid .minigame {
    width: 100%;
    height: auto;
    min-height: 380px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 0.5rem;
    overflow: hidden; /* prevent child canvas from overflowing */
}

/* Canvas: responsive sizing with aspect ratio */
.minigame canvas {
    width: 75%;
    height: auto;
    max-width: 900px;
    max-height: 70vh;
    aspect-ratio: 16 / 9;
    display: block;
    position: relative;
    z-index: auto;
}

/* Desktop grids (default) */
.grid {
    grid-template-columns: repeat(4, 1fr);
}

.dual-grid {
    grid-template-columns: repeat(2, 1fr);
}

/* About section: portrait image smaller and offset (desktop) */
.dual-grid > div .about-portrait {
    max-width: 50%;
    margin-left: 25%;
    height: auto;
    display: block;
}

.dual-grid > article { margin-left: 2em; }

/* Minigame larger on desktop */
.dual-grid .minigame { min-height: 480px; }

/* Mobile tweaks: navigation and sizing adjustments for small screens */
@media (max-width: 60em) {
    /* Reset grids to single column on mobile */
    .grid { grid-template-columns: 1fr; }
    .dual-grid { grid-template-columns: 1fr; }

    /* Intro: don't use the 80vh fixation on small phones */
    .introduction {
        height: auto;
        padding: 2.5rem 1rem;
        text-align: center;
        align-items: center;
    }

    /* Agrandir le logo uniquement sur mobile : plus visible mais restant adaptatif */
    .avatar {
        width: clamp(120px, 75vw, 220px);
        height: auto;
    }

    /* Nav: stack below logo for narrow widths */
    /* On narrow viewports, keep the nav compact and horizontal to avoid a very tall header.
       The language buttons remain visible on the right. If space is tight the nav will scroll horizontally. */
    header { padding: 0.75rem 1rem; }

    nav {
        display: flex;
        align-items: center; /* vertically center nav content */
        justify-content: space-between;
        gap: 12px;
    }

    nav ul {
        display: flex;
        flex-direction: row; /* keep items on one line to avoid a tall, centered block */
        gap: 12px;
        align-items: center;
        width: auto;
        overflow-x: auto; /* allow small horizontal scrolling if there are too many items */
        -webkit-overflow-scrolling: touch;
        padding: 4px 0;
    }

    nav ul::-webkit-scrollbar { height: 6px; }
    nav ul::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 6px; }

    /* Keep nav links compact on mobile */
    nav a { font-size: 0.95rem; padding: 6px 8px; }

     /* Language switch: compact on mobile */
     .lang-switch {
         margin-left: 0.5rem;
         display: flex;
         gap: 6px;
         align-items: center;
     }
     
     .lang-toggle {
         background: transparent;
         border: 0;
         padding: 2px;
         border-radius: 6px;
     }
     
     .lang-toggle[aria-pressed="true"] {
         outline: 2px solid rgba(255,255,255,0.08);
     }
     
     /* Mobile icons: 20px */
     .lang-toggle img.lang-icon {
         width: 20px;
         height: auto;
         display: block;
     }

    /* Make touch targets larger */
    .thumb { padding: 0.5rem; }
    .demo-image { border-radius: 8px; }

    /* Minigame: fit the canvas to viewport width on phones */
    .minigame canvas {
        width: 90%;
        max-width: 100%;
        height: auto;
        max-height: 60vh;
        aspect-ratio: 16/9;
    }

    /* Icons & buttons scale down on mobile */
    .type-icon { width: 64px; height: auto; }
    .skill-icon, .contact-icon { width: 48px; height: 48px; }
    .custom-button { margin-left: 0; padding: 10px; }

     /* On small screens: minigame container shrinks */
     .dual-grid .minigame {
         min-height: 0;
         padding-top: 1rem;
         padding-bottom: 1rem;
     }

     /* Reset desktop styling on mobile */
     .dual-grid > article { margin-left: 0; }
     .dual-grid > div .about-portrait {
         max-width: 100%;
         margin-left: 0;
     }
}

/* Portrait orientation: better fit for tall devices (override canvas) */
@media (orientation: portrait) and (max-width: 90em) {
    .minigame canvas {
        aspect-ratio: 9/16;
        width: 90%;
        max-height: 80vh;
    }
}

/* Mobile portrait: categories full-width and language buttons below */
@media (max-width: 40em) and (orientation: portrait) {
    /* Reset grids to single column on mobile portrait */
    .grid { grid-template-columns: 1fr; }
    .dual-grid { grid-template-columns: 1fr; }

    /* tighten header vertical padding for portrait phones */
    header { padding: 0.5rem 0.8rem; }

    /* Stack nav vertically so categories occupy full width */
    nav {
        flex-direction: column;
        align-items: stretch; /* allow children to stretch to full width */
        gap: 8px;
    }

    /* Make the category list a full-width column */
    nav ul {
        flex-direction: column;
        width: 100%;
        gap: 6px;
        padding: 0;
    }

    nav ul li { width: 100%; }

    /* Make links block-level so they fill the width and are easy to tap */
    nav ul li a {
        display: block;
        width: 100%;
        padding: 10px 12px;
        text-align: center;
        border-radius: 8px;
        background: rgba(255,255,255,0.02);
        color: #fff;
    }

     /* Place language buttons at the top-right on portrait phones */
     nav { position: relative; }
     
     .lang-switch {
         position: absolute;
         top: 8px;
         right: 12px;
         display: flex;
         gap: 8px;
         align-items: center;
         width: auto;
         z-index: 80;
     }
     
     /* Portrait: slightly larger tap targets for flags */
     .lang-toggle {
         padding: 6px;
     }
     
     .lang-toggle img.lang-icon {
         width: 22px;
         height: auto;
         display: block;
     }

     /* ABOUT: ensure the portrait image uses the same width as the text on mobile portrait */
     .dual-grid > div img { width: 100%; max-width: 100%; height: auto; margin: 0; display: block; }

     /* Reset desktop styling for about section */
     .dual-grid > article { margin-left: 0; }
     .dual-grid > div .about-portrait {
         max-width: 100%;
         margin-left: 0;
     }

     /* Reset minigame height on portrait */
     .dual-grid .minigame { min-height: 0; }
}

/* Large / ultrawide screens: optional subtle spacing increase, but keep layout */
@media (min-width: 75em) {
    .grid { gap: 28px; }
}

/* Accessibility: respect reduced motion for canvas animations (if any) */
@media (prefers-reduced-motion: reduce) {
    #wisp-canvas, #bg-canvas { will-change: auto; }
}

/* Small tweak: ensure footer text wraps nicely on narrow devices */
@media (max-width: 40em) {
    footer p { text-align: center; font-size: 0.95rem; padding: 1rem; }
}

/* Style bonus pour la lisibilité */
.grid article {
    padding: 20px;
    border-radius: 8px;
}

#realisations {
    background: #2c6064 !important;
    color: #ffffff;
    padding: 3em 1em;
    align-items: center;
}

.gallery { display:flex; gap:12px; flex-wrap:wrap; }

.thumb {
    position: relative;
    display: inline-block;   /* important */
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    overflow: hidden;        /* évite débordement */
}

.thumb--video::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10%;
    aspect-ratio: 1 / 1;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
}

.thumb--video::after {
    content: "";
    position: absolute;
    width: 10%;
    aspect-ratio: 1 / 1;

    background: rgba(255,255,255,0.3);

    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);

    clip-path: polygon(20% 20%, 80% 50%, 20% 80%);
}

/* Optionnel : effet hover */
.thumb--video:hover::before {
    background: rgba(0,0,0,0.3);
}

.thumb--video:hover::after {
    background: rgba(255,255,255,0.7);
}

/* Modal */
.modal{
    position: fixed;
    inset: 0;
    z-index: 9999;

    display: flex;
    align-items: center;
    justify-content: center;
    
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity 360ms ease, visibility 0s linear 360ms;
}

.modal.is-open{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transition: opacity 360ms ease, visibility 0s;
}

/* backdrop suit l'opacité globale, optionnel */
.modal__backdrop{
    position:absolute;
    inset:0;
    background: rgba(0,0,0,.65);
}

.modal.is-open .modal__content{
    opacity: 1;
}

.modal__content{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: 90%;
    max-width: 90%;
}

.modal__content.is-youtube{
    width: min(90vw, 1200px);
}

/* Respect des préférences d’accessibilité */
@media (prefers-reduced-motion: reduce){
    .modal__backdrop, .modal__content { transition:none; }
}

/* Skills grid (icône + label) */
#skills {
    background: #0f2027 !important;
    color: #ffffff;
    padding: 3em 1em;
    align-items: center;
}

.skills-grid{
    list-style: none;
    display: grid;
    gap: 12px;
    padding: 0;
    margin: 1em 0 0 0;
    grid-template-columns: 1fr; /* mobile : une colonne */
}

.skill-item{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.02);
}

.skill-icon{
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border-radius: 50%;
    padding: 8px;
    background: rgba(0,0,0,0.15);
    display: inline-block;
    object-fit: contain;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.skill-label{
    font-weight: 600;
    color: #f1f5f9;
}

.custom-button{
    margin-left: 5%;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 1rem;
    text-decoration:none;
    color: #f1f5f9;
    border: rgba(255,255,255,0.8) 1px solid;
}

.type-icon{
    width: 8em;
    height: 8em;
}

#contact {
    background: #135063 !important;
    color: #ffffff;
    padding: 3em 1em;
    align-items: center;
}

.contact-icon{
    width: 5em;
    height: 5em;
}

/* Make header and main explicit stacking contexts to avoid overlay issues */
header {
    position: relative;
    z-index: 5;
}

main {
    position: relative;
    z-index: 2;
}

/* Ensure grid containers don't collapse margins with headings */
.grid,
.dual-grid {
    margin-top: 0;
}

/* Language toggle (flags) - base styles */
.lang-switch {
    display: flex;
    gap: 1em;
    align-items: center;
}

.lang-toggle {
    border: 0;
    background: transparent;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-appearance: none;
    outline: none;
}

.lang-toggle img { border: 0; }

/* Desktop: 4em icons with hover effects */
@media (min-width: 40em) {
    .lang-toggle img.lang-icon {
        display: block;
        width: 4em;
        height: auto;
        border-radius: 0.2em;
        transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
        box-shadow: none;
        border: 0;
    }
    
    /* Hover and active states */
    .lang-toggle:hover img.lang-icon,
    .lang-toggle.active img.lang-icon {
        transform: translateY(-0.1em) scale(1.06);
        box-shadow: 0 0.2em 1em rgba(0,0,0,0.45);
        opacity: 1;
    }
}

/* Keyboard focus state */
.lang-toggle:focus-visible {
    outline: none;
}
.lang-toggle:focus-visible img.lang-icon {
    box-shadow: 0 0 0 3px rgba(255,255,255,0.12);
}

/* Footer: stacking context and separation from main content */
footer {
    position: relative;
    z-index: 120; /* above #wisp-canvas */
    margin-top: 2rem;
}

footer p { display: inline-block; color: #ddd; }

/* Make the legal link clearly visible */
.legal-link {
    color: #7bdcff;
    text-decoration: underline;
    margin-left: 0.4em;
    display: inline-block;
}

/* ===== Cookie banner styles ===== */
.cookie-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(13,13,20,0.95);
    color: #eee;
    font-size: 0.95rem;
    z-index: 9000; /* below modal (modal uses 9999) but above page content */
    box-shadow: 0 -6px 18px rgba(0,0,0,0.45);
}
.cookie-banner .cookie-banner__text {
    line-height: 1.4;
}
.cookie-banner .cookie-banner__text a {
    color: #9fd6ff;
    text-decoration: underline;
}
.cookie-banner .cookie-banner__actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.cookie-banner button {
    background: #2c6064;
    color: #fff;
    border: 0;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}
.cookie-banner button:focus {
    outline: 3px solid rgba(173,216,230,0.25);
}
.cookie-banner.hidden {
    display: none !important;
}

/* Responsive: stack content on small screens */
@media (max-width: 480px) {
    .cookie-banner {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }
    .cookie-banner .cookie-banner__actions {
        justify-content: flex-end;
    }
}

/* Hamburger menu styles */
.hamburger {
    display: none; /* shown only on small screens */
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    padding: 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.hamburger .bar {
    display: block;
    width: 100%;
    height: 2px;
    background: white;
    position: relative;
}
.hamburger .bar::before,
.hamburger .bar::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: white;
    transition: transform 180ms ease, opacity 120ms ease;
}
.hamburger .bar::before { top: -8px; }
.hamburger .bar::after { top: 8px; }

/* when open, rotate the bars into an X */
.hamburger[aria-expanded="true"] .bar {
    background: transparent;
}
.hamburger[aria-expanded="true"] .bar::before {
    transform: translateY(8px) rotate(45deg);
}
.hamburger[aria-expanded="true"] .bar::after {
    transform: translateY(-8px) rotate(-45deg);
}

/* Desktop: show nav inline */
@media (min-width: 40em) {
    .hamburger { display: none; }
    #primary-nav { display: flex; }
}

/* Mobile: hide the nav by default and show hamburger */
@media (max-width: 40em) {
    .hamburger { display: inline-flex; }

    /* hide the primary nav and show via body.nav-open */
    #primary-nav {
        display: none;
        position: static; /* in document flow so it pushes content when shown */
        width: 100%;
        background: transparent !important;
        padding: 8px 12px;
        box-shadow: none !important;
        z-index: 60;
        flex-direction: column;
        gap: 6px;
    }

    body.nav-open #primary-nav {
        display: flex; /* revealed when body has nav-open */
    }

    /* When displayed, ensure the inner list stacks vertically so items fill the width */
    body.nav-open #primary-nav ul {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 0;
        margin: 0;
        width: 100%;
    }
    
    body.nav-open #primary-nav li { width: 100%; }

    /* adjust nav ul items inside #primary-nav */
    #primary-nav li a {
        display: block;
        padding: 12px 10px;
        border-radius: 8px;
        color: #fff;
    }

    /* ensure hamburger is visually separated from the lang-switch */
    nav { position: relative; }
}
