/* Variables de base (pilotées dynamiquement par la couleur choisie) */
:root {
    --papier: #f4f1ea;
    --encre: #1a1917;
    --accent: #15803d;
    --note-bordure: #b93815;

    /* Déclinaisons calculées automatiquement via color-mix() */
    --surface: color-mix(in srgb, var(--papier) 65%, white);
    --surface-hover: color-mix(in srgb, var(--papier) 88%, var(--encre));
    --texte-secondaire: color-mix(in srgb, var(--encre) 72%, var(--papier));
    --bordure-legere: color-mix(in srgb, var(--encre) 22%, var(--papier));
    --trame: color-mix(in srgb, var(--encre) 7%, transparent);
    --note-bg: color-mix(in srgb, var(--papier) 92%, var(--note-bordure));
}

/* Mode sombre automatique si aucun papier n'est choisi manuellement */
@media (prefers-color-scheme: dark) {
    :root:not([data-papier]) {
        --papier: #161615;
        --encre: #ece8df;
        --accent: #4ade80;
        --note-bordure: #e07a5f;
        --surface: #1f1e1c;
        --surface-hover: #2b2926;
        --trame: rgba(236, 232, 223, 0.06);
    }
}

/* Ajustement automatique des surfaces quand un papier sombre est choisi */
:root[data-mode="sombre"] {
    --surface: color-mix(in srgb, var(--papier) 88%, white);
    --surface-hover: color-mix(in srgb, var(--papier) 80%, white);
    --trame: color-mix(in srgb, var(--encre) 8%, transparent);
}

/* Règle globale : angles vifs et police monospace */
* {
    box-sizing: border-box;
    border-radius: 0 !important;
}

body {
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, 'DejaVu Sans Mono', monospace;
    max-width: 1240px;
    margin: 2.5rem auto;
    padding: 0 1.5rem;
    line-height: 1.6;
    background-color: var(--papier);
    color: var(--encre);
    font-size: 0.95rem;
    transition: background-color 0.2s, color 0.2s;
}

/* --- LES 4 TRAMES DE PAPIER --- */

/* 1. Croix de repérage d'imprimerie (par défaut) */
body[data-trame="croix"], body:not([data-trame]) {
    background-image:
        linear-gradient(to right, transparent 13px, var(--trame) 13px, var(--trame) 15px, transparent 15px),
        linear-gradient(to bottom, transparent 13px, var(--trame) 13px, var(--trame) 15px, transparent 15px);
    background-size: 28px 28px;
    background-position: 0 0;
}

/* 2. Trame de papier vergé (fibres fines) */
body[data-trame="verge"] {
    background-image:
        repeating-linear-gradient(0deg, transparent, transparent 2px, var(--trame) 3px, transparent 4px),
        repeating-linear-gradient(90deg, transparent, transparent 42px, var(--trame) 43px, transparent 44px);
    background-size: 100% 6px, 86px 100%;
}

/* 3. Double quadrillage millimétré */
body[data-trame="millimetre"] {
    background-image:
        linear-gradient(var(--trame) 1.5px, transparent 1.5px),
        linear-gradient(90deg, var(--trame) 1.5px, transparent 1.5px),
        linear-gradient(var(--trame) 0.5px, transparent 0.5px),
        linear-gradient(90deg, var(--trame) 0.5px, transparent 0.5px);
    background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
}

/* 4. Papier uni sans trame */
body[data-trame="uni"] {
    background-image: none;
}

/* Titres et liens */
h1, h2, h3 {
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
}

h1 {
    border-bottom: 4px double var(--encre);
    padding-bottom: 0.6rem;
    margin-bottom: 1.25rem;
    font-size: 1.55rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
}

a:hover {
    background-color: var(--accent);
    color: var(--surface);
    border-bottom-style: solid;
}

.cache { display: none !important; }

/* Barre de navigation + sélecteur de papier */
.nav-onglets {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--encre);
}

