/* =================================================================
   LE LIVRE DE BLUE — feuille de style
   Un livre-objet posé dans une lumière chaude et tamisée.
   Couverture toilée profonde · pages papier crème · accent glacier.
   ================================================================= */

:root {
    --ink:        #1b1815;
    --paper:      #f6efe1;   /* papier des pages */
    --paper-warm: #efe6d4;
    --cloth:      #20424a;   /* toile de couverture (teal profond) */
    --cloth-2:    #15333a;
    --sand:       #c8b193;
    --sand-deep:  #a98b63;
    --glacier:    #9cc3d4;   /* l'œil — accent */
    --glacier-dp: #4e7d91;
    --gold:       #cdb079;   /* dorure discrète de couverture */
    --text:       #2a2520;
    --muted:      #837868;
    --line:       #ddd0bb;

    --display: "Fraunces", Georgia, serif;
    --body: "Inter", system-ui, -apple-system, sans-serif;
    --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--body);
    color: var(--text);
    /* La "table" : lumière chaude et vignette */
    background:
        radial-gradient(120% 80% at 50% -10%, #3a342c 0%, transparent 55%),
        radial-gradient(140% 120% at 50% 120%, #14110d 0%, transparent 60%),
        linear-gradient(160deg, #2a251f, #1a1611);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.iris {
    display: inline-block;
    width: .7em; height: .7em;
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 50%, #14110d 0 22%, transparent 23%),
        radial-gradient(circle at 38% 36%, #fff 0 14%, transparent 15%),
        radial-gradient(circle at 50% 50%, var(--glacier) 0 60%, var(--glacier-dp) 100%);
    vertical-align: middle;
}
.iris.big { width: 46px; height: 46px; }

/* ---------- Accueil / présentation (hero) ---------- */
.hero {
    position: relative; min-height: 100svh;
    display: flex; flex-direction: column; justify-content: flex-end;
    overflow: hidden; background: var(--ink);
}
.hero-media {
    position: absolute; inset: 0;
    background-size: cover; background-position: center 30%;
    transform: scale(1.12); transition: transform .25s ease-out, opacity 1s var(--ease);
    will-change: transform;
}
.hero-media2 { opacity: 0; }
.hero-3d { position: absolute; inset: 0; width: 100%; height: 100%; background: transparent; }
.hero-media--empty {
    background:
        radial-gradient(120% 90% at 70% 10%, #2a525c, transparent 60%),
        linear-gradient(160deg, #20424a, #15333a);
    animation: none; transform: none;
}
@keyframes heroZoom { to { transform: scale(1); } }
.hero-veil {
    position: absolute; inset: 0;
    background: linear-gradient(to top,
        rgba(18,14,10,.93) 0%, rgba(18,14,10,.3) 45%,
        rgba(18,14,10,.12) 70%, rgba(18,14,10,.42) 100%);
}
.hero-topbar {
    position: absolute; top: 0; left: 0; right: 0; z-index: 3;
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(1rem + env(safe-area-inset-top)) clamp(1rem, 4vw, 2.4rem) 1rem;
    color: #f3ead9;
}
.hero-topbar .brand {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: var(--display); font-size: 1.15rem; font-weight: 600;
}
.hero-topbar .admin-link {
    font-size: .8rem; letter-spacing: .04em; text-decoration: none;
    color: rgba(243,234,217,.75);
    border: 1px solid rgba(243,234,217,.25);
    padding: .35rem .8rem; border-radius: 999px;
    transition: all .2s var(--ease);
}
.hero-topbar .admin-link:hover { color: #f3ead9; border-color: var(--glacier); }
.hero-in {
    position: relative; z-index: 2;
    width: min(1100px, 90vw); margin: 0 auto;
    padding: 0 0 13svh; color: #f6efe3;
}
.hero-in .eyebrow {
    display: inline-flex; align-items: center; gap: .55rem; margin: 0 0 .8rem;
    font-size: .8rem; letter-spacing: .3em; text-transform: uppercase; color: var(--glacier);
    opacity: 0; animation: heroRise .9s var(--ease) .3s forwards;
}
.hero-in h1 {
    margin: 0; font-family: var(--display); font-weight: 500;
    font-size: clamp(5rem, 24vw, 15rem); line-height: .84; letter-spacing: -.02em; color: #fbf6ec;
    opacity: 0; animation: heroRise 1s var(--ease) .45s forwards;
}
.hero-intro {
    max-width: 34ch; margin: 1.3rem 0 0;
    font-size: clamp(1rem, 1.4vw, 1.18rem); line-height: 1.6; color: rgba(246,239,227,.82);
    opacity: 0; animation: heroRise 1s var(--ease) .62s forwards;
}
@keyframes heroRise { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: translateY(0); } }
.cue {
    position: absolute; left: 50%; bottom: calc(3svh + env(safe-area-inset-bottom));
    transform: translateX(-50%); z-index: 2;
    opacity: 0; animation: heroRise 1s var(--ease) 1s forwards;
}
.cue span { display: block; width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--glacier); position: relative; }
.cue span::after {
    content: ""; position: absolute; left: 50%; top: 38%; width: 7px; height: 7px;
    border-right: 1.5px solid var(--glacier); border-bottom: 1.5px solid var(--glacier);
    transform: translateX(-50%) rotate(45deg); animation: cueBob 1.8s ease-in-out infinite;
}
@keyframes cueBob { 0%,100% { top: 34%; opacity: .5; } 50% { top: 46%; opacity: 1; } }

/* ---------- Barre haute discrète ---------- */
.topbar-mini {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem clamp(1rem, 4vw, 2.4rem);
    color: #efe6d4;
}
.topbar-mini .brand {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: var(--display); font-size: 1.15rem; font-weight: 600;
    letter-spacing: .01em;
}
.topbar-mini .admin-link {
    font-size: .82rem; letter-spacing: .04em;
    color: rgba(239,230,212,.6); text-decoration: none;
    border: 1px solid rgba(239,230,212,.2);
    padding: .35rem .8rem; border-radius: 999px;
    transition: all .2s var(--ease);
}
.topbar-mini .admin-link:hover { color: #efe6d4; border-color: rgba(156,195,212,.6); }

/* ---------- Scène ---------- */
.scene {
    display: flex; flex-direction: column; align-items: center;
    padding: clamp(1rem, 3vw, 2rem) 1rem 4rem;
}
.scene-title {
    text-align: center; margin-bottom: clamp(1.6rem, 4vw, 2.8rem);
    display: flex; flex-direction: column; align-items: center; gap: .35rem;
}
.scene-title .eyebrow {
    display: inline-flex; align-items: center; gap: .5rem; margin: 0;
    font-size: .76rem; letter-spacing: .34em; text-transform: uppercase;
    color: var(--glacier);
}
.scene-title h1, .scene-title h2 {
    margin: .1rem 0 0;
    font-family: var(--display); font-weight: 500;
    font-size: clamp(2.1rem, 6.5vw, 3.4rem); line-height: 1.04;
    color: #f7f0e2; letter-spacing: -.01em;
    text-shadow: 0 2px 30px rgba(0,0,0,.4);
}
.scene-title::after {
    content: ""; width: 64px; height: 1px; margin-top: 1.1rem;
    background: linear-gradient(to right, transparent, var(--gold), transparent);
}
.scene-empty {
    color: rgba(239,230,212,.75);
    font-family: var(--display); font-style: italic; font-size: 1.2rem;
    text-align: center; max-width: 30ch; margin-top: 3rem;
}

/* ---------- Le livre ---------- */
.book-wrap {
    width: min(880px, 94vw);
    perspective: 2200px;
}
.book {
    width: 100%;
    margin: 0 auto;
    /* StPageFlip gère la hauteur. Ombre portée du livre sur la table. */
    filter: drop-shadow(0 40px 60px rgba(0,0,0,.55));
}

/* Pages (communes) */
.page { background: var(--paper); overflow: hidden; }
.page--paper {
    background:
        radial-gradient(120% 100% at 0% 0%, rgba(0,0,0,.05), transparent 40%),
        var(--paper);
}
/* fine ombre de reliure côté gauche */
.page--paper::before {
    content: ""; position: absolute; inset: 0 auto 0 0; width: 26px;
    background: linear-gradient(to right, rgba(40,30,18,.16), transparent);
    pointer-events: none;
}
.paper-inner {
    position: relative;
    height: 100%;
    padding: clamp(1.1rem, 3.4vw, 2.2rem);
    display: flex; flex-direction: column; justify-content: center;
}
.paper-inner.center { align-items: center; text-align: center; }

/* ---------- Couverture toilée ---------- */
.page--cover {
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 2px, transparent 2px 4px),
        radial-gradient(120% 120% at 30% 20%, #2a525c, transparent 60%),
        linear-gradient(160deg, var(--cloth), var(--cloth-2));
    color: #f3ead9;
}
.cover-inner {
    height: 100%;
    padding: clamp(1.4rem, 4vw, 2.6rem);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    border: 1px solid rgba(205,176,121,.28);
    margin: clamp(.7rem, 2vw, 1.2rem);
    border-radius: 3px;
}
.cover-rule { width: 54px; height: 1px; background: var(--gold); opacity: .8; margin: .2rem 0; }
.cover-eyebrow {
    margin: 1.2rem 0 .4rem;
    font-size: .72rem; letter-spacing: .34em; text-transform: uppercase;
    color: var(--glacier);
}
.cover-title {
    margin: 0 0 1.2rem;
    font-family: var(--display); font-weight: 500;
    font-size: clamp(3rem, 11vw, 5.5rem); line-height: .9;
    color: #f6eeda;
    text-shadow: 0 1px 0 rgba(205,176,121,.25);
}
.cover-photo {
    width: clamp(120px, 42%, 210px); aspect-ratio: 1;
    border: 3px solid rgba(246,238,218,.9);
    border-radius: 2px; overflow: hidden;
    box-shadow: 0 14px 30px -12px rgba(0,0,0,.6);
    margin: .4rem 0 1.4rem;
}
.cover-photo img { width: 100%; height: 100%; object-fit: cover; }
.cover-iris { margin: 1rem 0 1.6rem; }
.cover-year {
    margin: 0; font-family: var(--display); font-style: italic;
    font-size: 1.05rem; color: var(--gold);
}
.page--back .back-year { margin-top: 1rem; color: var(--glacier); font-family: var(--display); font-style: italic; }

/* ---------- Frontispice & fin ---------- */
.paw { font-size: 1.7rem; }
.front-name {
    font-family: var(--display); font-weight: 500;
    font-size: clamp(2.4rem, 8vw, 3.6rem); margin: .4rem 0 .8rem;
    color: var(--ink);
}
.front-intro {
    max-width: 34ch; margin: 0 auto 1.4rem;
    font-size: 1rem; line-height: 1.65; color: var(--muted);
}
.front-meta, .end-sub {
    font-family: var(--display); font-style: italic;
    color: var(--glacier-dp);
}
.end-line {
    font-family: var(--display); font-size: 1.6rem; margin: .8rem 0 .2rem; color: var(--ink);
}
.end-sub { font-size: 1.15rem; margin: 0; }

/* ---------- Planche photo ---------- */
.plate { margin: 0; display: flex; flex-direction: column; height: 100%; justify-content: center; }
.mat {
    position: relative;
    background: #fff;
    padding: clamp(8px, 1.6vw, 14px);
    border: 1px solid #eadfca;
    box-shadow: 0 10px 26px -14px rgba(40,30,18,.5);
    border-radius: 2px;
    max-height: 78%;
    display: flex;
}
.mat img, .mat video {
    width: 100%; height: 100%; max-height: 60vh;
    object-fit: cover; display: block;
    border-radius: 1px;
}
.plate figcaption {
    margin-top: clamp(.7rem, 2vw, 1.1rem);
    text-align: center;
}
.plate .cap {
    display: block; font-size: .98rem; color: var(--ink); font-weight: 500;
}
.plate .cap-date {
    display: block; margin-top: .15rem;
    font-family: var(--display); font-style: italic; font-size: .9rem;
    color: var(--glacier-dp);
}

/* bouton zoom + lecture */
.zoom {
    position: absolute; top: 14px; right: 14px;
    width: 30px; height: 30px; border-radius: 50%;
    background: rgba(20,17,13,.55); color: #f6eeda;
    display: grid; place-items: center; font-size: .85rem;
    opacity: 0; transition: opacity .25s var(--ease);
}
.mat:hover .zoom { opacity: 1; }
.play {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(20,17,13,.5); backdrop-filter: blur(5px);
    border: 1.5px solid rgba(156,195,212,.8);
    display: grid; place-items: center; pointer-events: none;
}
.play svg { width: 22px; height: 22px; fill: #f6eeda; margin-left: 2px; }

.folio {
    position: absolute; bottom: clamp(.7rem, 2vw, 1.2rem); right: clamp(1rem, 3vw, 1.8rem);
    font-family: var(--display); font-style: italic; font-size: .85rem;
    color: var(--sand-deep);
}

/* ---------- Contrôles ---------- */
.book-controls {
    display: flex; align-items: center; gap: 1.4rem;
    margin-top: clamp(1.4rem, 4vw, 2.2rem);
}
.nav-btn {
    width: 50px; height: 50px; border-radius: 50%;
    background: rgba(246,238,218,.06);
    border: 1px solid rgba(156,195,212,.4);
    color: #f3ead9; font-size: 1.7rem; line-height: 0;
    cursor: pointer; transition: all .2s var(--ease);
}
.nav-btn:hover { background: var(--glacier-dp); border-color: var(--glacier); }
.page-count {
    font-family: var(--display); font-style: italic;
    color: rgba(243,234,217,.85); min-width: 6ch; text-align: center;
}
.book-hint {
    margin-top: 1rem; font-size: .8rem; letter-spacing: .03em;
    color: rgba(239,230,212,.45);
}

/* ---------- Repli si la librairie ne charge pas ---------- */
.book.no-flip {
    filter: none;
    display: grid; gap: 26px;
    max-width: 560px;
}
.book.no-flip .page {
    position: relative; border-radius: 8px;
    min-height: 420px;
    box-shadow: 0 24px 50px -24px rgba(0,0,0,.6);
}
.book.no-flip .page--cover { min-height: 520px; }
.no-flip ~ .book-controls, .no-flip ~ .book-hint { display: none; }

/* ---------- Plein écran (lightbox) ---------- */
.lightbox {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(12,9,7,.97); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    display: none; align-items: center; justify-content: center;
    opacity: 0; transition: opacity .3s var(--ease);
}
.lightbox.open { display: flex; opacity: 1; }
.lb-stage { width: 100%; height: 100%; display: grid; place-items: center; }
.lb-stage img, .lb-stage video {
    max-width: 100vw; max-height: 100dvh;
    width: auto; height: auto; object-fit: contain;
    animation: pop .35s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.lb-bar {
    position: absolute; left: 0; right: 0; bottom: 0;
    padding: 1.2rem 1.4rem calc(1.4rem + env(safe-area-inset-bottom));
    text-align: center;
    background: linear-gradient(to top, rgba(12,9,7,.7), transparent);
}
.lb-caption { margin: 0; color: #f6eeda; font-family: var(--display); font-style: italic; }
.lb-close {
    position: absolute; z-index: 2;
    top: calc(.9rem + env(safe-area-inset-top)); right: .9rem;
    width: 46px; height: 46px; border-radius: 50%;
    background: rgba(255,255,255,.08); border: 1px solid rgba(156,195,212,.4);
    color: #f6eeda; font-size: 1.2rem; cursor: pointer;
    transition: all .2s var(--ease);
}
.lb-close:hover { background: var(--glacier-dp); border-color: var(--glacier); }

:focus-visible { outline: 2px solid var(--glacier); outline-offset: 3px; }

@media (max-width: 560px) {
    .scene-title h1, .scene-title h2 { font-size: 2.1rem; }
    .mat img, .mat video { max-height: 52vh; }
}

/* ---------- Thème de couverture : bleu glacier ---------- */
body.theme-bleu .page--cover {
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,.02) 0 2px, transparent 2px 4px),
        radial-gradient(120% 120% at 30% 20%, #2f5e73, transparent 60%),
        linear-gradient(160deg, #244b63, #15303f);
}
body.theme-bleu .hero-media--empty {
    background:
        radial-gradient(120% 90% at 70% 10%, #2f5e73, transparent 60%),
        linear-gradient(160deg, #244b63, #15303f);
}

/* ---------- Page chapitre ---------- */
.page--chapter .paper-inner { gap: .9rem; }
.page--chapter .iris { transform: scale(1.5); }
.chap-label {
    margin: 0; font-family: var(--display); font-style: italic;
    font-size: clamp(1.7rem, 5.5vw, 2.6rem); color: var(--ink);
}
.page--chapter::after {
    content: ""; width: 46px; height: 1px; background: var(--sand-deep); opacity: .6;
    position: absolute; left: 50%; bottom: 22%; transform: translateX(-50%);
}

/* ---------- Page à propos ---------- */
.about-photo {
    width: clamp(96px, 30%, 150px); aspect-ratio: 1; margin: 0 auto 1.1rem;
    border-radius: 50%; overflow: hidden;
    border: 3px solid #fff; box-shadow: 0 10px 26px -12px rgba(40,30,18,.55);
}
.about-photo img { width: 100%; height: 100%; object-fit: cover; }
.about-kicker { margin: 0 0 .3rem; font-size: .72rem; letter-spacing: .3em; text-transform: uppercase; color: var(--glacier-dp); }
.about-name { margin: 0 0 1.3rem; font-family: var(--display); font-weight: 500; font-size: clamp(2rem, 7vw, 3rem); color: var(--ink); }
.about-facts { list-style: none; padding: 0; margin: 0 0 1.3rem; width: min(330px, 84%); }
.about-facts li { display: flex; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.about-facts span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.about-facts strong { font-family: var(--display); font-weight: 500; color: var(--ink); }
.about-text { max-width: 34ch; margin: 0; color: var(--muted); line-height: 1.6; font-size: .98rem; }

/* ---------- Fondu « blur-up » des photos (auto-complétant) ---------- */
.js .bup { animation: bupIn .8s var(--ease) both; }
@keyframes bupIn {
    from { opacity: 0; filter: blur(14px); transform: scale(1.03); }
    to   { opacity: 1; filter: none; transform: none; }
}

/* ---------- Boutons son & PDF ---------- */
.icon-btn {
    width: 50px; height: 50px; border-radius: 50%;
    background: rgba(246,238,218,.06); border: 1px solid rgba(156,195,212,.4);
    color: #f3ead9; font-size: 1.1rem; cursor: pointer; transition: all .2s var(--ease);
}
.icon-btn:hover { background: var(--glacier-dp); border-color: var(--glacier); }
.icon-btn.on { background: var(--glacier-dp); border-color: var(--glacier); color: #fff; }
.icon-btn.off { opacity: .4; }
.pdf-btn {
    display: inline-block; margin-top: 1.3rem;
    color: rgba(243,234,217,.85); text-decoration: none; font-size: .85rem; letter-spacing: .02em;
    border: 1px solid rgba(156,195,212,.35); padding: .6rem 1.2rem; border-radius: 999px;
    transition: all .2s var(--ease);
}
.pdf-btn:hover { color: #f3ead9; border-color: var(--glacier); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ===================== Finitions : relief, partage, thèmes ===================== */
.hero-actions { display: inline-flex; align-items: center; gap: .7rem; }
.hero-btn {
    font-family: var(--body); font-size: .8rem; letter-spacing: .04em;
    color: rgba(243,234,217,.85); background: transparent;
    border: 1px solid rgba(243,234,217,.25); padding: .35rem .85rem; border-radius: 999px;
    cursor: pointer; transition: all .2s var(--ease);
}
.hero-btn:hover { color: #f3ead9; border-color: var(--glacier); }

.tilt-btn {
    position: absolute; left: 50%; bottom: calc(7svh + env(safe-area-inset-bottom));
    transform: translateX(-50%); z-index: 3;
    display: none; align-items: center; gap: .4rem;
    font-family: var(--body); font-size: .76rem; letter-spacing: .04em;
    color: rgba(243,234,217,.92); background: rgba(20,17,13,.45);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border: 1px solid rgba(156,195,212,.5); padding: .45rem 1rem; border-radius: 999px; cursor: pointer;
}

/* Modale de partage */
.share-modal {
    position: fixed; inset: 0; z-index: 120; padding: 1.5rem;
    background: rgba(12,9,7,.9); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    display: none; align-items: center; justify-content: center;
}
.share-modal.open { display: flex; }
.share-card {
    position: relative; width: min(340px, 100%); text-align: center;
    background: #f6efe1; color: var(--ink); border-radius: 16px; padding: 1.7rem 1.6rem;
    box-shadow: 0 30px 70px -20px rgba(0,0,0,.6);
}
.share-title { font-family: var(--display); font-weight: 500; font-size: 1.25rem; margin: 0 0 1rem; }
.qr { display: flex; justify-content: center; margin: 0 auto .9rem; min-height: 184px; align-items: center; }
.qr img, .qr canvas { border-radius: 8px; }
.share-url { font-size: .76rem; color: var(--muted); word-break: break-all; margin: 0 0 1rem; }
.share-copy { width: 100%; padding: .75rem; border: 0; border-radius: 10px; background: var(--glacier-dp); color: #fff; font: inherit; font-weight: 500; cursor: pointer; }
.share-copy:hover { background: #456c7d; }
.share-x { position: absolute; top: .7rem; right: .7rem; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; }

/* Thème de couverture : noir charbon */
body.theme-noir .page--cover {
    background:
        repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 2px, transparent 2px 4px),
        radial-gradient(120% 120% at 30% 20%, #34343a, transparent 60%),
        linear-gradient(160deg, #232227, #121214);
}
body.theme-noir .hero-media--empty {
    background: radial-gradient(120% 90% at 70% 10%, #34343a, transparent 60%), linear-gradient(160deg, #232227, #121214);
}
