/* ---------- Le livre ---------- */

.sv-page--book { max-width: none; width: min(100% - 2rem, 120rem); }

/* Sur ordinateur la page tient dans la fenêtre et ne défile pas : la molette tourne les pages */
@media (min-width: 48.01rem) {
    html:has([data-book]), html:has([data-book]) body { overflow: hidden; height: 100%; }
}

.sv-bookbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sv-space-xs);
    margin-bottom: var(--sv-space-sm);
}

.sv-bookbar__spacer { margin-right: auto; }

.sv-book {
    --sv-gutter: 4.6rem;
    --sv-sheet: linear-gradient(90deg, #f3e9d4 0%, #fbf6ea 5%, #fdf9ee 45%, #ede3cd 50%, #fdf9ee 55%, #fbf6ea 95%, #f3e9d4 100%);
    position: relative;
    width: min(100%, calc((100vh - 14rem) * 1.5));
    aspect-ratio: 3 / 2;
    margin: 0 auto;
}

/* Couverture cartonnée */
.sv-book__cover {
    position: absolute;
    inset: 0;
    padding: 0.85rem;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--sv-bordeaux), var(--sv-bordeaux-deep));
    box-shadow: 0 2px 4px rgba(59, 42, 32, 0.3), 0 28px 50px rgba(59, 42, 32, 0.32);
}

/* Les pages : papier, tranche et creux de la reliure */
.sv-book__paper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 3px;
    background: var(--sv-sheet);
    box-shadow: inset 0 0 0 1px rgba(59, 42, 32, 0.1);
}

.sv-book__paper::before,
.sv-book__paper::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0.55rem;
    z-index: 4;
    pointer-events: none;
    background: repeating-linear-gradient(90deg, rgba(59, 42, 32, 0.16) 0 1px, transparent 1px 3px);
}

.sv-book__paper::before { left: 0; }
.sv-book__paper::after { right: 0; transform: scaleX(-1); }

.sv-book__spine {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    z-index: 3;
    width: 4.4rem;
    margin-left: -2.2rem;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(59, 42, 32, 0.12) 42%, rgba(59, 42, 32, 0.26) 50%, rgba(59, 42, 32, 0.12) 58%, transparent);
}

.sv-book__clip {
    position: absolute;
    inset: 2.4rem calc(var(--sv-gutter) / 2) 2.4rem;
    overflow: hidden;
    container-type: size;
}

.sv-book__flow {
    height: 100%;
    column-count: 2;
    column-gap: var(--sv-gutter);
    column-fill: auto;
    color: var(--sv-ink);
    font-size: clamp(1.05rem, 3.4cqh, 1.6rem);
    transition: transform 0.75s cubic-bezier(0.65, 0.05, 0.25, 1);
}

.sv-book--resizing .sv-book__flow { transition: none; }

/* Feuilletage : un feuillet pleine page pivote en 3D autour de la reliure */
.sv-book--flipping .sv-book__flow { transition: none; }

.sv-book__stage {
    position: absolute;
    inset: 0.85rem;
    z-index: 7;
    perspective: 2600px;
    perspective-origin: 50% 40%;
    pointer-events: none;
}

.sv-book--flipping .sv-book__spine { visibility: hidden; }   /* le feuillet porte sa propre copie de l'ombre */

.sv-book__stage::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    z-index: 3;
    width: 4.4rem;
    margin-left: -2.2rem;
    pointer-events: none;
    background: linear-gradient(90deg, transparent, rgba(59, 42, 32, 0.12) 42%, rgba(59, 42, 32, 0.26) 50%, rgba(59, 42, 32, 0.12) 58%, transparent);
}

.sv-book__leaf { z-index: 2; }

.sv-book__under { position: absolute; top: 0; bottom: 0; width: 50%; overflow: hidden; background-image: var(--sv-sheet); }

