/* Styles propres au blog (aucun style en ligne : CSP style-src 'self'). */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
}

.navbar .btn-link.nav-link {
    border: 0;
}

/* Contenu des articles (HTML assaini) */
.article-content img {
    max-width: 100%;
    height: auto;
}

.article-content table {
    width: 100%;
    margin-bottom: 1rem;
    border-collapse: collapse;
}

.article-content th,
.article-content td {
    border: 1px solid var(--bs-border-color);
    padding: .25rem .5rem;
}

.article-content pre {
    background: var(--bs-tertiary-bg);
    padding: .75rem;
    border-radius: .25rem;
}

.article-content blockquote {
    border-left: .25rem solid var(--bs-border-color);
    padding-left: 1rem;
    color: var(--bs-secondary-color);
}

/* Cartes d'articles (page d'accueil, archives, recherche) */
.article-card-image {
    aspect-ratio: 16 / 9;
    object-fit: cover;
    height: auto;
    background: var(--bs-tertiary-bg);
}

.article-card-summary {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.category-count {
    opacity: .75;
    font-size: .875em;
}

/* Commentaires : texte brut, retours à la ligne conservés */
.comment-content {
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Médiathèque et illustrations */
.media-thumb {
    object-fit: cover;
    aspect-ratio: 4 / 3;
    background: var(--bs-tertiary-bg);
}

.article-cover img {
    max-height: 28rem;
    width: auto;
}

/* Journal d'audit */
.audit-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Bandeau (accueil et articles) : image de fond, texte superposé à la position choisie. La boîte
   grandit avec le texte ; l'image la remplit toujours (object-fit). */
.hero {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: clamp(12rem, 32vw, 24rem);
    overflow: hidden;
    border-radius: var(--bs-border-radius-lg);
    background: #212529;
    color: #fff;
}

.hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-has-text::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-text {
    position: relative;
    z-index: 1;
    max-width: 50rem;
    padding: 1.5rem;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}

.hero-title {
    font-size: calc(1.4rem + 1.2vw);
    margin-bottom: .5rem;
}

.hero-lead {
    font-size: 1.15rem;
    margin-bottom: 0;
    white-space: pre-line;
}

.hero-v-top { justify-content: flex-start; }
.hero-v-middle { justify-content: center; }
.hero-v-bottom { justify-content: flex-end; }
.hero-h-start { align-items: flex-start; text-align: start; }
.hero-h-center { align-items: center; text-align: center; }
.hero-h-end { align-items: flex-end; text-align: end; }

.hero-v-top.hero-has-text::after { background: linear-gradient(to bottom, rgba(0, 0, 0, .75), rgba(0, 0, 0, .1)); }
.hero-v-middle.hero-has-text::after { background: rgba(0, 0, 0, .45); }
.hero-v-bottom.hero-has-text::after { background: linear-gradient(to top, rgba(0, 0, 0, .75), rgba(0, 0, 0, .1)); }

@media (min-width: 1200px) {
    .hero-title { font-size: 2.5rem; }
}

/* Différence entre la version en ligne et une révision (modération) */
.revision-diff {
    max-height: 30rem;
    overflow: auto;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    font-size: .85rem;
}

.revision-diff span { display: block; }
.revision-diff .diff-add { background: var(--bs-success-bg-subtle); }
.revision-diff .diff-del { background: var(--bs-danger-bg-subtle); text-decoration: line-through; }
.revision-diff .diff-same { color: var(--bs-secondary-color); }
.revision-diff .diff-skip { color: var(--bs-secondary-color); font-style: italic; }

/* Schémas PlantUML (SVG affichés en image) */
.article-content figure.diagram {
    margin: 1.5rem 0;
    text-align: center;
}

.article-content figure.diagram img {
    max-width: 100%;
    height: auto;
}

.article-content figure.diagram-error figcaption {
    padding: .5rem .75rem;
    border: 1px dashed var(--bs-danger-border-subtle);
    color: var(--bs-danger-text-emphasis);
}

/* Panneau de l'éditeur */
.editor-thumb {
    width: 3rem;
    height: 2.25rem;
    object-fit: cover;
    background: var(--bs-tertiary-bg);
}

.editor-list {
    max-height: 14rem;
    overflow-y: auto;
}

.print-only {
    display: none;
}

/*
 * Impression (et « Enregistrer en PDF ») : seul l'article est imprimé. Titres jamais isolés en
 * bas de page ; images, schémas, tableaux, blocs de code et citations non coupés entre deux pages
 * (une image ou un schéma plus haut qu'une page est réduit pour y tenir).
 */
@media print {
    @page {
        size: A4;
        margin: 18mm 16mm 20mm;
    }

    body {
        display: block;
        min-height: 0;
        font-size: 11pt;
        line-height: 1.45;
        color: #000;
        background: #fff;
    }

    header, footer, #commentaires, .d-print-none {
        display: none !important;
    }

    main.container {
        max-width: none;
        padding: 0;
    }

    .print-only {
        display: block;
    }

    h1, h2, h3, h4, h5, h6 {
        break-after: avoid-page;
        break-inside: avoid;
    }

    p, li, dd {
        orphans: 3;
        widows: 3;
    }

    .article-content img, .article-cover, figure, pre, blockquote, table, .attachments, .lead, .hero {
        break-inside: avoid;
    }

    /* Bandeau imprimé : l'image, puis le titre et le chapeau en noir dessous (encre, lisibilité). */
    .hero {
        display: block;
        min-height: 0;
        background: none;
        color: #000;
        border-radius: 0;
    }

    .hero-image {
        position: static;
        display: block;
        width: 100%;
        height: auto;
        max-height: 90mm;
    }

    .hero-has-text::after {
        display: none;
    }

    .hero-text {
        max-width: none;
        padding: 4mm 0 0;
        text-shadow: none;
        text-align: start;
    }

    tr, thead {
        break-inside: avoid;
    }

    thead {
        display: table-header-group;
    }

    .article-content img, .article-content figure.diagram img {
        max-width: 100%;
        max-height: 230mm;
        object-fit: contain;
    }

    .article-cover img {
        max-height: 90mm;
        width: auto;
    }

    pre {
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        border: 1px solid #999;
    }

    .article-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 85%;
        overflow-wrap: anywhere;
    }

    a {
        color: #000;
    }
}

/* Logo du site, en tête du bandeau (image réduite à 64 px de haut, affichée à 32 px). */
.site-logo {
    height: 2rem;
    width: auto;
    max-width: 12rem;
}
