/* ==========================================================================
   Thème Steampunk — surcharge de learn2
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=IM+Fell+English:ital@0;1&family=Special+Elite&display=swap');

:root {
    --parchemin: #f3e9d2;
    --parchemin-clair: #faf4e4;
    --sepia: #3b2a1a;
    --sepia-doux: #6b5235;
    --laiton: #b5833a;
    --laiton-clair: #e0b66a;
    --laiton-fonce: #7a5520;
    --cuivre: #b87333;
    --vert-de-gris: #4a7c6f;
}

/* --- 1. Palette ---------------------------------------------------------- */

body,
#body {
    background: var(--parchemin);
    color: var(--sepia);
}

#body {
    background: radial-gradient(ellipse at center, var(--parchemin-clair) 0%, var(--parchemin) 60%, #e8d9b5 100%) fixed;
}

a {
    color: var(--cuivre);
}
a:hover,
a:focus {
    color: var(--vert-de-gris);
}

#top-bar {
    background: rgba(181, 131, 58, 0.12);
    border: 1px solid rgba(181, 131, 58, 0.35);
}

/* En-tête de la barre latérale (bleu d'origine) */
#header {
    background: linear-gradient(180deg, var(--laiton-clair) 0%, var(--laiton) 55%, var(--laiton-fonce) 100%);
}
#sidebar ul li.visited > a .read-icon,
#body a.anchor-link:hover {
    color: var(--laiton);
}

.button,
.page-title,
.bullet-icon {
    background: var(--laiton);
}
.button {
    box-shadow: 0 3px 0 var(--laiton-fonce);
}
.button:hover {
    background: var(--laiton-fonce);
}

hr {
    border-bottom: 2px solid var(--laiton);
}

blockquote {
    border-left: 6px solid var(--laiton);
}
blockquote p {
    color: var(--sepia-doux);
    font-style: italic;
}

/* --- 2. Typographie ------------------------------------------------------ */

body {
    font-family: 'IM Fell English', 'Libre Baskerville', Georgia, serif;
    font-size: 1.05rem;
    letter-spacing: 0;
}

h1, h2, h3, h4, h5, h6,
#chapter h3 {
    font-family: 'Cinzel', 'Times New Roman', serif;
    color: var(--sepia);
    letter-spacing: 0.04em;
}

#chapter p {
    font-family: 'IM Fell English', Georgia, serif;
}

#body #breadcrumbs {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 0.95rem;
}

/* --- 3. Ornements -------------------------------------------------------- */

/* Titre de page : double filet de laiton */
#body-inner h1 {
    font-weight: 700;
    padding-bottom: 0.4em;
    border-bottom: 4px double var(--laiton);
}

/* Années : filet doré terminé par un engrenage de chaque côté */
#body-inner h3 {
    display: flex;
    align-items: center;
    gap: 0.6em;
    margin-top: 2.5rem;
    font-weight: 700;
}
#body-inner h3::before,
#body-inner h3::after {
    content: '\f013'; /* fa-cog */
    font-family: FontAwesome;
    font-weight: normal;
    flex: 1;
    display: flex;
    align-items: center;
    color: var(--laiton);
    background: linear-gradient(var(--laiton), var(--laiton)) center / 100% 2px no-repeat;
}
#body-inner h3::before {
    justify-content: flex-end;
}

/* Mois : petite plaque de laiton rivetée */
#body-inner h4,
#body-inner h5 {
    display: inline-block;
    margin: 1.5rem 0 0.5rem;
    padding: 0.25em 1.1em;
    font-size: 1rem;
    font-weight: 700;
    color: var(--sepia);
    border: 1px solid var(--laiton-fonce);
    border-radius: 3px;
    background:
        radial-gradient(circle, var(--laiton-fonce) 0 2px, transparent 2.5px) 4px 4px / 8px 8px no-repeat,
        radial-gradient(circle, var(--laiton-fonce) 0 2px, transparent 2.5px) calc(100% - 4px) 4px / 8px 8px no-repeat,
        radial-gradient(circle, var(--laiton-fonce) 0 2px, transparent 2.5px) 4px calc(100% - 4px) / 8px 8px no-repeat,
        radial-gradient(circle, var(--laiton-fonce) 0 2px, transparent 2.5px) calc(100% - 4px) calc(100% - 4px) / 8px 8px no-repeat,
        linear-gradient(180deg, var(--laiton-clair) 0%, var(--laiton) 60%, #9a6b2c 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 2px 3px rgba(59, 42, 26, 0.3);
}