.sv-book__ghostbox { position: absolute; overflow: hidden; }
.sv-book__flow--ghost { position: absolute; top: 0; left: 0; max-width: none; transition: none; }
.sv-book__flow--ghost .sv-titlepage,
.sv-book__flow--ghost .sv-descpage { height: var(--sv-ghost-height); }

.sv-book__leaf {
    position: absolute;
    top: 0;
    left: 50%;
    width: 50%;
    height: 100%;
    transform-origin: left center;
    transform-style: preserve-3d;
}

.sv-book__face {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background-image: var(--sv-sheet);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.sv-book__face--back { transform: rotateY(180deg); }

.sv-book__shade {
    position: absolute;
    inset: 0;
    opacity: 0;
    pointer-events: none;
    background: rgb(59, 42, 32);
}

.sv-book__shade--under { background: linear-gradient(90deg, rgb(59, 42, 32), rgba(59, 42, 32, 0.05)); }

/* Flèches */
.sv-book__nav {
    position: absolute;
    top: 50%;
    z-index: 6;
    width: 3rem;
    height: 3rem;
    margin-top: -1.5rem;
    border: 1px solid var(--sv-ink-faint);
    border-radius: 50%;
    background: var(--sv-paper);
    box-shadow: var(--sv-shadow-paper);
    cursor: pointer;
    transition: transform 0.25s var(--sv-ease), opacity 0.25s;
}

.sv-book__nav::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.7rem;
    height: 0.7rem;
    border-top: 2px solid var(--sv-bordeaux);
    border-right: 2px solid var(--sv-bordeaux);
}

.sv-book__nav--prev { left: -1.5rem; }
.sv-book__nav--prev::after { transform: translate(-30%, -50%) rotate(-135deg); }
.sv-book__nav--next { right: -1.5rem; }
.sv-book__nav--next::after { transform: translate(-70%, -50%) rotate(45deg); }
.sv-book__nav:hover:not(:disabled) { transform: scale(1.08); }
.sv-book__nav:disabled { opacity: 0.3; cursor: default; }

.sv-book__counter {
    margin: var(--sv-space-sm) 0 0;
    text-align: center;
    font-family: var(--sv-font-title);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--sv-ink-soft);
}

/* ---------- Première double page ---------- */

.sv-titlepage,
.sv-descpage {
    height: 98cqh;
    break-after: column;
    break-inside: avoid;
}

.sv-titlepage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    text-align: center;
}

.sv-titlepage__cover { width: 56%; margin: 0 0 0.8em; }
.sv-titlepage__cover .sv-photo__link { aspect-ratio: 4 / 3; }

.sv-titlepage__title {
    margin: 0;
    font-size: 2.6em;
    font-weight: 400;
    line-height: 1;
    text-wrap: balance;
}

.sv-titlepage__dates { margin: 0; font-family: var(--sv-font-hand); font-size: 1.25em; color: var(--sv-bordeaux); }
.sv-titlepage__place { margin: 0; font-family: var(--sv-font-title); font-size: 1.1em; font-style: italic; color: var(--sv-ink-soft); }
.sv-titlepage__faces { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.2em 0.1em; margin-top: 0.6em; }

.sv-descpage { display: flex; flex-direction: column; justify-content: center; gap: 1em; }

.sv-descpage__text {
    margin: 0;
    font-family: var(--sv-font-title);
    font-size: 1.05em;
    line-height: 1.55;
    text-wrap: pretty;
}

.sv-descpage__text:first-letter {
    float: left;
    padding: 0.05em 0.1em 0 0;
    font-size: 3.2em;
    line-height: 0.8;
    color: var(--sv-bordeaux);
}

.sv-descpage__text--empty { font-style: italic; color: var(--sv-ink-soft); }
.sv-descpage__text--empty:first-letter { all: unset; }

/* Dessins au trait posés dans le livre */
.sv-sketch {
    fill: none;
    stroke: var(--sv-ink-soft);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.55;
}

.sv-descpage__doodle { width: 62%; align-self: center; margin-top: auto; }

/* ---------- Notes ---------- */

.sv-note { margin-bottom: 1.9em; }

