/* ==========================================================================
   Palais Vivienne — extras.css
   Curseur, boutons magnétiques, lightbox, grain, remonter, soulignés.
   z-index : grain 9000 · remonter 9100 · lightbox 9500 · curseur 9998
   ========================================================================== */

:root {
  --x-or: #9a7b45;
  --x-or-clair: #c9a86a;
  --x-noir: #1f1b17;
  --x-brun: #3a342e;
  --x-taupe: #7d7468;
  --x-sable: #d5cbb8;
  --x-creme: #f5f1e7;
  --x-ivoire: #fff8ec;
  --x-ease: cubic-bezier(.22, 1, .36, 1);
}

/* --------------------------------------------------------------------------
   1. Curseur personnalisé
   -------------------------------------------------------------------------- */
html.has-cursor,
html.has-cursor body,
html.has-cursor a,
html.has-cursor button,
html.has-cursor [data-cursor],
html.has-cursor [data-magnetic],
html.has-cursor label,
html.has-cursor input,
html.has-cursor select,
html.has-cursor textarea,
html.has-cursor summary {
  cursor: none;
}

.x-cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9998;
  pointer-events: none;
  will-change: transform;
  opacity: 0;
  transition: opacity .35s ease;
}
.x-cursor--dot {
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--x-or-clair);
  mix-blend-mode: difference;
}
.x-cursor--ring {
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 50%;
  box-sizing: border-box;
  border: 1px solid var(--x-or-clair);
  background: rgba(201, 168, 106, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  mix-blend-mode: difference;
  transition:
    width .45s var(--x-ease),
    height .45s var(--x-ease),
    margin .45s var(--x-ease),
    border-width .3s ease,
    border-color .3s ease,
    background-color .35s ease,
    opacity .35s ease;
}
.x-cursor--ring span {
  font-family: 'Jost', sans-serif;
  font-weight: 400;
  font-size: .62rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--x-ivoire);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .25s ease, transform .35s var(--x-ease);
  padding-left: .28em; /* compense le letter-spacing final */
}
html.cursor-visible .x-cursor { opacity: 1; }

/* État « voir » : grand disque or translucide avec le mot */
.x-cursor--ring.is-voir {
  width: 88px;
  height: 88px;
  margin: -44px 0 0 -44px;
  border-color: rgba(201, 168, 106, .5);
  background: rgba(154, 123, 69, .55);
  mix-blend-mode: normal;
}
.x-cursor--ring.is-voir span {
  opacity: 1;
  transform: translateY(0);
}
.x-cursor--dot.is-voir { opacity: 0; }

/* État « lien » : anneau réduit et épaissi */
.x-cursor--ring.is-lien {
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-width: 2px;
  border-color: var(--x-or-clair);
}
.x-cursor--dot.is-lien { opacity: 0; }

/* Pression */
.x-cursor--ring.is-down { transform: scale(.85); }

@media (pointer: coarse) {
  .x-cursor { display: none !important; }
}

/* --------------------------------------------------------------------------
   2. Boutons magnétiques
   -------------------------------------------------------------------------- */
[data-magnetic] {
  display: inline-block;
  will-change: transform;
}
[data-magnetic] > .x-magnetic-inner {
  display: inline-block;
  will-change: transform;
}

/* --------------------------------------------------------------------------
   3. Lightbox
   -------------------------------------------------------------------------- */
.x-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  color: var(--x-sable);
  font-family: 'Jost', sans-serif;
}
.x-lightbox.is-open { display: block; }

.x-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 27, 23, .96);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  opacity: 0;
}

.x-lightbox__stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(56px, 8vh, 96px) clamp(56px, 8vw, 120px) clamp(96px, 14vh, 140px);
  pointer-events: none;
}
.x-lightbox__img {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  object-fit: cover;
  transform-origin: top left;
  will-change: transform, width, height;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: pan-y;
}

.x-lightbox__caption {
  position: absolute;
  left: 50%;
  bottom: clamp(32px, 6vh, 56px);
  transform: translateX(-50%);
  width: min(80vw, 760px);
  text-align: center;
  font-family: 'Bodoni Moda', serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  line-height: 1.5;
  color: var(--x-sable);
  opacity: 0;
}
.x-lightbox__counter {
  position: absolute;
  top: clamp(20px, 3.5vh, 32px);
  left: clamp(24px, 4vw, 48px);
  font-size: .7rem;
  letter-spacing: .28em;
  text-transform: uppercase;
  color: var(--x-or-clair);
  opacity: 0;
}