.nav-gauche {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-onglets button,
.nav-onglets .btn-nav {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    height: 42px;
    padding: 0 1.35rem;
    border: 1.5px solid var(--encre);
    background: var(--surface);
    color: var(--encre);
    cursor: pointer;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.92rem;
    line-height: 1;
    letter-spacing: 0.03em;
    transition: transform 0.1s, box-shadow 0.1s;
}

.nav-onglets button:hover,
.nav-onglets .btn-nav:hover {
    background: var(--surface-hover);
    color: var(--encre);
    border-bottom: 1.5px solid var(--encre);
    transform: translate(-1px, -1px);
    box-shadow: 2px 2px 0 var(--encre);
}

.nav-onglets button.actif {
    background: var(--encre);
    color: var(--surface);
}

/* Sélecteur de papier & trame à droite */
.atelier-papier {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.pastilles-couleur {
    display: flex;
    gap: 0.35rem;
}

.pastille {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1.5px solid var(--encre);
    cursor: pointer;
    transition: transform 0.1s;
}

.pastille:hover {
    transform: translateY(-2px);
}

.pastille.active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.select-trame {
    height: 34px;
    padding: 0 0.5rem;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Barre d'outils et filtres */
.outils {
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--surface);
    border: 3px double var(--encre);
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.barre-haut {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

input[type="search"], select {
    font-family: inherit;
    padding: 0.55rem 0.75rem;
    font-size: 0.92rem;
    border: 1.5px solid var(--encre);
    background: var(--papier);
    color: var(--encre);
}

input[type="search"]:focus, select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

input[type="search"] {
    flex: 1;
    min-width: 240px;
}

.compteur {
    font-size: 0.85rem;
    color: var(--texte-secondaire);
    border-top: 1px dashed var(--bordure-legere);
    padding-top: 0.5rem;
}

/* Grille des livres */
.grille {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
    gap: 1.75rem;
}

.carte {
    border: 1.5px solid var(--encre);
    background: var(--surface);
    padding: 1rem;
    text-align: left;
    color: var(--encre);
    box-shadow: 4px 4px 0 var(--encre);
    transition: transform 0.12s, box-shadow 0.12s;
    display: flex;
    flex-direction: column;
}

.carte:hover {
    background: var(--surface);
    color: var(--encre);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 var(--encre);
    border-bottom: 1.5px solid var(--encre);
}

.carte img {
    width: 100%;
    height: 270px;
    object-fit: contain;
    background-color: var(--papier);
    padding: 0.35rem;
    margin-bottom: 0.85rem;
}

.carte h3 {
    font-size: 1.02rem;
    margin: 0 0 0.5rem 0;
    line-height: 1.35;
}

.carte-auteur {
    margin: auto 0 0 0;
    padding-top: 0.55rem;
    border-top: 1px dashed var(--bordure-legere);
    color: var(--texte-secondaire);
    font-size: 0.92rem;
    font-weight: 600;
}

/* En-tête fiche livre */
.entete {
    display: flex;
    gap: 2rem;
    align-items: start;
    margin: 0 0 2rem 0;
    padding: 1.5rem;
    background: var(--surface);
    border: 3px double var(--encre);
    flex-wrap: wrap;
}

.entete > div {
    flex: 1;
    min-width: 260px;
}

.entete img {
    width: 210px;
    border: 1.5px solid var(--encre);
    box-shadow: 4px 4px 0 var(--encre);
}

.entete h2 {
    border-bottom: 2px solid var(--encre);
    padding-bottom: 0.4rem;
    margin-top: 0;
    font-size: 1.35rem;
}

.description-livre {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--bordure-legere);
    text-align: justify;
    hyphens: auto;
}


/* Tableaux des modèles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: var(--surface);
    border: 1.5px solid var(--encre);
}

th, td {
    border: 1px solid var(--bordure-legere);
    padding: 0.75rem 0.9rem;
    text-align: left;
}

th {
    background-color: var(--papier);
    border-bottom: 3px double var(--encre);
    text-transform: uppercase;
    font-size: 0.84rem;
    letter-spacing: 0.05em;
}

tbody tr {
    cursor: pointer;
}

tbody tr:hover {
    background-color: var(--surface-hover);
}

.miniature {
    height: 100px;
    width: auto;
    max-width: 220px;
    object-fit: contain;
    border: 1px solid var(--encre);
    display: block;
}


.lien-livre {
    font-weight: 700;
}

/* Fenêtre modale */
dialog {
    border: 4px double var(--encre);
    padding: 0;
    max-width: 640px;
    width: 92%;
    background: var(--surface);
    color: var(--encre);
    box-shadow: 8px 8px 0 var(--encre);
}

dialog::backdrop {
    background: rgba(18, 18, 16, 0.75);
}

.modale-contenu {
    padding: 1.75rem;
    position: relative;
}

.modale-fermer {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--papier);
    color: var(--encre);
    border: 1.5px solid var(--encre);
    width: 34px;
    height: 34px;
    font-size: 1.1rem;
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

.modale-img {
    width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: var(--papier);
    border: 1.5px solid var(--encre);
    padding: 0.5rem;
    margin-bottom: 1.25rem;
}

.modale-infos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    background: var(--papier);
    border: 1.5px solid var(--encre);
    padding: 1rem;
    margin: 1rem 0;
    font-size: 0.92rem;
}

.modale-notes {
    background: var(--note-bg);
    border: 1px solid var(--bordure-legere);
    border-left: 4px solid var(--note-bordure);
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
}

.btn-voir-livre {
    display: inline-block;
    background: var(--encre);
    color: var(--surface);
    border: 1.5px solid var(--encre);
    padding: 0.65rem 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    box-shadow: 3px 3px 0 var(--encre);
}
.btn-voir-livre:hover {
    background: var(--accent);
    color: var(--surface);
    border-color: var(--encre);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--encre);
}

/* Navigation Précédent / Suivant dans la modale */
.modale-entete {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.modale-entete h2 {
    margin: 0;
    line-height: 1.3;
}

.modale-actions-haut {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

.modale-nav,
.modale-fermer {
    position: static;
    background: var(--papier);
    color: var(--encre);
    border: 1.5px solid var(--encre);
    width: 34px;
    height: 34px;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--encre);
}

.modale-nav:hover:not(:disabled),
.modale-fermer:hover {
    background: var(--accent);
    color: var(--surface);
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--encre);
}

.modale-nav:disabled {
    opacity: 0.25;
    cursor: not-allowed;
    box-shadow: none;
}

/* Colonnes triables dans les tableaux */
th.triable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.6rem;
}

