/* ===============================
   MÉDIAS UNIFIÉS (images, vidéos, PDFs, gifs dynamiques)
   =============================== */
/* ===============================
   MÉDIAS UNIFIÉS (séparation figure / img / embed)
   =============================== */

/* --- Figure générique (bloc multimédia avec cadre) --- */
figure,
.embed-figure,
.gif-wrapper+.embed-figure,
.embed-container {
    display: block;
    margin: 1.5em 0;
    padding: 0.5em;
    border: 2px solid var(--header-background-color);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: var(--content-background-color, transparent);
    width: 100%;
}

/* --- Images SEULES (hors figure) → cadre --- */
img:not(figure img) {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 7px;
    border: 2px solid var(--header-background-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    background-color: var(--content-background-color, transparent);
}

/* --- Images DANS une figure → pas de double bordure --- */
figure img,
.embed-figure img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 7px;
    border: none;
    /* pas de cadre, le figure s'en charge */
    box-shadow: none;
    /* pas d’ombre, héritée du figure */
    background: transparent;
}

/* --- Vidéos animées dans figure --- */
.embed-figure video.video-anim {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 7px;
    border: none;
    box-shadow: none;
    background: transparent;
}

/* --- Iframes dans container --- */
.embed-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    /* pas de bordure interne */
    border-radius: 7px;
    background: transparent;
}

/* --- Figcaption (pour tous les médias) --- */
figure figcaption,
.embed-figure figcaption,
.gif-wrapper+.embed-figure figcaption,
.embed-container figcaption {
    font-size: 0.85em;
    margin-top: 0.3em;
    padding: 0.3em 0.5em;
    background-color: var(--header-background-color) !important;
    color: var(--content-background-color) !important;
    border-radius: 7px;
    text-align: left;
    font-weight: 400;
    line-height: 1.3;
    font-style: italic;
}

/* --- Container responsive pour iframe/tableaux/PDF --- */
.embed-container {
    position: relative;
    padding-bottom: 65%;
    height: 0;
    overflow: hidden;
}

/* ===============================
   ANKI
   =============================== */
.cartes-anki-button {
    background-color: #93C5FD;
    color: #2C2C2C;
    border: none;
    padding: 2px 4px;
    border-radius: 10px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    display: inline-block;
    margin: 2px;
    line-height: 1.2;
}

.notes-anki-button {
    background-color: #4ADE80;
    color: #2C2C2C;
    border: none;
    padding: 2px 4px;
    border-radius: 10px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    display: inline-block;
    margin: 2px;
    line-height: 1.2;
}

.flag-anki-button {
    background-color: #2C2C2C;
    border-radius: 3px;
    padding: 3px;
    margin: 2px;
    line-height: 1.7;
}

.sauvegarde-anki-button {
    background-color: #2e64df;
    color: #ffffff;
    border: none;
    padding: 2px 4px;
    border-radius: 4px;
    box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    display: inline-block;
    margin: 2px;
    line-height: 1.2;
}

/* ===============================
   TAB BAR
   =============================== */
