/* ==========================================================================
   Black Olive, page Galerie
   S'ajoute à css/style.css (même fichier que l'accueil) : jetons, en-tête, boutons, pied de page.
   Panneau fixe + une photo par chapitre en arche ou en cercle sur fond sombre, flèches gauche et droite.
   ========================================================================== */

:root { --gx-top: calc(var(--frame-h) + var(--header-h)); }

.gx { display: block; padding-top: var(--gx-top); }
.main-nav a.is-here:not(.btn) { color: var(--cream); }
.main-nav a.is-here:not(.btn)::after { transform: scaleX(1); transform-origin: left; }
:focus-visible { outline: 2px solid var(--olive); outline-offset: 4px; }

/* ---------- Panneau ---------- */
.gx-panel {
  background:
    radial-gradient(ellipse 90% 40% at 0% 0%, rgba(138, 154, 91, .16) 0%, transparent 70%),
    var(--forest-deep);
  color: var(--cream);
}
.gx-head { padding: 28px var(--gutter) 22px; }
.gx-title {
  font-family: var(--font-display); font-weight: 300; text-transform: uppercase; letter-spacing: .02em;
  font-size: clamp(1.9rem, 7.2vw, 2.7rem); line-height: 1.06; text-wrap: balance; color: var(--cream);
}
.gx-title em { font-style: italic; font-weight: 400; text-transform: none; color: var(--gold-soft); }
.gx-lead { margin-top: 12px; max-width: 36ch; font-size: .95rem; line-height: 1.55; font-weight: 300; color: var(--cream-muted); }
.gx-head .kicker { margin-bottom: 10px; }

/* chapitres : pastilles sur mobile */
.gx-idx ul { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 12px var(--gutter); list-style: none; margin: 0; }
.gx-idx ul::-webkit-scrollbar { display: none; }
.gx-idx a {
  display: flex; align-items: baseline; gap: 8px; padding: 10px 18px; border-radius: var(--radius-pill); white-space: nowrap;
  font-size: .72rem; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--cream-muted);
  border: 1px solid rgba(248, 246, 240, .28);
  transition: background-color .35s var(--ease-out), color .35s var(--ease-out), border-color .35s var(--ease-out), transform .2s var(--ease-out);
}
.gx-idx a:active { transform: scale(.97); }
.gx-idx a.is-current { background: var(--cream); color: var(--ink); border-color: var(--cream); }
.gx-idx small { font-size: .7rem; letter-spacing: .08em; opacity: .7; }
.gx-idx__n { display: none; }
.gx-live { display: none; }

/* ---------- Flux : une photo en arche ou en cercle par chapitre ---------- */
.gx-flow { background: var(--ink); }
.gx-chap {
  --ar: .8;                       /* proportion de la photo (largeur / hauteur) */
  --w: min(100%, calc(60svh * var(--ar)));
  position: relative; isolation: isolate; overflow: hidden;
  display: grid; grid-template-columns: 1fr; gap: var(--space-md); justify-items: center;
  padding: var(--space-lg) var(--gutter);
  background:
    radial-gradient(ellipse 60% 50% at 50% 38%, rgba(138, 154, 91, .16) 0%, transparent 70%),
    var(--ink);
  scroll-margin-top: calc(var(--gx-top) + 56px);
}
.gx-chap + .gx-chap { border-top: 1px solid var(--hairline); }
.gx-chap--round { --ar: 1; }

/* la photo : une seule visible, les autres empilées dessous */
.gx-stage { position: relative; grid-row: 2; width: var(--w); aspect-ratio: var(--ar); touch-action: pan-y; }
.gx-slides { position: absolute; inset: 0; margin: 0; padding: 0; list-style: none; overflow: hidden; background: var(--forest-deep); }
.gx-chap--arch .gx-slides { border-radius: 999px 999px 0 0; }
.gx-chap--round .gx-slides { border-radius: 50%; }
.gx-slide {
  position: absolute; inset: 0; opacity: 0; visibility: hidden; transform: scale(1.06);
  transition: opacity .7s var(--ease-out), transform 1.6s var(--ease-out), visibility 0s linear .7s;
}
.gx-slide.is-active { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.gx-open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.gx-open img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; filter: saturate(.96); }
/* filet doré qui suit la forme, un peu en retrait de la photo */
.gx-stage::before {
  content: ""; position: absolute; inset: -14px; z-index: 0; pointer-events: none; border: 1px solid var(--gold-line);
  transition: inset .8s var(--ease-out), border-color .8s var(--ease-out);
}
.gx-chap--arch .gx-stage::before { border-radius: 999px 999px 0 0; }
.gx-chap--round .gx-stage::before { border-radius: 50%; }
.gx-slides { z-index: 1; }
@media (hover: hover) and (pointer: fine) { .gx-stage:hover::before { inset: -20px; border-color: rgba(233, 207, 159, .7); } }