th.triable:hover {
    background-color: var(--surface-hover);
}

th.triable::after {
    content: "⇅";
    position: absolute;
    right: 0.5rem;
    opacity: 0.4;
    font-size: 0.8rem;
}

th.triable.tri-asc::after {
    content: "▲";
    opacity: 1;
    color: var(--accent);
}

th.triable.tri-desc::after {
    content: "▼";
    opacity: 1;
    color: var(--accent);
}


/* Encadré synthétique : Pack de papier suggéré (Repliable + Badges doux) */
.pack-papier {
    margin: 0 0 2rem 0;
    padding: 0.85rem 1.25rem;
    background: var(--surface);
    border: 3px double var(--encre);
}

.pack-papier summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.98rem;
    user-select: none;
}

.pack-papier summary::-webkit-details-marker {
    display: none;
}

.pack-papier[open] summary {
    border-bottom: 1.5px solid var(--encre);
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

/* Indicateur [−] / [+] façon fiche technique */
.indicateur-pli::after {
    content: "[ + AFFICHER ]";
    font-size: 0.78rem;
    color: var(--accent);
}

.pack-papier[open] .indicateur-pli::after {
    content: "[ − RÉDUIRE ]";
}

.liste-pack {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
    column-gap: 2.5rem;
}

.ligne-pack-type {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.45rem 0;
    border-bottom: 1px dashed var(--bordure-legere);
    font-size: 0.86rem;
}

.pack-type-titre {
    width: 155px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--encre);
    flex-shrink: 0;
}

.pack-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    line-height: 1.45;
}

.pack-item-inline {
    display: block;
}

/* Badge discret avec bordure fine au lieu d'un bloc noir plein */
.pack-qte {
    display: inline-block;
    background: var(--papier);
    color: var(--encre);
    border: 1px solid var(--bordure-legere);
    font-weight: 700;
    padding: 0 0.35rem;
    font-size: 0.78rem;
    margin-right: 0.4rem;
}

.pack-noms {
    color: var(--texte-secondaire);
}

@media (max-width: 600px) {
    .liste-pack {
        grid-template-columns: 1fr;
    }
    .ligne-pack-type {
        flex-direction: column;
        gap: 0.2rem;
    }
}