.sv-note__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1em 0.45em;
    margin-bottom: 0.3em;
    break-after: avoid;
    break-inside: avoid;
}

.sv-note__author { font-family: var(--sv-font-hand); font-size: 1.15em; font-weight: 700; color: var(--sv-bordeaux); }
.sv-note__date { font-family: var(--sv-font-title); font-size: 0.8em; font-style: italic; color: var(--sv-ink-soft); }
.sv-note__place { font-family: var(--sv-font-title); font-size: 0.8em; font-style: italic; color: var(--sv-ink-soft); }
.sv-note__edit { margin-left: auto; font-family: var(--sv-font-ui); font-size: 0.6em; color: var(--sv-ink-soft); }

.sv-note__text {
    margin: 0 0 0.7em;
    font-family: var(--sv-font-hand);
    font-size: 1.12em;
    font-weight: 500;
    line-height: 1.25;
    orphans: 2;
    widows: 2;
}

.sv-note__photos {
    --sv-photo-width: 47%;
    display: flex;
    flex-wrap: wrap;
    gap: 0.9em 1em;
    padding: 0.5em 0.3em;
    justify-content: var(--sv-justify, flex-start);
}

.sv-note--center { --sv-justify: center; }
.sv-note--end { --sv-justify: flex-end; }
.sv-note__photos--une { --sv-photo-width: 80%; }
.sv-note__photos--deux { --sv-photo-width: 47%; }
.sv-note__photos > .sv-photo { width: var(--sv-photo-width); }

.sv-note__photos--deux > .sv-photo:nth-child(even) { margin-top: 1.2em; }

.sv-note__more {
    margin: 0.2em 0 0 0.3em;
    padding: 0.15em 0.9em;
    border: 1px solid var(--sv-bordeaux);
    border-radius: var(--sv-radius-round);
    background: transparent;
    color: var(--sv-bordeaux);
    font: 500 0.65em var(--sv-font-ui);
    cursor: pointer;
}

.sv-note__more:hover { background: var(--sv-bordeaux); color: var(--sv-paper); }

.sv-photo__more {
    position: absolute;
    right: 0.7em;
    bottom: 2.4em;
    z-index: 3;
    padding: 0.1em 0.6em;
    border-radius: var(--sv-radius-round);
    background: rgba(59, 42, 32, 0.82);
    color: var(--sv-paper);
    font: 500 0.85em var(--sv-font-ui);
    pointer-events: none;
}

/* ---------- Visages ---------- */

.sv-face--tiny { width: 1.5em; height: 1.5em; display: inline-block; }
.sv-face--small { width: 1.9em; height: 1.9em; }
.sv-face--large { width: 3.1em; height: 3.1em; }

/* ---------- Photos et leurs cadres ---------- */

.sv-photo {
    position: relative;
    margin: 0;
    break-inside: avoid;
    transform: rotate(var(--sv-tilt));
    transition: transform 0.35s var(--sv-ease);
}

.sv-photo:hover, .sv-photo:focus-within { transform: rotate(0deg) scale(1.03); z-index: 2; }

.sv-photo__link { display: block; overflow: hidden; cursor: zoom-in; background: var(--sv-cream-deep); }
.sv-photo__link img { display: block; width: 100%; height: 100%; object-fit: cover; }

.sv-photo--4-3 .sv-photo__link { aspect-ratio: 4 / 3; }
.sv-photo--1-1 .sv-photo__link { aspect-ratio: 1 / 1; }
.sv-photo--3-4 .sv-photo__link { aspect-ratio: 3 / 4; }

.sv-photo__caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15em 0.4em;
    margin-top: 0.35em;
    font-family: var(--sv-font-hand);
    font-size: 0.8em;
    line-height: 1.05;
    color: var(--sv-ink);
}

.sv-photo__text { flex: 1 1 100%; }
.sv-photo__faces { display: inline-flex; }
.sv-photo__faces .sv-face { margin-left: -0.3em; }

