/*
 * Tsundoku — deux mondes, une seule feuille.
 *
 * Tout passe par des variables posées sur <body class="monde-manga|monde-roman"> :
 * le Monde Manga est une planche de BD (encre, trames, cases à ombre décalée),
 * le Monde Roman une page de livre (papier crème, empattements, sobriété).
 * Bootstrap (via le thème GXON) ne sert qu'à la grille et aux formulaires.
 */

:root {
    --bs-btn-primary-hover: #2a5ad9;
}

/* ---------- Les deux ambiances ---------- */

.monde-manga {
    --encre: #141414;
    --papier: #fffdf6;
    --carte: #ffffff;
    --accent: #ff3b3b;
    --accent-texte: #ffffff;
    --surligne: #ffd23f;
    --doux: #6b6b6b;
    --ligne: var(--encre);
    --trait: 3px;
    --ombre: 5px 5px 0 var(--encre);
    --ombre-forte: 8px 8px 0 var(--encre);
    --rayon: 6px;
    --titre: 'Bangers', 'Impact', sans-serif;
    --texte: 'Zen Maru Gothic', 'Plus Jakarta Sans', system-ui, sans-serif;
    --fond: radial-gradient(rgba(20, 20, 20, .09) 1.1px, transparent 1.4px) 0 0 / 11px 11px, var(--papier);
}

.monde-roman {
    --encre: #2b2522;
    --papier: #f7f2e8;
    --carte: #fffdf8;
    --accent: #7a2e2e;
    --accent-texte: #fffdf8;
    --surligne: transparent;
    --doux: #7d7266;
    --ligne: #e3d9c6;
    --trait: 1px;
    --ombre: 0 1px 2px rgba(60, 45, 30, .06), 0 6px 18px rgba(60, 45, 30, .07);
    --ombre-forte: 0 2px 4px rgba(60, 45, 30, .08), 0 12px 28px rgba(60, 45, 30, .12);
    --rayon: 8px;
    --titre: 'Lora', Georgia, serif;
    --texte: 'Source Sans 3', 'Plus Jakarta Sans', system-ui, sans-serif;
    --fond: var(--papier);
}

body.monde {
    background: var(--fond);
    color: var(--encre);
    font-family: var(--texte);
    min-height: 100vh;
    padding-bottom: 5.5rem; /* la barre du bas sur téléphone */
}

@media (min-width: 992px) {
    body.monde { padding-bottom: 2rem; }
}

.monde a { color: inherit; }
.monde .text-doux { color: var(--doux) !important; }

.monde h1, .monde h2, .monde h3, .monde .titre {
    font-family: var(--titre);
    color: var(--encre);
    font-weight: 600;
}

.monde-manga h1, .monde-manga h2, .monde-manga h3, .monde-manga .titre {
    font-weight: 400;
    letter-spacing: .04em;
}

/* ---------- Barre du haut ---------- */

.barre {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--carte);
    border-bottom: var(--trait) solid var(--ligne);
}

.barre-dedans {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 64px;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: .45rem;
    text-decoration: none;
    white-space: nowrap;
}

.logo-nom {
    font-family: var(--titre);
    font-size: 1.7rem;
    line-height: 1;
}

.logo-kanji {
    font-size: .85rem;
    color: var(--doux);
}

.monde-manga .logo-nom {
    color: var(--encre);
    text-shadow: 2px 2px 0 var(--surligne);
    transform: rotate(-2deg);
    display: inline-block;
}

.nav-principale {
    display: none;
    gap: .25rem;
    margin-left: 1rem;
}

.nav-principale a {
    padding: .45rem .8rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    font-size: .95rem;
    color: var(--doux);
}

.nav-principale a:hover { color: var(--encre); }

