/* ==========================================================================
   « au musée » — s'approcher d'une œuvre (theme/musee-approche.js).
   Dans le monde de « des tableaux » (theme/style.css) : fond gris grainé,
   PP Eiko et PP Neue Montreal, cartel à filets fins, pastille, et la nuit
   « lampe de banquier ». On reprend ses variables quand elles sont là ;
   sinon, les mêmes valeurs.
   ========================================================================== */

.ap {
    --ap-fond: var(--tb-fond, #F2F2F2);
    --ap-encre: var(--tb-encre, #000);
    --ap-carte: var(--tb-carte, #fff);
    --ap-filet: var(--tb-filet, rgba(0, 0, 0, .15));
    --ap-filet-fort: var(--tb-filet-fort, rgba(0, 0, 0, .25));
    --ap-ombre: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .08);
    --ap-eiko: "PP Eiko", "Times New Roman", serif;
    --ap-sans: "PP Neue Montreal", "Helvetica Neue", Arial, sans-serif;
    --ap-marge: 16px;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    top: 3rem;                     /* corrigé par le script : le bas de l'en-tête */
    z-index: 1;
    overflow: hidden;
    background-color: var(--ap-fond);
    /* Le grain du papier de « des tableaux » (theme/style.css), sans image à charger. */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
    color: var(--ap-encre);
    font-family: var(--ap-sans);
    font-weight: 500;
    font-size: 15px;
    letter-spacing: -0.025em;
    -webkit-font-smoothing: antialiased;
}
html[data-nuit] .ap {
    --ap-fond: var(--tb-fond, #121110);
    --ap-encre: var(--tb-encre, #EFEAE1);
    --ap-carte: var(--tb-carte, #1E1B19);
    --ap-filet: var(--tb-filet, rgba(255, 255, 255, .16));
    --ap-filet-fort: var(--tb-filet-fort, rgba(255, 255, 255, .32));
    --ap-ombre: 0 1px 2px rgba(0, 0, 0, .5), 0 14px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}
/* Le cartel reprend les classes de « des tableaux » : on leur donne nos couleurs. */
.ap-cartel {
    --tb-encre: var(--ap-encre);
    --tb-fond: var(--ap-fond);
    --tb-eiko: var(--ap-eiko);
    --tb-filet: var(--ap-filet);
}
.ap a { color: inherit; }
.ap kbd {
    display: inline-block;
    min-width: 1.35em;
    padding: 0 .3em;
    margin: 0 .08em;
    border: 1px solid currentColor;
    border-radius: 3px;
    font: inherit;
    line-height: 1.3;
    text-align: center;
}

/* --- La scène : le mur, l'œuvre, toi, le gardien ------------------------------------- */
.ap-scene { position: absolute; inset: 0; }
.ap-toile {
    position: absolute;
    left: 0; top: 0;
    display: block;
    touch-action: none;
    cursor: zoom-in;
    -webkit-user-select: none;
    user-select: none;
}
.ap-toile.est-tire { cursor: grabbing; }
.ap-dessin {
    position: absolute;
    left: 0; top: 0;
    overflow: hidden;
    pointer-events: none;
    fill: currentColor;
}

/* --- La carte : comment s'approcher, ce que tu vois, avec quelle image ---------------- */
.ap-carte {
    position: absolute;
    left: var(--ap-marge); top: var(--ap-marge);
    z-index: 3;
    width: 19.5rem;
    padding: .75rem .9rem .8rem;
    background: var(--ap-carte);
    border-radius: 2px;
    box-shadow: var(--ap-ombre);
    font-size: .74rem;
    line-height: 1.4;
    font-weight: 400;
    letter-spacing: -0.01em;
}
.ap-carte p { margin: 0; }

/* La mention : bien visible d'abord (en tête, à l'encre pleine), discrète ensuite. */
.ap-mention.est-grande {
    margin: -.75rem -.9rem .7rem;
    padding: .8rem .9rem .85rem;
    background: var(--ap-encre);
    color: var(--ap-carte);
    border-radius: 2px 2px 0 0;
}
.ap-mention-titre {
    font-family: var(--ap-eiko);
    font-size: 1.45rem;
    line-height: 1.05;
    letter-spacing: -0.035em;
}
.ap-mention-texte { margin-top: .3rem !important; font-size: .82rem; line-height: 1.38; font-weight: 500; }
.ap-mention.est-grande kbd { font-weight: 500; }
.ap-mention.est-discrete {
    order: 9;
    margin-top: .55rem;
    padding-top: .45rem;
    border-top: 1px solid var(--ap-filet);
    font-size: .68rem;
    opacity: .62;
}
.ap-mention.est-discrete kbd { font-size: .62rem; line-height: 1.25; }
.ap-carte { display: flex; flex-direction: column; }

.ap-mesure-lib { font-size: .7rem; opacity: .62; }
.ap-mesure-val { font-size: .8rem; }
.ap-mesure-val span {
    font-family: var(--ap-eiko);
    font-size: 2.35rem;
    line-height: 1;
    letter-spacing: -0.045em;
    font-variant-numeric: tabular-nums;
}
.ap-mesure-dist { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: .3rem .8rem; margin-top: .3rem !important; }
.ap-a-completer { font-style: italic; }
.ap-barre { display: inline-flex; align-items: flex-end; gap: .4rem; font-size: .66rem; line-height: 1; white-space: nowrap; }
.ap-barre svg { display: block; overflow: visible; }
.ap-barre line { stroke: var(--ap-encre); stroke-width: 1; shape-rendering: crispEdges; }

/* La jauge des distances : de 10 m à 1 cm, le mur à droite. */
.ap-jauge { margin-top: .55rem; }
.ap-jauge:empty { display: none; }
.ap-jauge svg { display: block; overflow: visible; }
.ap-jauge text { font: 400 9px/1 var(--ap-sans); fill: var(--ap-encre); opacity: .55; letter-spacing: 0; }
.ap-jauge-sol, .ap-jauge-trait { stroke: var(--ap-encre); stroke-width: 1; opacity: .5; shape-rendering: crispEdges; }
.ap-jauge-mur { stroke: var(--ap-encre); stroke-width: 2; }
.ap-jauge-interdit { fill: var(--ap-encre); opacity: .1; }
.ap-jauge-limite { stroke: var(--ap-encre); stroke-width: 1; stroke-dasharray: 2 2; opacity: .6; }
.ap-jauge-toi { fill: var(--ap-encre); }

.ap-image { margin-top: .6rem !important; padding-top: .5rem; border-top: 1px solid var(--ap-filet); opacity: .85; }
.ap-image b { font-weight: 500; }
.ap-image.est-signal { animation: ap-signal 1.2s ease; }
@keyframes ap-signal { 0%, 40% { opacity: 1; } 100% { opacity: .85; } 15% { transform: translateX(3px); } 30% { transform: none; } }
.ap-alerte { color: #9a3412; }
html[data-nuit] .ap-alerte { color: #fdba74; }
.ap-charge { position: relative; display: block; height: 3px; margin-top: .4rem; background: var(--ap-filet); }
.ap-charge span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ap-encre); }

/* --- Le cartel, sous l'œuvre (il la suit, et s'efface quand on s'approche) ----------- */
.ap-cartel {
    position: absolute;
    left: 0; top: 0;
    z-index: 2;
    width: min(54rem, calc(100% - 2 * var(--ap-marge)));
    display: grid;
    grid-template-columns: minmax(0, 31rem) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    column-gap: 2.2rem;
    align-items: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    padding-bottom: .4rem;
    transition: opacity .25s ease;
    will-change: transform;
}
.ap-cartel::-webkit-scrollbar { display: none; }
.ap-cartel.est-efface { pointer-events: none; }
.ap-cartel.est-coupe {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.2rem), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 2.2rem), transparent);
}
.ap-cartel .tb-titre { grid-column: 1; margin: 0 0 .7rem; font-size: clamp(1.5rem, 2.1vw, 2.2rem); }
.ap-cartel .tb-credits { grid-column: 1; columns: 2; column-gap: 1.4rem; }
.ap-cartel .tb-credits > div { break-inside: avoid; -webkit-column-break-inside: avoid; }
.ap-cartel .tb-credits dd { overflow-wrap: anywhere; }
.ap-cartel-suite { grid-column: 2; grid-row: 1 / span 2; }
.ap-cartel .cartel-texte { margin-top: 0; }
.ap-cartel .cartel-texte > :last-child { margin-bottom: 0; }
.ap-chemins { margin: .7rem 0 0; font-size: .8rem; }
.ap-chemins a { text-decoration: underline; text-underline-offset: 3px; }
.ap-chemins a:hover { text-decoration: none; }
.ap-chemins .sep, .ap-cartel .cartel-liens .sep { opacity: .5; }

/* --- Le plan de la toile, dès qu'elle déborde ------------------------------------------ */
.ap-mini {
    position: absolute;
    left: var(--ap-marge); bottom: 1.2rem;
    z-index: 3;
    padding: 4px;
    background: var(--ap-carte);
    border-radius: 2px;
    box-shadow: var(--ap-ombre);
    line-height: 0;
    cursor: pointer;
}
.ap-mini[hidden] { display: none; }
.ap-scene:has(.ap-gardien:not([hidden])) .ap-mini, .ap-scene:has(.ap-avis:not([hidden])) .ap-mini { visibility: hidden; }
.ap-mini img { display: block; max-width: 132px; max-height: 96px; }
.ap-mini-fenetre { position: absolute; border: 1px solid #B8860B; background: rgba(184, 134, 11, .14); pointer-events: none; }
html[data-nuit] .ap-mini-fenetre { border-color: #FFD9A0; background: rgba(255, 217, 160, .16); }

/* --- Le gardien : il entre par la droite, la main levée ---------------------------------- */
.ap-gardien { position: absolute; inset: 0; z-index: 5; pointer-events: none; overflow: hidden; }
.ap-gardien[hidden] { display: none; }
.ap-gardien-figure {
    position: absolute;
    display: block;
    overflow: visible;
    color: var(--ap-encre);
    transform: translateX(18%);
    transition: transform .45s cubic-bezier(.2, .7, .2, 1), opacity .3s ease;
}
.ap-bulle {
    position: absolute;
    max-width: 17rem;
    margin: 0;
    padding: .7rem .9rem .75rem;
    background: var(--ap-carte);
    border-radius: 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 12px 32px rgba(0, 0, 0, .16);
    transform: translateY(6px);
    transition: transform .35s ease .15s, opacity .3s ease;
}
.ap-bulle-mot {
    display: block;
    font-family: var(--ap-eiko);
    font-style: italic;
    font-size: 2.1rem;
    line-height: 1;
    letter-spacing: -0.04em;
}
.ap-bulle-sous { display: block; margin-top: .45rem; font-size: .72rem; line-height: 1.38; font-weight: 400; opacity: .78; }
/* Il est là dès le premier instant (rien n'attend une animation) ; il glisse en
   entrant, et s'efface en partant. */
.ap-gardien.est-la .ap-gardien-figure, .ap-gardien.est-la .ap-bulle { transform: none; }
.ap-gardien.est-partant .ap-gardien-figure, .ap-gardien.est-partant .ap-bulle { opacity: 0; }

/* --- L'avis : sans grand fichier, la limite dite franchement ----------------------------- */
.ap-avis {
    position: absolute;
    left: 50%; bottom: 5.4rem;
    z-index: 4;
    width: min(26rem, calc(100% - 32px));
    transform: translateX(-50%);
    padding: .75rem .95rem .8rem;
    background: var(--ap-carte);
    border-left: 3px solid var(--ap-encre);
    border-radius: 2px;
    box-shadow: var(--ap-ombre);
}
.ap-avis[hidden] { display: none; }
.ap-avis p { margin: 0; }
.ap-avis-mot { font-family: var(--ap-eiko); font-size: 1.5rem; line-height: 1.05; letter-spacing: -0.035em; }
.ap-avis-texte { margin-top: .35rem !important; font-size: .76rem; line-height: 1.42; font-weight: 400; }

/* --- La pastille (comme celle de « des tableaux ») --------------------------------------- */
.ap-pastille {
    position: absolute;
    left: 50%;
    bottom: 1.2rem;
    transform: translateX(-50%);
    z-index: 6;
    display: flex;
    align-items: center;
    gap: .2rem;
    padding: .45rem .55rem;
    background: var(--ap-carte);
    border-radius: 2px;
    box-shadow: var(--ap-ombre);
    white-space: nowrap;
}
.ap-pastille button {
    font: inherit;
    letter-spacing: inherit;
    color: var(--ap-encre);
    background: none;
    border: 0;
    padding: .25rem .6rem;
    cursor: pointer;
    opacity: .55;
    transition: opacity .15s;
}
.ap-pastille button:hover, .ap-pastille button:focus-visible { opacity: 1; }
.ap-pastille .ap-avancer { opacity: .9; }
.ap-pastille-sep { width: 1px; height: 1.1rem; margin: 0 .2rem; background: var(--ap-filet-fort); }

.ap-introuvable { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.ap-introuvable-texte { font-family: var(--ap-eiko); font-size: 1.6rem; letter-spacing: -0.03em; margin: 0 0 .6rem; }

/* --- Entre deux : le cartel sur une colonne ------------------------------------------------ */
@media (max-width: 1099px) {
    .ap-cartel { width: min(36rem, calc(100% - 2 * var(--ap-marge))); grid-template-columns: minmax(0, 1fr); grid-template-rows: none; }
    .ap-cartel-suite { grid-column: 1; grid-row: auto; margin-top: 1rem; }
}

/* --- Téléphone ------------------------------------------------------------------------------- */
@media (max-width: 800px) {
    .ap-carte { left: 10px; right: 10px; top: 10px; width: auto; padding: .6rem .75rem .65rem; font-size: .7rem; }
    .ap-mention.est-grande { margin: -.6rem -.75rem .55rem; padding: .65rem .75rem .7rem; }
    .ap-mention-titre { font-size: 1.2rem; }
    .ap-mention-texte { font-size: .78rem; }
    .ap-mesure { display: grid; grid-template-columns: auto 1fr; column-gap: .8rem; align-items: end; }
    .ap-mesure-lib { grid-column: 1 / -1; }
    .ap-mesure-val span { font-size: 1.85rem; }
    .ap-mesure-dist { margin: 0 !important; justify-content: flex-end; font-size: .68rem; }
    .ap-image { margin-top: .45rem !important; padding-top: .4rem; font-size: .66rem; line-height: 1.35; }
    .ap-cartel { width: calc(100% - 32px); }
    .ap-cartel .tb-titre { font-size: clamp(1.6rem, 7.5vw, 2.2rem); }
    .ap-cartel .tb-credits { columns: 1; }
    .ap-cartel .tb-credits dd { font-size: .85rem; }
    .ap-cartel .cartel-texte { font-size: .88rem; }
    .ap-mini { left: 10px; bottom: 5rem; }
    .ap-mini img { max-width: 84px; max-height: 64px; }
    .ap-avis { bottom: 5.2rem; }
    .ap-pastille { bottom: 1rem; max-width: calc(100vw - 1.4rem); }
    .ap-pastille button { padding: .25rem .45rem; }
    .ap-bulle { max-width: none; }
    .ap-bulle-mot { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ap-gardien-figure, .ap-bulle, .ap-cartel, .ap-pastille button { transition: none !important; }
    .ap-image.est-signal { animation: none; }
}