/* Listes : engrenages en guise de puces */
#body-inner ul {
    list-style: none;
    padding-left: 1.6em;
}
#body-inner ul li {
    position: relative;
}
#body-inner ul li::before {
    content: '\f013'; /* fa-cog */
    font-family: FontAwesome;
    position: absolute;
    left: -1.4em;
    color: var(--laiton);
}

/* Photos : cadre de laiton */
#body-inner img {
    border: 3px solid var(--laiton);
    padding: 4px;
    background: var(--parchemin-clair);
    box-shadow: 0 0 0 1px var(--laiton-fonce), 0 6px 14px rgba(59, 42, 26, 0.35);
}

/* Liens du contenu : soulignement qui se dessine comme un trait de plume.
   Au repos, un filet cuivré discret ; au survol, un trait d'encre effilé
   (plus épais au centre) se trace de gauche à droite. */
#body-inner a:not(:has(img)):not(.anchor-link) {
    padding-bottom: 2px;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 6' preserveAspectRatio='none'%3E%3Cpath d='M0 4.2 Q25 2.4 50 3 T100 2.6 L100 3.1 Q75 4.7 50 4.5 Q25 4.9 0 4.5 Z' fill='%234a7c6f'/%3E%3C/svg%3E"),
        linear-gradient(rgba(184, 115, 51, 0.35), rgba(184, 115, 51, 0.35));
    background-repeat: no-repeat;
    background-position: left bottom, left calc(100% - 2px);
    background-size: 0% 0.4em, 100% 1px;
    transition: background-size 0.45s ease-out;
}
#body-inner a:not(:has(img)):not(.anchor-link):hover,
#body-inner a:not(:has(img)):not(.anchor-link):focus-visible {
    background-size: 100% 0.4em, 100% 1px;
}

@media (prefers-reduced-motion: reduce) {
    #body-inner a:not(:has(img)):not(.anchor-link) {
        transition: none;
    }
}

/* Bandeau d'en-tête (hero_image de la page) en tons sépia, cadre de laiton */
.hero-sepia {
    position: relative;
    height: 220px;
    margin: 0 0 2.5rem;
    background-size: cover;
    background-position: center;
    border: 3px solid var(--laiton);
    box-shadow: 0 0 0 1px var(--laiton-fonce), 0 6px 14px rgba(59, 42, 26, 0.35);
    filter: sepia(0.85) contrast(1.05) brightness(0.95);
}
/* Vignettage façon vieille photographie */
.hero-sepia::after {
    content: '';
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 60px rgba(40, 25, 10, 0.7);
    pointer-events: none;
}
@media only all and (max-width: 47.938em) {
    .hero-sepia {
        height: 140px;
    }
}

/* --- 4. Barre latérale en cuir ------------------------------------------- */

#sidebar {
    background-color: #4a2e1c;
    background-image:
        radial-gradient(rgba(0, 0, 0, 0.18) 1px, transparent 1.5px),
        radial-gradient(rgba(255, 220, 170, 0.05) 1px, transparent 1.5px),
        radial-gradient(ellipse at 30% 20%, rgba(140, 90, 50, 0.45) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(20, 10, 5, 0.5) 0%, transparent 65%),
        linear-gradient(180deg, #5a3823 0%, #43291a 50%, #2f1d12 100%);
    background-size: 5px 5px, 7px 7px, 100% 100%, 100% 100%, 100% 100%;
    background-position: 0 0, 2px 3px, 0 0, 0 0, 0 0;
    border-right: 3px solid var(--laiton-fonce);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.6), 2px 0 8px rgba(59, 42, 26, 0.5);
}