.nav-principale a.actif {
    color: var(--encre);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.monde-manga .nav-principale a.actif {
    background: var(--surligne);
    border: 2px solid var(--encre);
    border-radius: 4px;
    transform: rotate(-1deg);
}

@media (min-width: 992px) {
    .nav-principale { display: flex; }
}

.barre-fin {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .6rem;
}

/* Le sélecteur de monde : deux moitiés, la courante pleine. */
.bascule {
    display: inline-flex;
    border: var(--trait) solid var(--encre);
    border-radius: 999px;
    overflow: hidden;
    font-weight: 700;
    font-size: .85rem;
    background: var(--carte);
}

.monde-roman .bascule { border-color: var(--ligne); }

.bascule a {
    display: flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .8rem;
    text-decoration: none;
    color: var(--doux);
    transition: background .2s, color .2s;
}

.bascule a.actif-manga {
    background: #ff3b3b;
    color: #fff;
    font-family: 'Bangers', sans-serif;
    font-weight: 400;
    letter-spacing: .06em;
    font-size: 1rem;
}

.bascule a.actif-roman {
    background: #7a2e2e;
    color: #fffdf8;
    font-family: 'Lora', serif;
    font-style: italic;
}

.bascule .bascule-mot { display: none; }
@media (min-width: 576px) { .bascule .bascule-mot { display: inline; } }

.avatar-rond {
    display: inline-grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-texte);
    font-weight: 700;
    font-size: .85rem;
    text-decoration: none;
    flex-shrink: 0;
}

.monde-manga .avatar-rond { border: 2px solid var(--encre); }
.avatar-rond.petit { width: 1.8rem; height: 1.8rem; font-size: .7rem; }

/* Barre du bas, téléphone seulement. */
.barre-bas {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--carte);
    border-top: var(--trait) solid var(--ligne);
    padding-bottom: env(safe-area-inset-bottom);
}

.barre-bas a {
    display: grid;
    justify-items: center;
    gap: .15rem;
    padding: .55rem 0 .5rem;
    font-size: .7rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--doux);
}

.barre-bas a i { font-size: 1.25rem; line-height: 1; }
.barre-bas a.actif { color: var(--accent); }
.monde-manga .barre-bas a.actif { color: var(--encre); }
.monde-manga .barre-bas a.actif i {
    background: var(--surligne);
    border-radius: 50%;
    box-shadow: 0 0 0 5px var(--surligne);
}

@media (min-width: 992px) {
    .barre-bas { display: none; }
}

/* ---------- En-tête de page ---------- */

.entete {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.75rem 0 1.5rem;
}

.entete h1 {
    font-size: clamp(2rem, 6vw, 3rem);
    margin: 0;
    line-height: 1.05;
}

.monde-manga .entete h1 span.surligne {
    background: linear-gradient(transparent 55%, var(--surligne) 55%);
    padding: 0 .15em;
}

.monde-roman .entete h1 { font-style: italic; }

.entete p { margin: .35rem 0 0; color: var(--doux); }

/* ---------- Cases (cartes) ---------- */

.case {
    background: var(--carte);
    border: var(--trait) solid var(--ligne);
    border-radius: var(--rayon);
    box-shadow: var(--ombre);
    padding: 1.25rem;
}

.case + .case { margin-top: 1.25rem; }
.series > .case, .row > * > .case + .case { margin-top: 0; }
.row > * > .case ~ .case { margin-top: 1.25rem; }

.case-titre {
    font-family: var(--titre);
    font-size: 1.4rem;
    margin: 0 0 .9rem;
}

.monde-manga .case-titre { letter-spacing: .04em; }

/* ---------- Boutons ---------- */

.bouton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    font-weight: 700;
    font-size: .92rem;
    line-height: 1.2;
    border-radius: var(--rayon);
    border: var(--trait) solid var(--encre);
    background: var(--carte);
    color: var(--encre);
    text-decoration: none;
    cursor: pointer;
    transition: transform .08s, box-shadow .08s, background .15s;
    white-space: nowrap;
}

.bouton.plein { background: var(--accent); color: var(--accent-texte); border-color: var(--accent); }
.bouton.petit { padding: .3rem .65rem; font-size: .82rem; }
.bouton.discret { border-color: transparent; background: transparent; color: var(--doux); box-shadow: none !important; }
.bouton.discret:hover { color: var(--encre); }
.bouton.danger { color: #b42318; }
.bouton:disabled { opacity: .5; cursor: default; }

.monde-manga .bouton { box-shadow: 3px 3px 0 var(--encre); }
.monde-manga .bouton.plein { border-color: var(--encre); }
.monde-manga .bouton:hover:not(:disabled) { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--encre); }
.monde-manga .bouton:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--encre); }