/* Polaroïd */
.sv-photo--polaroid { padding: 0.45em 0.45em 0.6em; background: #fffdf7; box-shadow: var(--sv-shadow-paper); }
.sv-photo--polaroid .sv-photo__caption { min-height: 1.6em; }

/* Ruban adhésif */
.sv-photo--ruban .sv-photo__link { box-shadow: var(--sv-shadow-paper); }

.sv-photo--ruban::before {
    content: "";
    position: absolute;
    top: -0.55em;
    left: 50%;
    z-index: 2;
    width: 4.2em;
    height: 1.25em;
    margin-left: -2.1em;
    background: repeating-linear-gradient(135deg, rgba(176, 141, 87, 0.55) 0 4px, rgba(176, 141, 87, 0.4) 4px 8px);
    box-shadow: 0 1px 2px rgba(59, 42, 32, 0.18);
    transform: rotate(-4deg);
}

/* Coins d'album */
.sv-photo--coins { padding: 0.3em; background: #fffdf7; box-shadow: var(--sv-shadow-paper); }

.sv-photo--coins::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(135deg, var(--sv-bordeaux) 50%, transparent 50%) top left / 1.5em 1.5em no-repeat,
        linear-gradient(225deg, var(--sv-bordeaux) 50%, transparent 50%) top right / 1.5em 1.5em no-repeat,
        linear-gradient(45deg, var(--sv-bordeaux) 50%, transparent 50%) bottom left / 1.5em 1.5em no-repeat,
        linear-gradient(315deg, var(--sv-bordeaux) 50%, transparent 50%) bottom right / 1.5em 1.5em no-repeat;
}

/* Cadre dessiné à la main */
.sv-photo--croquis { padding: 0.4em; margin-bottom: 0.4em; border-radius: 2px 7px 3px 8px / 7px 2px 8px 3px; box-shadow: 0 0 0 0.3em #fffdf7, 0 0 0 calc(0.3em + 1.5px) var(--sv-ink); outline: 1.5px solid var(--sv-ink); outline-offset: -0.1em; }

/* Vignette du moment */
.sv-photo__badge,
.sv-photo__thumb {
    position: absolute;
    top: 0.4em;
    right: 0.4em;
    z-index: 3;
}

.sv-photo__badge {
    padding: 0.05em 0.6em;
    border-radius: var(--sv-radius-round);
    background: var(--sv-bordeaux);
    color: var(--sv-paper);
    font: 500 0.55em var(--sv-font-ui);
}

.sv-photo__thumb { margin: 0; opacity: 0; transition: opacity 0.25s; }
.sv-photo:hover .sv-photo__thumb, .sv-photo:focus-within .sv-photo__thumb { opacity: 1; }

.sv-photo__thumb button {
    padding: 0.1em 0.7em;
    border: 0;
    border-radius: var(--sv-radius-round);
    background: rgba(251, 246, 234, 0.92);
    color: var(--sv-ink);
    font: 500 0.55em var(--sv-font-ui);
    cursor: pointer;
    box-shadow: var(--sv-shadow-paper);
}

@media (hover: none) { .sv-photo__thumb { opacity: 1; } }

/* ---------- Photothèque ---------- */

.sv-gallery__title { margin-top: var(--sv-space-sm); font-size: var(--sv-text-x-large); font-weight: 300; }
.sv-gallery__count { font-family: var(--sv-font-hand); font-size: 1.5rem; color: var(--sv-ink-soft); }
.sv-gallery__filter { margin-bottom: var(--sv-space-md); }

/* Une grille régulière : chaque photo occupe une case de même format (recadrée, la photo entière est dans la visionneuse) */
.sv-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 2.2rem 1.8rem; align-items: start; font-size: 1.1rem; }
.sv-gallery .sv-photo__link { aspect-ratio: 4 / 3; }

/* ---------- Visionneuse : la photo en grand, sans cadre ---------- */

.sv-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    place-items: center;
    padding: 1rem 5rem 0.8rem;
    background: rgba(32, 22, 16, 0.96);
    animation: sv-fade 0.25s ease;
}