/* Couture le long du bord droit */
#sidebar::after {
    content: '';
    position: absolute;
    top: 8px;
    bottom: 8px;
    right: 7px;
    border-right: 2px dashed rgba(224, 182, 106, 0.45);
    pointer-events: none;
}

#sidebar a {
    color: #e3cfa4;
}
#sidebar a:hover {
    color: var(--laiton-clair);
    text-shadow: 0 0 6px rgba(255, 170, 60, 0.6);
}
#sidebar a.subtitle {
    color: rgba(227, 207, 164, 0.6);
}

#sidebar ul.topics > li > a {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 1rem;
    letter-spacing: 0.03em;
}

#sidebar ul.topics > li.parent,
#sidebar ul.topics > li.active {
    background: rgba(0, 0, 0, 0.25);
}

/* Menu actif : lueur de filament d'ampoule Edison */
#sidebar ul li.active > a {
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.15));
    border-left: 3px solid var(--laiton-clair);
    color: #ffcf7a !important;
    text-shadow: 0 0 4px #ff9a2e, 0 0 10px rgba(255, 140, 30, 0.6);
}

#sidebar hr {
    border-bottom: 1px solid rgba(224, 182, 106, 0.25);
}

/* Recherche : encart de cuir sombre dans l'en-tête de laiton */
.searchbox {
    background: rgba(43, 29, 20, 0.75);
    border: 1px solid var(--laiton-fonce);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}
.searchbox input,
.searchbox label {
    color: #e3cfa4;
}

/* Ascenseur de la barre latérale */
.scrollbar-inner > .scroll-element .scroll-element_track {
    background-color: rgba(0, 0, 0, 0.25);
}
.scrollbar-inner > .scroll-element .scroll-bar,
.scrollbar-inner > .scroll-element:hover .scroll-bar,
.scrollbar-inner > .scroll-element.scroll-draggable .scroll-bar {
    background-color: var(--laiton);
}

/* --- 5. Bouton "remonter en haut" : engrenage animé ---------------------- */
#back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1000;
    font-size: 26px; /* l'engrenage (fa-stack-2x) mesure 2em, soit 52px */
    text-decoration: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, filter 0.2s;
}
#back-to-top.visible {
    opacity: 0.9;
    visibility: visible;
}
#back-to-top:hover {
    opacity: 1;
    filter: brightness(1.15);
}

/* Engrenage en laiton (dégradé appliqué au glyphe) */
#back-to-top .fa-cog {
    background: radial-gradient(circle at 35% 30%, var(--laiton-clair), var(--laiton) 55%, var(--laiton-fonce));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 3px rgba(59, 42, 26, 0.5));
}
/* Flèche au centre, détourée de parchemin pour rester lisible */
#back-to-top .fa-arrow-up {
    font-size: 0.6em;
    line-height: 3.33em; /* recentre la flèche réduite dans le fa-stack (2em / 0.6) */
    color: var(--sepia);
    text-shadow: 0 0 2px var(--parchemin-clair), 0 0 4px var(--parchemin-clair);
}

/* Rotation lente au survol, rapide pendant la remontée */
@keyframes engrenage {
    to { transform: rotate(360deg); }
}
#back-to-top:hover .fa-cog {
    animation: engrenage 4s linear infinite;
}
#back-to-top.spinning .fa-cog {
    animation: engrenage 0.8s linear infinite;
}

@media (prefers-reduced-motion: reduce) {
    #back-to-top:hover .fa-cog,
    #back-to-top.spinning .fa-cog {
        animation: none;
    }
}

/* --- Fenêtre photo (js/lightbox.js) -------------------------------------- */

#body-inner.lightbox-actif img {
    cursor: zoom-in;
}