.x-lightbox__btn {
  position: absolute;
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--x-or-clair);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: color .3s ease, transform .4s var(--x-ease);
}
.x-lightbox__btn:hover { color: var(--x-ivoire); }
.x-lightbox__btn:focus-visible {
  outline: 1px solid var(--x-or-clair);
  outline-offset: 6px;
  border-radius: 50%;
}
.x-lightbox__btn svg {
  display: block;
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.x-lightbox__close {
  top: clamp(16px, 3vh, 28px);
  right: clamp(20px, 3.5vw, 44px);
  width: 44px;
  height: 44px;
}
.x-lightbox__close:hover { transform: rotate(90deg); }
.x-lightbox__prev,
.x-lightbox__next {
  top: 50%;
  width: 48px;
  height: 72px;
  margin-top: -36px;
}
.x-lightbox__prev { left: clamp(8px, 2vw, 32px); }
.x-lightbox__next { right: clamp(8px, 2vw, 32px); }
.x-lightbox__prev:hover { transform: translateX(-4px); }
.x-lightbox__next:hover { transform: translateX(4px); }

@media (max-width: 720px) {
  .x-lightbox__stage {
    padding: 64px 12px 120px;
  }
  .x-lightbox__prev,
  .x-lightbox__next {
    top: auto;
    bottom: 18px;
    margin-top: 0;
    width: 44px;
    height: 44px;
  }
  .x-lightbox__prev { left: 24px; }
  .x-lightbox__next { right: 24px; }
  .x-lightbox__caption {
    bottom: 76px;
    width: 84vw;
    font-size: .95rem;
  }
}

/* --------------------------------------------------------------------------
   4. Grain film
   -------------------------------------------------------------------------- */
.x-grain {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  opacity: .05;
  mix-blend-mode: overlay;
}
.x-grain canvas {
  width: 100%;
  height: 100%;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  .x-grain { display: none; }
}

/* --------------------------------------------------------------------------
   5. Bouton « Remonter »
   -------------------------------------------------------------------------- */
.x-remonter {
  position: fixed;
  right: clamp(18px, 2.5vw, 36px);
  bottom: clamp(18px, 3vh, 36px);
  z-index: 9100;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(201, 168, 106, .7);
  background: rgba(31, 27, 23, .35);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--x-or-clair);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px);
  transition:
    opacity .5s ease,
    visibility .5s ease,
    transform .6s var(--x-ease),
    border-color .3s ease,
    background-color .3s ease;
}
.x-remonter.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.x-remonter:hover {
  border-color: var(--x-ivoire);
  background: rgba(154, 123, 69, .35);
  color: var(--x-ivoire);
}
.x-remonter:focus-visible {
  outline: 1px solid var(--x-or-clair);
  outline-offset: 4px;
}
.x-remonter svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform .5s var(--x-ease);
}
.x-remonter:hover svg { transform: translateY(-3px); }

/* --------------------------------------------------------------------------
   6. Soulignés dessinés (nav + footer)
   -------------------------------------------------------------------------- */
nav a:not([class*="btn"]):not([class*="logo"]),
footer a:not([class*="btn"]):not([class*="logo"]) {
  position: relative;
  text-decoration: none;
  background-image: linear-gradient(90deg, var(--x-or), var(--x-or-clair));
  background-repeat: no-repeat;
  background-size: 0% 1px;
  background-position: 0 calc(100% - .05em);
  transition: background-size .55s var(--x-ease), color .3s ease;
  padding-bottom: .12em;
}
nav a:not([class*="btn"]):not([class*="logo"]):hover,
nav a:not([class*="btn"]):not([class*="logo"]):focus-visible,
footer a:not([class*="btn"]):not([class*="logo"]):hover,
footer a:not([class*="btn"]):not([class*="logo"]):focus-visible {
  background-size: 100% 1px;
}

/* --------------------------------------------------------------------------
   Mouvement réduit
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .x-cursor--ring,
  .x-cursor--ring span,
  .x-remonter,
  .x-remonter svg,
  .x-lightbox__btn,
  nav a,
  footer a {
    transition: none !important;
  }
}