@keyframes sv-fade { from { opacity: 0; } }

.sv-lightbox__figure { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; min-height: 0; max-width: 100%; margin: 0; }
.sv-lightbox__img { min-height: 0; max-width: 100%; max-height: calc(100vh - 17rem); object-fit: contain; box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5); }

.sv-lightbox__caption { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; color: var(--sv-cream); text-align: center; }
.sv-lightbox__legend { margin: 0; font-family: var(--sv-font-hand); font-size: 1.5rem; line-height: 1.1; }
.sv-lightbox__credit { margin: 0; font-family: var(--sv-font-title); font-size: 1rem; font-style: italic; opacity: 0.7; }

.sv-lightbox__tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem 0.9rem; margin: 0; padding: 0; list-style: none; }
.sv-lightbox__tag { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--sv-font-hand); font-size: 1.15rem; }
.sv-lightbox__tag .sv-face { width: 2.2rem; height: 2.2rem; }

.sv-lightbox__action:empty { display: none; }
.sv-lightbox__hint { margin: 0; color: var(--sv-cream); font: 0.85rem var(--sv-font-ui); opacity: 0.55; }
.sv-lightbox__action .sv-photo__thumb { position: static; opacity: 1; font-size: 1.4rem; }
.sv-lightbox__action .sv-photo__thumb button { padding: 0.3em 1.1em; font-size: 0.8rem; background: var(--sv-cream); }
.sv-lightbox__action .sv-photo__badge { position: static; display: inline-block; font-size: 1.4rem; }

.sv-lightbox__counter { position: absolute; top: 1.4rem; left: 1.6rem; margin: 0; color: var(--sv-cream); font-family: var(--sv-font-ui); font-size: 0.95rem; opacity: 0.75; }

.sv-lightbox__strip {
    display: flex;
    gap: 0.5rem;
    max-width: 100%;
    padding: 0.5rem 0.2rem;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(244, 236, 221, 0.4) transparent;
}

.sv-lightbox__thumb {
    flex: none;
    width: 4.2rem;
    height: 3.2rem;
    padding: 0;
    border: 2px solid transparent;
    background: none;
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.2s;
}

.sv-lightbox__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.sv-lightbox__thumb:hover { opacity: 0.85; }
.sv-lightbox__thumb.is-current { border-color: var(--sv-cream); opacity: 1; }

.sv-lightbox__btn {
    position: absolute;
    width: 3rem;
    height: 3rem;
    border: 1px solid rgba(244, 236, 221, 0.4);
    border-radius: 50%;
    background: rgba(244, 236, 221, 0.1);
    color: var(--sv-cream);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.sv-lightbox__btn:hover { background: rgba(244, 236, 221, 0.25); }
.sv-lightbox__btn--close { top: 1rem; right: 1rem; }
.sv-lightbox__btn--prev { left: 1rem; top: 40%; }
.sv-lightbox__btn--next { right: 1rem; top: 40%; }

/* ---------- Téléphone : une page à la fois ---------- */

@media (max-width: 48rem) {
    .sv-book { --sv-gutter: 2.2rem; width: 100%; aspect-ratio: 3 / 4.6; }
    .sv-book__cover { padding: 0.5rem; }
    .sv-book__flow { column-count: 1; font-size: clamp(1rem, 3cqh, 1.3rem); }
    .sv-book__spine { display: none; }
    .sv-book__paper { background: #fdf9ee; }
    .sv-book__clip { inset: 1.6rem 1.1rem; }
    .sv-book__nav--prev { left: -0.4rem; }
    .sv-book__nav--next { right: -0.4rem; }
    .sv-book__nav { width: 2.6rem; height: 2.6rem; margin-top: 0; top: auto; bottom: -3.3rem; }
    .sv-book__counter { margin-top: 1rem; }
    .sv-note__photos--deux { --sv-photo-width: 48%; }
    .sv-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.6rem 1rem; }
}
