body {
    margin: 0;
    background: #efefef;
    font-family: Arial, sans-serif;
}

/* =========================
   STRUCTURE PRINCIPALE
   ========================= */

.publication-layout {
    display: flex;
    height: calc(100vh - 140px);
    min-height: 0;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;

    background: #fff;
    border-right: 1px solid #ddd;

    overflow-y: auto;
}

.sidebar h2 {
    margin: 0;
    padding: 25px;

    background: #d32f2f;
    color: #fff;

    font-size: 24px;
}

.publication-item {
    padding: 18px 22px;

    border-bottom: 1px solid #eee;

    cursor: pointer;

    transition: .25s;
}

.publication-item:hover {
    background: #f7f7f7;
}

.publication-item.active {
    background: #ffeaea;
    border-left: 5px solid #d32f2f;
}

.pub-title {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 6px;
}

.pub-number {
    font-size: 14px;
    color: #777;
}

/* =========================
   ZONE LECTEUR
   ========================= */

.viewer {
    position: relative;

    flex: 1;

    min-width: 0;
    min-height: 0;

    display: flex;
    flex-direction: column;

    background: #666;

    overflow: hidden;
}

/* =========================
   ZONE DU MAGAZINE
   ========================= */

.book-viewport {
    position: relative;

    flex: 1;

    min-width: 0;
    min-height: 0;

    width: 100%;

    display: flex;

    justify-content: center;
    align-items: center;

    overflow: hidden;

    box-sizing: border-box;
}

/*
   IMPORTANT :
   On ne donne PAS de largeur/hauteur
   artificielle à #book.

   PageFlip doit gérer sa propre taille.
*/

#book {
    position: relative;

    flex-shrink: 0;

    margin: 0;
    padding: 0;

    display: block;

    transform-origin: center center;

    box-sizing: border-box;
}

/* =========================
   PAGES PDF
   ========================= */

.page {
    background: #fff;

    overflow: hidden;

    box-sizing: border-box;
}

.page canvas {
    display: block;

    width: 100%;
    height: 100%;
}

/* =========================
   CHARGEMENT
   ========================= */

.loading-magazine {
    position: absolute;

    inset: 0;

    display: flex;

    flex-direction: column;

    justify-content: center;
    align-items: center;

    gap: 20px;

    color: #fff;

    z-index: 10;
}

.spinner {
    width: 60px;
    height: 60px;

    border: 6px solid rgba(255, 255, 255, .3);

    border-top: 6px solid #fff;

    border-radius: 50%;

    animation: spin 1s linear infinite;
}

@keyframes spin {

    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }

}

/* =========================
   BARRE D'OUTILS
   ========================= */

.toolbar {
    flex-shrink: 0;

    width: 100%;
    height: 60px;

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 12px;

    background: #222;

    border-top: 1px solid #444;

    box-sizing: border-box;

    z-index: 20;
}

.toolbar button {
    padding: 8px 15px;

    border: none;
    border-radius: 8px;

    background: #d32f2f;
    color: #fff;

    font-size: 17px;

    cursor: pointer;

    transition: .2s;
}

.toolbar button:hover {
    transform: translateY(-2px);
}

#pageInfo {
    min-width: 120px;

    text-align: center;

    color: #fff;

    font-weight: bold;
}

/* =========================
   ANCIEN MODE READER
   Désactivé pour l'instant
   ========================= */

.reader {
    display: none;
}

/* =========================
   RESPONSIVE
   ========================= */

/* TABLETTE */

@media (max-width: 1000px) {

    .publication-layout {
        height: calc(100dvh - 140px);
    }

    .sidebar {
        width: 220px;
    }

    .sidebar h2 {
        padding: 18px;
        font-size: 20px;
    }

    .publication-item {
        padding: 14px 16px;
    }

}


/* MOBILE */

@media (max-width: 700px) {

    .publication-layout {
        display: flex;
        flex-direction: column;

        width: 100%;
        height: calc(100dvh - 140px);

        min-height: 0;
    }

    /* -------------------------
       LISTE DES MAGAZINES
       ------------------------- */

    .sidebar {
        width: 100%;
        height: auto;

        max-height: 125px;

        flex-shrink: 0;

        border-right: none;
        border-bottom: 1px solid #444;

        overflow-x: auto;
        overflow-y: hidden;

        white-space: nowrap;
    }

    .sidebar h2 {
        padding: 10px 15px;

        font-size: 18px;

        position: sticky;
        left: 0;
    }

    #listePublications {
        display: flex;

        width: max-content;

        min-width: 100%;
    }

    .publication-item {
        display: block;

        min-width: 125px;

        padding: 10px 14px;

        border-bottom: none;
        border-right: 1px solid #eee;

        box-sizing: border-box;
    }

    .publication-item.active {
        border-left: none;
        border-bottom: 4px solid #d32f2f;
    }


    /* -------------------------
       LECTEUR
       ------------------------- */

    .viewer {
        flex: 1;

        min-height: 0;
        min-width: 0;

        width: 100%;

        overflow: hidden;
    }

    .book-viewport {
        width: 100%;
        height: 100%;

        min-height: 0;

        padding: 8px;

        box-sizing: border-box;
    }

    #book {
        max-width: 100%;
        max-height: 100%;
    }


    /* -------------------------
       BARRE D'OUTILS
       ------------------------- */

    .toolbar {
        height: 52px;

        min-height: 52px;

        gap: 6px;

        padding: 5px;

        box-sizing: border-box;
    }

    .toolbar button {
        min-width: 40px;

        padding: 7px 9px;

        font-size: 15px;

        border-radius: 7px;
    }

    #pageInfo {
        min-width: 70px;

        font-size: 13px;
    }

}


/* PETIT TÉLÉPHONE */

@media (max-width: 420px) {

    .sidebar {
        max-height: 110px;
    }

    .sidebar h2 {
        font-size: 16px;
        padding: 8px 12px;
    }

    .publication-item {
        min-width: 115px;

        padding: 9px 11px;

        font-size: 13px;
    }

    .toolbar {
        height: 48px;
        min-height: 48px;
    }

    .toolbar button {
        min-width: 36px;

        padding: 6px 8px;

        font-size: 14px;
    }

    #pageInfo {
        min-width: 60px;

        font-size: 12px;
    }

}

@media (max-width: 700px) {

    .toolbar {
        position: relative;
        z-index: 50;
    }

    #fullscreen {
        display: none;
    }

}

#loupe {
    position: absolute;

    width: 260px;
    height: 260px;

    border-radius: 50%;

    border: 4px solid #fff;

    box-shadow:
        0 5px 20px rgba(0, 0, 0, .45);

    background: #fff;

    pointer-events: none;

    display: none;

    z-index: 100;

    overflow: hidden;

    box-sizing: border-box;
}

#loupe.active {
    display: block;
}

#loupe canvas {
    position: absolute;

    width: 100%;
    height: 100%;

    display: block;
}

@media (max-width:700px) {
    #zoomLoupe {
        display: none;
    }
}