/* flèches gauche et droite, sur les côtés de la photo */
.gx-arrow {
  position: absolute; top: 50%; z-index: 3; width: 52px; height: 52px; margin-top: -26px; display: grid; place-items: center; padding: 0;
  border-radius: 50%; color: var(--cream); background: rgba(14, 21, 18, .72); border: 1px solid rgba(233, 207, 159, .6); cursor: pointer;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  transition: background-color .3s var(--ease-out), color .3s var(--ease-out), border-color .3s var(--ease-out), transform .2s var(--ease-out);
}
.gx-arrow svg { width: 20px; height: 20px; }
.gx-arrow--prev { left: -8px; }
.gx-arrow--next { right: -8px; }
.gx-arrow:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .gx-arrow:hover { background: var(--olive); color: var(--ink); border-color: var(--olive); } }

/* texte du chapitre */
.gx-chap__head { grid-row: 1; justify-self: stretch; padding: 0; }
.gx-orn { display: flex; align-items: center; gap: 14px; margin-bottom: var(--space-sm); color: var(--gold); }
.gx-orn i { font-style: normal; font-size: .85rem; line-height: 1; }
.gx-orn span { width: 84px; height: 1px; background: linear-gradient(90deg, var(--gold-line), transparent); }
.gx-chap__title {
  font-family: var(--font-display); font-weight: 300; text-transform: uppercase; letter-spacing: .02em;
  font-size: clamp(2.8rem, 11vw, 4rem); line-height: 1.02; color: var(--cream);
}
.gx-chap__title em { font-style: italic; font-weight: 400; text-transform: none; color: var(--gold-soft); padding-right: .06em; }
.gx-chap__head p { margin-top: var(--space-sm); max-width: 44ch; font-weight: 300; color: var(--cream-muted); }