.monde-roman .bouton { border-color: var(--ligne); }
.monde-roman .bouton.plein { border-color: var(--accent); }
.monde-roman .bouton:hover:not(:disabled) { border-color: var(--accent); }
.monde-roman .bouton.plein:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }

form.en-ligne { display: inline; }

/* ---------- Champs ---------- */

.monde .form-control, .monde .form-select {
    border: var(--trait) solid var(--ligne);
    border-radius: var(--rayon);
    background-color: var(--carte);
    color: var(--encre);
    font-family: var(--texte);
}

.monde .form-control:focus, .monde .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}

.monde .form-label { font-weight: 700; }

/* La grande barre de recherche. */
.cherche {
    display: flex;
    gap: .6rem;
}

.cherche input {
    flex: 1;
    font-size: 1.1rem;
    padding: .8rem 1rem;
}

.monde-manga .cherche input { box-shadow: 4px 4px 0 var(--encre); }

/* ---------- Couvertures ---------- */

.couv {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: #ece6da;
    border-radius: 3px;
}

.monde-manga .couv { border: 2px solid var(--encre); }
.monde-roman .couv { box-shadow: 0 1px 2px rgba(0, 0, 0, .12), 0 6px 14px rgba(60, 45, 30, .18); border-radius: 2px 4px 4px 2px; }

/* Grille de livres. */
.grille-livres {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1.6rem 1.1rem;
}

@media (max-width: 575px) {
    .grille-livres { grid-template-columns: repeat(2, 1fr); gap: 1.3rem .9rem; }
}

.livre {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-width: 0;
}

.livre-lien {
    text-decoration: none;
    display: block;
    position: relative;
    transition: transform .15s;
}

.monde-manga .livre-lien:hover { transform: rotate(-2deg) scale(1.03); }
.monde-roman .livre-lien:hover { transform: translateY(-4px); }