/* Badge de collection et statistiques sur les cartes (Accueil) */
.badge-collection {
    display: inline-block;
    align-self: flex-start;
    background: var(--encre);
    color: var(--surface);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    margin-bottom: 0.45rem;
}

.carte-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--bordure-legere);
    font-size: 0.8rem;
    color: var(--texte-secondaire);
    font-weight: 600;
}

/* Jauge de progression des modèles photographiés (Fiche livre) */
.stats-livre {
    margin: 1rem 0;
    padding: 0.75rem 1rem;
    background: var(--papier);
    border: 1.5px solid var(--encre);
}

.stats-texte {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.88rem;
    margin-bottom: 0.5rem;
}

.jauge-fond {
    width: 100%;
    height: 10px;
    background: var(--surface);
    border: 1px solid var(--encre);
}

.jauge-remplissage {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}

/* Pied de page (Footer) */
.pied-page {
    margin-top: 3.5rem;
    padding-top: 1rem;
    border-top: 4px double var(--encre);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.84rem;
    color: var(--texte-secondaire);
}

/* Bouton flottant : Revenir en haut de page */
.btn-haut {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    width: 42px;
    height: 42px;
    padding: 0;
    background: var(--surface);
    color: var(--encre);
    border: 1.5px solid var(--encre);
    box-shadow: 3px 3px 0 var(--encre);
    font-size: 1.2rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn-haut:hover {
    background: var(--accent);
    color: var(--surface);
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 var(--encre);
}

/* Barre de pagination numérotée avec ellipses */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 2rem;
}

.pagination button {
    min-width: 38px;
    height: 38px;
    padding: 0 0.65rem;
    background: var(--surface);
    color: var(--encre);
    border: 1.5px solid var(--encre);
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 2px 2px 0 var(--encre);
    transition: transform 0.1s, box-shadow 0.1s;
}

.pagination button:hover:not(.actif) {
    background: var(--surface-hover);
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--encre);
}

.pagination button.actif {
    background: var(--encre);
    color: var(--surface);
    cursor: default;
}

.pagination-points {
    padding: 0 0.35rem;
    font-weight: 700;
    color: var(--texte-secondaire);
    user-select: none;
}

.pagination-haut {
    margin-top: 0;
    margin-bottom: 1.5rem;
}


/* --- PAGE STATISTIQUES --- */
.grille-kpi {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.carte-kpi {
    background: var(--surface);
    border: 3px double var(--encre);
    padding: 1.1rem 1.25rem;
    box-shadow: 4px 4px 0 var(--encre);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-titre {
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--texte-secondaire);
}

.kpi-valeur {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 0.35rem 0;
    line-height: 1.1;
}

.kpi-valeur small {
    font-size: 1rem;
    color: var(--texte-secondaire);
}

.kpi-detail {
    font-size: 0.82rem;
    color: var(--texte-secondaire);
    margin-top: 0.35rem;
}

.grille-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(440px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 520px) {
    .grille-stats {
        grid-template-columns: 1fr;
    }
}

.bloc-stat {
    background: var(--surface);
    border: 1.5px solid var(--encre);
    padding: 1.25rem 1.5rem;
    box-shadow: 4px 4px 0 var(--encre);
}

.bloc-stat h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--encre);
    font-size: 1.05rem;
}

.barre-stat {
    margin-bottom: 0.85rem;
}

.barre-stat:last-child {
    margin-bottom: 0;
}

.barre-stat-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    margin-bottom: 0.25rem;
}

/* --- BADGE ANNÉE (Fiche livre + Cartes accueil) --- */
.entete-titre {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 2px solid var(--encre);
    padding-bottom: 0.45rem;
    margin-bottom: 1rem;
}

.entete-titre h2 {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.badge-annee {
    background: var(--papier);
    color: var(--encre);
    border: 1.5px solid var(--encre);
    padding: 0.15rem 0.55rem;
    font-weight: 700;
    font-size: 0.85rem;
    box-shadow: 2px 2px 0 var(--encre);
    flex-shrink: 0;
}

.carte-badges {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
    min-height: 22px;
}

.carte-badges .badge-collection {
    margin-bottom: 0;
}

.badge-annee-carte {
    font-size: 0.74rem;
    padding: 0.1rem 0.4rem;
    margin-left: auto;
}