/* légende et compteur : sous la photo sur mobile */
.gx-bg__cap {
  grid-row: 3; justify-self: stretch; display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  font-family: var(--font-display); font-style: italic; font-size: 1.2rem; line-height: 1.3; color: var(--gold-soft);
}
.gx-fig__n { font-family: var(--font-body); font-style: normal; font-size: .75rem; letter-spacing: .2em; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
.gx-fig__n b { font-weight: 500; color: var(--cream); }

/* fin */
.gx-end { padding: clamp(72px, 12vw, 120px) var(--gutter) clamp(80px, 12vw, 140px); background: var(--ink); }
.gx-orn + .gx-end__phrase { margin-top: 0; }
.gx-end__phrase { font-family: var(--font-display); font-weight: 300; text-transform: uppercase; letter-spacing: .02em; font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.06; text-wrap: balance; }
.gx-end__phrase em { font-style: italic; font-weight: 400; text-transform: none; color: var(--gold-soft); }
.gx-end__links { display: flex; flex-wrap: wrap; gap: 14px; margin-top: var(--space-md); }

/* mobile : pastilles collées sous l'en-tête */
@media (max-width: 1080px) {
  .gx-idx { position: sticky; top: var(--gx-top); z-index: 20; background: rgba(14, 21, 18, .94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border-bottom: 1px solid var(--hairline); }
  .gx-panel { display: contents; }
  .gx-head { background: var(--forest-deep); }
}
@media (max-width: 640px) {
  .gx-chap { --w: min(100% - 40px, calc(52svh * var(--ar))); gap: 20px; padding-block: 36px 44px; }
  .gx-chap__title { font-size: clamp(2.4rem, 10vw, 3.2rem); }
  .gx-chap__head p { margin-top: 10px; font-size: .97rem; line-height: 1.6; }
  .gx-orn { margin-bottom: 10px; }
  .gx-bg__cap { margin-top: 6px; font-size: 1.1rem; }
  .gx-arrow { width: 44px; height: 44px; margin-top: -22px; }
  .gx-arrow--prev { left: -18px; }
  .gx-arrow--next { right: -18px; }
}

/* ---------- Grand écran : panneau collant ---------- */
@media (min-width: 1081px) {
  .gx { display: grid; grid-template-columns: minmax(23rem, 31rem) minmax(0, 1fr); align-items: start; }

  .gx-panel {
    position: sticky; top: var(--gx-top); height: calc(100vh - var(--gx-top)); height: calc(100svh - var(--gx-top));
    display: flex; flex-direction: column; justify-content: space-between;
    padding: var(--space-md) clamp(24px, 3vw, 48px) clamp(20px, 3vh, 36px) var(--gutter);
    border-right: 1px solid var(--hairline);
  }
  .gx-head { padding: 0; }
  .gx-title { font-size: clamp(2rem, 2.7vw, 2.8rem); }
  .gx-lead { font-size: .97rem; }

  .gx-idx { margin-block: var(--space-sm); }
  .gx-idx ul { display: block; overflow: visible; padding: 0; }
  .gx-idx li + li { margin-top: 2px; }
  .gx-idx a {
    display: grid; grid-template-columns: 22px 1fr auto; align-items: baseline; gap: 8px; padding: 4px 0; border: 0; border-radius: 0; background: none;
    font-family: var(--font-display); font-size: clamp(1.45rem, 2vw, 1.8rem); font-weight: 400; letter-spacing: 0; text-transform: none; line-height: 1.2; color: rgba(231, 227, 216, .6);
    transition: color .4s var(--ease-out), transform .4s var(--ease-out);
  }
  .gx-idx a:active { transform: none; }
  .gx-idx a.is-current { background: none; color: var(--cream); transform: translateX(6px); }
  .gx-idx__n { display: inline; font-family: var(--font-body); font-size: .7rem; font-weight: 500; letter-spacing: .12em; color: var(--gold); opacity: .55; transition: opacity .4s var(--ease-out); }
  .gx-idx a.is-current .gx-idx__n { opacity: 1; }
  .gx-idx small { font-family: var(--font-body); font-size: .72rem; letter-spacing: .1em; color: var(--cream-muted); }
  @media (hover: hover) and (pointer: fine) { .gx-idx a:hover { color: var(--cream); } }

  .gx-live { display: block; }
  .gx-live__cap { min-height: 3.2em; font-family: var(--font-display); font-style: italic; font-size: clamp(1.25rem, 1.6vw, 1.5rem); line-height: 1.25; color: var(--gold-soft); text-wrap: balance; transition: opacity .22s var(--ease-out), filter .22s var(--ease-out); }
  .gx-live__cap.is-swap { opacity: 0; filter: blur(3px); }
  .gx-live__bar { display: block; height: 1px; margin-top: 14px; background: rgba(248, 246, 240, .16); overflow: hidden; }
  .gx-live__bar i { display: block; height: 100%; background: var(--gold); transform-origin: left; transform: scaleX(0); will-change: transform; }
  .gx-live__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 16px; }
  .gx-live__count { font-size: .78rem; letter-spacing: .22em; color: var(--gold); font-variant-numeric: tabular-nums; white-space: nowrap; }
  .gx-live__count b { font-weight: 500; color: var(--cream); }
  .gx-live__cta { padding: 12px 22px; }

  /* chaque chapitre occupe l'écran : texte d'un côté, photo en arche ou en cercle de l'autre */
  .gx-chap {
    --w: min(100%, calc(62vh * var(--ar))); --w: min(100%, calc(62svh * var(--ar)));
    min-height: calc(100vh - var(--gx-top)); min-height: calc(100svh - var(--gx-top)); scroll-margin-top: var(--gx-top);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "head stage" "cap stage";
    align-content: center; align-items: center; column-gap: clamp(40px, 5vw, 96px); row-gap: var(--space-sm);
    padding: var(--space-lg) clamp(32px, 4vw, 72px);
  }
  .gx-chap--flip { grid-template-areas: "stage head" "stage cap"; }
  .gx-stage { grid-area: stage; justify-self: center; }
  .gx-chap__head { grid-area: head; align-self: end; }
  .gx-chap__title { font-size: clamp(3.2rem, 4.8vw, 5.4rem); }
  .gx-arrow--prev { left: -26px; }
  .gx-arrow--next { right: -26px; }
  /* la légende vit dans le panneau : elle reste lisible pour les lecteurs d'écran */
  .gx-bg__cap { grid-area: cap; position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

/* portables peu hauts : le panneau se resserre pour garder la légende visible */
@media (min-width: 1081px) and (max-height: 820px) {
  .gx-panel { padding-top: 20px; padding-bottom: 16px; }
  .gx-head .kicker { margin-bottom: 8px; }
  .gx-title { font-size: clamp(1.7rem, 2.3vw, 2.2rem); }
  .gx-lead { display: none; }
  .gx-idx { margin-block: 12px; }
  .gx-idx a { padding-block: 2px; font-size: clamp(1.2rem, 1.6vw, 1.45rem); }
  .gx-live__cap { min-height: 2.6em; font-size: 1.15rem; }
  .gx-live__row { margin-top: 10px; }
  .gx-live__cta { display: none; }
  .gx-chap { --w: min(100%, calc(66svh * var(--ar))); }
  .gx-chap__title { font-size: clamp(2.8rem, 4.4vw, 4.2rem); }
}

/* ---------- Apparition ---------- */
.js .gx-stage { opacity: 0; transform: scale(.96); transition: opacity 1.1s var(--ease-out), transform 1.4s var(--ease-out); }
.js .gx-stage.is-in { opacity: 1; transform: none; }
.js .gx-chap__head { opacity: 0; transform: translateY(24px); transition: opacity 1s var(--ease-out), transform 1s var(--ease-out); }
.js .gx-chap__head.is-in, .js .gx-end.is-in { opacity: 1; transform: none; }
.js .gx-end { opacity: 0; transform: translateY(24px); transition: opacity 1s var(--ease-out), transform 1s var(--ease-out); }

/* ---------- Visionneuse ---------- */
.lb { border: 0; padding: 0; margin: 0; width: 100%; max-width: none; height: 100%; max-height: none; background: rgba(14, 21, 18, .98); color: var(--cream); }
.lb::backdrop { background: rgba(14, 21, 18, .92); }
.lb[open] { display: grid; grid-template-rows: 1fr auto; animation: lbIn .45s var(--ease-out) both; }
@keyframes lbIn { from { opacity: 0; } to { opacity: 1; } }
.lb__stage { position: relative; display: grid; place-items: center; padding: clamp(56px, 6vw, 80px) clamp(16px, 6vw, 96px) 16px; min-height: 0; touch-action: pan-y; }
.lb__img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 32px 80px -16px rgba(0, 0, 0, .6); }
.lb__bar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 16px clamp(16px, 4vw, 48px) 24px; border-top: 1px solid var(--hairline); }
.lb__cap { font-family: var(--font-display); font-style: italic; font-size: clamp(1.2rem, 2vw, 1.6rem); max-width: 40ch; color: var(--gold-soft); }
.lb__count { font-size: .75rem; letter-spacing: .22em; color: var(--gold); white-space: nowrap; }
.lb__btn { position: absolute; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: rgba(248, 246, 240, .06); border: 1px solid rgba(233, 207, 159, .45); color: var(--cream); cursor: pointer; transition: background-color .3s var(--ease-out), color .3s var(--ease-out), transform .2s var(--ease-out); }
.lb__btn:active { transform: scale(.94); }
.lb__btn svg { width: 18px; height: 18px; }
.lb__close { top: 16px; right: 16px; }
.lb__prev { left: clamp(8px, 1.5vw, 24px); top: 50%; translate: 0 -50%; }
.lb__next { right: clamp(8px, 1.5vw, 24px); top: 50%; translate: 0 -50%; }
@media (hover: hover) { .lb__btn:hover { background: var(--olive); color: var(--ink); border-color: var(--olive); } }
@media (max-width: 640px) {
  .lb__stage { padding-inline: 8px; }
  .lb__prev, .lb__next { top: auto; bottom: 8px; translate: none; }
  .lb__bar { flex-direction: column; align-items: flex-start; gap: 8px; padding-bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .js .gx-stage, .js .gx-chap__head, .js .gx-end { opacity: 1; transform: none; transition: none; }
  .gx-stage::before { transition: none; }
  .gx-slide, .gx-slide.is-active { transform: none; transition: opacity .2s linear, visibility 0s; }
  .gx-live__cap, .gx-idx a, .gx-idx__n { transition: none; }
  .lb[open] { animation: none; }
}