html.lightbox-open {
    overflow: hidden;
}

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 1rem 1rem;
    background: radial-gradient(ellipse at center, rgba(59, 42, 26, 0.92), rgba(20, 13, 6, 0.97));
    cursor: zoom-out;
}

.lightbox[hidden] {
    display: none;
}

/* Photo dans un cadre de laiton, comme un daguerréotype */
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border: 6px solid var(--laiton);
    outline: 1px solid var(--laiton-fonce);
    box-shadow: 0 0 0 3px var(--laiton-fonce), 0 0 30px rgba(224, 182, 106, 0.35);
    background: var(--sepia);
    cursor: default;
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    padding: 0;
    border: 2px solid var(--laiton-fonce);
    background: radial-gradient(circle at 35% 35%, var(--laiton-clair), var(--laiton) 55%, var(--laiton-fonce));
    color: var(--sepia);
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.lightbox-close {
    top: 0.75rem;
    right: 0.75rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 22px;
}

.lightbox-nav {
    top: 50%;
    width: 48px;
    height: 64px;
    margin-top: -32px;
    border-radius: 6px;
    font-size: 24px;
}

.lightbox-prev {
    left: 0.75rem;
}

.lightbox-next {
    right: 0.75rem;
}

.lightbox-nav[hidden],
.lightbox-counter[hidden] {
    display: none;
}

.lightbox-counter {
    position: absolute;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.2rem 0.8rem;
    border: 1px solid var(--laiton-fonce);
    border-radius: 3px;
    background: var(--parchemin);
    color: var(--sepia);
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

.lightbox-close:hover,
.lightbox-nav:hover {
    background: radial-gradient(circle at 35% 35%, var(--parchemin-clair), var(--laiton-clair) 55%, var(--laiton));
    box-shadow: 0 0 14px rgba(224, 182, 106, 0.8);
}

.lightbox-close:focus-visible,
.lightbox-nav:focus-visible {
    outline: 2px solid var(--parchemin-clair);
    outline-offset: 2px;
}

@media only all and (max-width: 47.938em) {
    /* Sur téléphone, les flèches passent en bas pour ne pas cacher la photo */
    .lightbox {
        padding-bottom: 5rem;
    }

    .lightbox-nav {
        top: auto;
        bottom: 0.75rem;
        margin-top: 0;
    }
}

/* --- Bas d'entrée : entrées voisines (templates/partials/entrees_voisines.html.twig) --- */

#body .voisins {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 3rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--laiton);
}

#body a.voisin {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    padding: 0.8rem 1.1rem;
    background: var(--parchemin-clair);
    border: 1px solid var(--laiton);
    border-radius: 4px;
    box-shadow: inset 0 0 18px rgba(181, 131, 58, 0.25), 2px 2px 8px rgba(59, 42, 26, 0.2);
    color: var(--sepia);
    text-decoration: none;
}

#body a.voisin-avant {
    grid-column: 1;
    border-left: 6px solid var(--laiton);
}

#body a.voisin-apres {
    grid-column: 2;
    text-align: right;
    border-right: 6px solid var(--laiton);
}

#body a.voisin:hover,
#body a.voisin:focus-visible {
    color: var(--sepia);
    border-color: var(--cuivre);
    box-shadow: inset 0 0 18px rgba(181, 131, 58, 0.35), 0 0 12px rgba(184, 115, 51, 0.45);
}

#body .voisin-sens {
    font-family: 'Special Elite', 'Courier New', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cuivre);
}

#body .voisin-titre {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 1.1rem;
    line-height: 1.3;
}

#body .voisin-rubrique {
    grid-column: 1 / -1;
    justify-self: center;
    font-family: 'Cinzel', 'Times New Roman', serif;
}

@media only all and (max-width: 47.938em) {
    #body .voisins {
        grid-template-columns: 1fr;
    }

    #body a.voisin-avant,
    #body a.voisin-apres {
        grid-column: 1;
    }
}