.tab-bar {
    display: flex;
    border-bottom: 1px solid #555;
    background: #353535;
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tab-button {
    display: inline-block;
    padding: 6px 14px;
    margin: 0;
    font-family: sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #eee;
    background: #353535;
    border: 1px solid #343232;
    border-bottom: none;
    border-radius: 0 0 6px 6px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.tab-button:hover {
    background: #454545;
}

.tab-button.active {
    background: #555;
    color: #ffffff;
}

/* ===============================
   COPY BLOCK
   =============================== */
.copy-block {
    display: inline-block;
    cursor: pointer;
    background-color: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.2em 0.4em;
    font-family: monospace;
    position: relative;
    margin: 0;
    transition: background-color 0.2s;
}

.copy-block:hover {
    background-color: #e2e8f0;
}

.copy-block code {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font-size: 0.95em;
}

.copy-feedback {
    opacity: 0;
    transform: translateY(5px);
    pointer-events: none;
    font-size: 0.85em;
    color: #22c55e;
    background-color: #f9fafb;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    position: absolute;
    left: 0;
    top: calc(100% + 0.4em);
    white-space: nowrap;
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    z-index: 5;
    box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.15);
}

.copy-feedback.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Petite taille spécifique pour un seul bloc de copie */
.copy-block.tiny-copy {
    font-size: 0.6rem;
    /* encore un peu plus petit */
    line-height: 1.1;
    vertical-align: baseline;
}

/* Bloc de copie qui se déplie au clic */
.copy-block.collapse-copy {
    display: block;
    margin: 0.8em 0;
    max-height: 1.4em;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    transition: max-height 0.25s ease-in-out, background-color 0.2s;
    padding-right: 2em;
    /* laisse de la place pour les ... éventuels */
}

.copy-block.collapse-copy.expanded {
    max-height: 1000px;
    white-space: pre-wrap;
    background-color: #f8fafc;
}

.copy-block.collapse-copy code {
    display: block;
    width: 100%;
}

.copy-block.collapse-copy .copy-feedback {
    top: 5px;
    right: 5px;
    left: auto;
}

/* ===============================
   FOOTER ET LOGOS
   =============================== */
footer {
    margin-top: 2em;
    padding: 1em;
    text-align: center;
    font-size: 0.9em;
    color: #666;
    border-top: 1px solid #ddd;
}

.site-footer {
    padding: 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted-color, #666);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.social-icons a {
    display: inline-block;
    margin: 0 8px;
    vertical-align: middle;
    transition: color 0.2s;
}

.social-logo {
    height: 28px;
    vertical-align: middle;
}

.social-icons {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    margin: 1rem 0;
}

.social-icons figure {
    display: inline-block;
    margin: 0;
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
    width: auto;
}

.social-icons figure img.social-logo {
    width: 28px;
    height: 28px;
    display: block;
    margin: 0 auto;
    border: none;
    box-shadow: none;
    background: transparent;
}

.social-icons figcaption {
    font-size: 0.75rem;
    margin-top: 4px;
    text-align: center;
    background: transparent !important;
    color: var(--muted-color, #666) !important;
    font-style: normal;
    padding: 0 !important;
    border-radius: 0;
    font-weight: normal;
    line-height: 1.2;
}

.footer-contribute {
    margin-top: 0.6em;
    font-size: 0.9em;
    color: var(--muted-color, #666);
}

.footer-contribute a {
    color: var(--links);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s;
}

.footer-contribute a:hover {
    text-decoration-color: currentColor;
}


/* ===============================
   ICONES / BOUTONS GÉNÉRIQUES
   =============================== */
.icon-btn {
    --_size: 32px;
    inline-size: var(--_size);
    block-size: var(--_size);
    display: inline-grid;
    place-items: center;
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 999px;
    outline-offset: 3px;
    transition: transform .12s ease, color .12s ease;
    color: var(--header-background-color);
}

.icon-btn:hover {
    transform: translateY(-1px);
    color: var(--header-accent-color);
}

.icon {
    inline-size: 70%;
    block-size: 70%;
    color: inherit;
}

/* ===============================
   BOUTON GIF (vidéo animée)
   =============================== */
h1, h2, h3, h4, h5, h6 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35em;
}

.gif-wrapper {
    display: inline-flex;
    align-items: center;
    margin-left: 0.2em;
    vertical-align: middle;
}

.gif-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35em;
    background: transparent;
    color: #2563eb;
    font-weight: 500;
    border: 1px solid #2563eb;
    border-radius: 6px;
    padding: 0.15em 0.45em;
    cursor: pointer;
    font-size: 0.75em;
    line-height: 1;
    vertical-align: middle;
    transition: all 0.2s ease;
}

h1 .gif-btn, h2 .gif-btn, h3 .gif-btn, h4 .gif-btn, h5 .gif-btn, h6 .gif-btn {
    font-size: 0.55em;
}

.gif-btn:hover {
    background: #2563eb;
    color: white;
}

.gif-btn .icon {
    width: 0.9em;
    height: 0.9em;
    display: inline-block;
}

/* ===============================
   FALLBACK MÉDIAS
   =============================== */
.media-fallback {
    display: block;
    padding: 1em;
    margin: 0.5em 0;
    font-style: italic;
    font-size: 0.95em;
    color: #555;
    background-color: #fafafa;
    border: 2px dashed var(--header-background-color, #bbb);
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* ==== CAROUSEL ==== */
.carousel-container {
    position: relative;
    max-width: 620px;
    margin: 2rem auto;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    background: var(--bg);
}

.carousel-slide {
    display: none;
    animation: fadeEffect 0.5s ease-in-out;
}

.carousel-slide.active {
    display: block;
}

/* Zoom de l'image au survol dans le carousel */
.carousel-slide figure {
    margin: 0;
    overflow: hidden;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
}

.carousel-slide img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    box-shadow: none;
    border-radius: 0;
}

.carousel-slide img:hover {
    transform: scale(1.05);
}

.carousel-slide figcaption {
    text-align: center;
    padding: 10px 16px;
    font-size: 0.88em;
    font-style: italic;
    background: var(--header-background-color);
    color: var(--content-background-color);
    border-radius: 0;
    margin: 0;
}

.carousel-slide {
    border: none;
    padding: 0;
    margin: 0;
    box-shadow: none;
    background: transparent;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    border-radius: 50%;
    width: 42px;
    height: 42px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.25s, transform 0.2s;
    z-index: 10;
    backdrop-filter: blur(4px);
}

.carousel-btn:hover {
    background-color: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.carousel-prev {
    left: 10px;
}

.carousel-next {
    right: 10px;
}

/* Indicateurs de position (points) */
.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0 6px;
    background: var(--header-background-color, #333);
}

.carousel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: background 0.25s, transform 0.2s;
    border: none;
}

.carousel-dot.active {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.3);
}

@keyframes fadeEffect {
    from {
        opacity: 0;
        transform: translateX(8px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* ===============================
   IMAGE SIZING CLASSES
   =============================== */
.img-lg {
    max-width: 100%;
    /* Standard large image */
}

.img-md {
    max-width: 80%;
    margin: 0 auto;
    display: block;
}

.img-sm {
    max-width: 400px;
    margin: 0 auto;
    display: block;
}

/* ===============================
   LIGHTBOX
   =============================== */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    cursor: zoom-out;
}

.lightbox-overlay.zoomed-mode {
    display: block;
    overflow: auto;
    cursor: zoom-out;
}

.lightbox-img {
    max-width: calc(100vw - 160px);
    max-height: 80vh;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    opacity: 0;
    animation: zoomIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    object-fit: contain;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

@media (max-width: 768px) {
    .lightbox-img {
        max-width: calc(100vw - 110px);
        max-height: 75vh;
    }
}

.lightbox-img.lightbox-changing {
    opacity: 0 !important;
    transform: scale(0.95) !important;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lightbox-img.zoomed {
    max-width: 95%;
    max-height: none;
    width: auto;
    height: auto;
    transform: none;
    animation: none;
    cursor: zoom-out;
    margin: 40px auto;
    display: block;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 1003;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.4);
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    text-align: center;
    max-width: 80%;
    pointer-events: none;
    z-index: 1002;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.lightbox-caption.lightbox-changing {
    opacity: 0 !important;
    transform: translateX(-50%) scale(0.95) !important;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.lightbox-overlay.zoomed-mode .lightbox-caption {
    opacity: 0;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    border: none;
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s, transform 0.2s;
    user-select: none;
    z-index: 1002;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 20px;
}

.lightbox-next {
    right: 20px;
}

.lightbox-overlay.zoomed-mode .lightbox-prev,
.lightbox-overlay.zoomed-mode .lightbox-next {
    display: none !important;
}

@media (max-width: 768px) {
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    .lightbox-prev {
        left: 10px;
    }
    .lightbox-next {
        right: 10px;
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Helper to make images clickable */
img.clickable-zoom {
    cursor: zoom-in;
    transition: transform 0.2s;
}

img.clickable-zoom:hover {
    transform: scale(1.02);
}

/* ===============================
   STATS GRID (page d'accueil)
   =============================== */
.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--header-background-color);
    color: var(--content-background-color);
    border-radius: 12px;
    padding: 1.2rem 2rem;
    min-width: 130px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 0.8rem;
    margin-top: 0.4rem;
    opacity: 0.85;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}