.livre-titre {
    font-weight: 700;
    font-size: .92rem;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.monde-roman .livre-titre { font-family: 'Lora', serif; font-weight: 600; }

.livre-meta {
    font-size: .8rem;
    color: var(--doux);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.livre-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: auto;
}

/* Pastilles posées sur la couverture. */
.pastilles {
    position: absolute;
    top: .4rem;
    left: .4rem;
    right: .4rem;
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    pointer-events: none;
}

.pastille {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    padding: .15rem .45rem;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 999px;
    background: var(--carte);
    color: var(--encre);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.pastille.ok { background: #16a34a; color: #fff; }
.pastille.pret { background: #f59e0b; color: #1c1300; }
.pastille.ami { background: #2563eb; color: #fff; }
.pastille.reserve { background: #7c3aed; color: #fff; }

.monde-manga .pastille { border: 2px solid var(--encre); box-shadow: none; border-radius: 4px; transform: rotate(-3deg); }

/* Le numéro de tome, gros, en coin. */
.num-tome {
    position: absolute;
    right: -.5rem;
    bottom: -.5rem;
    min-width: 2.4rem;
    height: 2.4rem;
    padding: 0 .4rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    font-weight: 800;
    font-size: 1rem;
    background: var(--carte);
    color: var(--encre);
}

.monde-manga .num-tome {
    font-family: 'Bangers', sans-serif;
    font-weight: 400;
    font-size: 1.35rem;
    background: var(--surligne);
    border: 3px solid var(--encre);
    transform: rotate(8deg);
}

.monde-roman .num-tome {
    font-family: 'Lora', serif;
    font-size: .85rem;
    border: 1px solid var(--ligne);
    min-width: 2rem;
    height: 2rem;
}

/* ---------- Séries sur l'étagère ---------- */

.series {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

@media (max-width: 575px) { .series { grid-template-columns: 1fr; } }

.serie {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 1rem;
    align-items: start;
    text-decoration: none;
}

.serie .case-titre { font-size: 1.3rem; margin-bottom: .2rem; line-height: 1.1; }

/* Les dos des tomes : on voit d'un coup d'œil ce qui manque. */
.dos {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin: .7rem 0 .4rem;
}

.dos span {
    display: grid;
    place-items: end center;
    width: 20px;
    height: 34px;
    padding-bottom: 2px;
    font-size: .62rem;
    font-weight: 800;
    border-radius: 2px;
    background: var(--accent);
    color: var(--accent-texte);
}

.dos span:nth-child(3n+2) { filter: brightness(1.12); }
.dos span:nth-child(3n) { filter: brightness(.9); }
.dos span.trou { background: transparent; color: var(--doux); border: 2px dashed var(--doux); filter: none; }
.dos span.lu::after { content: ''; }

.monde-manga .dos span { border: 2px solid var(--encre); }
.monde-manga .dos span.trou { border: 2px dashed var(--encre); }
.monde-roman .dos span { border-radius: 1px; }

.progression {
    height: 6px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--encre) 10%, transparent);
    overflow: hidden;
}

.progression > div { height: 100%; background: var(--accent); }
.monde-manga .progression { height: 10px; border: 2px solid var(--encre); background: var(--carte); }
.monde-manga .progression > div { background: repeating-linear-gradient(-45deg, var(--accent) 0 6px, #ff6b6b 6px 12px); }

/* ---------- Bulles (vides, astuces) ---------- */

.bulle {
    position: relative;
    max-width: 34rem;
    margin: 2.5rem auto 3.5rem;
    padding: 1.5rem 1.75rem;
    text-align: center;
    background: var(--carte);
    border: var(--trait) solid var(--ligne);
    border-radius: 1.5rem;
}

.bulle h2 { font-size: 1.8rem; margin-bottom: .4rem; }
.bulle p { color: var(--doux); }

.monde-manga .bulle {
    border-radius: 50% / 38%;
    padding: 2.4rem 2.6rem;
    box-shadow: var(--ombre);
}

.monde-manga .bulle::after {
    content: '';
    position: absolute;
    bottom: -28px;
    left: 22%;
    width: 0;
    height: 0;
    border: 16px solid transparent;
    border-top: 30px solid var(--encre);
    border-bottom: 0;
    transform: skewX(-25deg);
}

.monde-roman .bulle { box-shadow: var(--ombre); }

/* ---------- Messages ---------- */

.messages {
    position: fixed;
    z-index: 40;
    left: 50%;
    top: 76px;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 2rem));
    display: grid;
    gap: .5rem;
}

.message {
    display: flex;
    gap: .7rem;
    align-items: flex-start;
    padding: .8rem 1rem;
    background: var(--carte);
    border: var(--trait) solid var(--ligne);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-forte);
    font-weight: 600;
    animation: arrivee .3s ease-out;
}

.message i { font-size: 1.15rem; margin-top: .1rem; }
.message.success i { color: #16a34a; }
.message.error i { color: #dc2626; }
.message.warning i { color: #d97706; }
.message.info i { color: #2563eb; }
.message button { margin-left: auto; border: 0; background: none; color: var(--doux); font-size: 1.2rem; line-height: 1; }
.message.part { animation: depart .3s ease-in forwards; }

.monde-manga .message { border-radius: 4px; }
.monde-manga .message.success { background: #fff7cc; }

@keyframes arrivee { from { opacity: 0; transform: translateY(-12px); } }
@keyframes depart { to { opacity: 0; transform: translateY(-12px); } }

/* « BAM ! » quand un manga rejoint l'étagère. */
.bam {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    place-items: center;
    pointer-events: none;
}

.bam span {
    font-family: 'Bangers', sans-serif;
    font-size: clamp(4rem, 18vw, 9rem);
    color: var(--surligne);
    -webkit-text-stroke: 4px #141414;
    paint-order: stroke fill;
    text-shadow: 8px 8px 0 #141414;
    animation: bam .9s cubic-bezier(.2, 1.6, .4, 1) forwards;
    padding: 2rem 3rem;
    background: radial-gradient(circle, #ff3b3b 0 38%, transparent 39%);
}

@keyframes bam {
    0% { transform: scale(.2) rotate(-25deg); opacity: 0; }
    30% { transform: scale(1.15) rotate(-8deg); opacity: 1; }
    75% { transform: scale(1) rotate(-6deg); opacity: 1; }
    100% { transform: scale(1.4) rotate(-6deg); opacity: 0; }
}

.bam.roman span {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 2rem;
    color: var(--accent);
    -webkit-text-stroke: 0;
    text-shadow: none;
    background: var(--carte);
    padding: 1rem 2rem;
    border-radius: 999px;
    box-shadow: var(--ombre-forte);
    animation: doux 1.2s ease forwards;
}

@keyframes doux {
    0% { opacity: 0; transform: translateY(10px); }
    25%, 70% { opacity: 1; transform: none; }
    100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .bam { display: none; }
    .message { animation: none; }
}

/* ---------- Divers ---------- */

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .3rem .75rem;
    border-radius: 999px;
    border: var(--trait) solid var(--ligne);
    background: var(--carte);
    font-weight: 600;
    font-size: .85rem;
    text-decoration: none;
    color: var(--encre);
}

.chip.actif { background: var(--encre); color: var(--carte); border-color: var(--encre); }
.monde-manga .chip { border-radius: 4px; }

.chiffres { display: flex; flex-wrap: wrap; gap: 1.5rem; }
.chiffre strong { display: block; font-family: var(--titre); font-size: 2rem; line-height: 1; }
.monde-manga .chiffre strong { font-size: 2.4rem; }
.chiffre span { color: var(--doux); font-size: .85rem; }

/* Menu « ♥ liste » sans JavaScript. */
details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }

details.menu > .menu-contenu {
    position: absolute;
    z-index: 20;
    top: calc(100% + .35rem);
    left: 0;
    min-width: 220px;
    padding: .4rem;
    background: var(--carte);
    border: var(--trait) solid var(--encre);
    border-radius: var(--rayon);
    box-shadow: var(--ombre-forte);
}

.monde-roman details.menu > .menu-contenu { border-color: var(--ligne); }
details.menu.a-droite > .menu-contenu { left: auto; right: 0; }

.menu-contenu button, .menu-contenu a {
    display: block;
    width: 100%;
    text-align: left;
    padding: .5rem .65rem;
    border: 0;
    background: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: .88rem;
    color: var(--encre);
    text-decoration: none;
}

.menu-contenu button:hover, .menu-contenu a:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }

.ligne-liste {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .9rem 0;
    border-bottom: 1px solid color-mix(in srgb, var(--encre) 12%, transparent);
}

.ligne-liste:last-child { border-bottom: 0; }
.ligne-liste .mini-couv { width: 48px; flex-shrink: 0; }

.copie {
    display: flex;
    gap: .5rem;
}

.copie input { font-family: ui-monospace, monospace; font-size: .85rem; }

.pagination-livres { display: flex; justify-content: center; gap: .5rem; margin: 2rem 0; }

/* Page d'accueil (non connecté). */
.une {
    position: relative;
    overflow: hidden;
    padding: 4rem 1.5rem;
    text-align: center;
    background:
        repeating-conic-gradient(from 0deg at 50% 50%, rgba(20, 20, 20, .07) 0deg 4deg, transparent 4deg 12deg),
        var(--papier);
    border-bottom: 3px solid var(--encre);
}

.une h1 {
    font-family: 'Bangers', sans-serif;
    font-size: clamp(3.5rem, 13vw, 7rem);
    letter-spacing: .04em;
    line-height: .95;
    margin: 0;
    color: var(--surligne);
    -webkit-text-stroke: 3px #141414;
    paint-order: stroke fill;
    text-shadow: 6px 6px 0 #141414;
    transform: rotate(-3deg);
}

.une .sous {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: 1.25rem;
    margin-top: 1.5rem;
}

/* Liste publique. */
.publique-entete { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.publique-entete h1 { font-size: clamp(2.2rem, 8vw, 3.5rem); }
