/* ============================================================
   CASA RIVAS MERCADO — Capa moderna compartida
   Animaciones, cursor, progreso de scroll, nav transformante,
   reveals, comparador antes/después. Aditiva: respeta la
   identidad existente (verde bosque + oro, Cinzel + Inter).
   ============================================================ */

::selection { background: rgba(181,155,92,.35); color: #fff; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---- Tipografía con un punto extra de finura ---- */
body { text-rendering: optimizeLegibility; }
h1, h2, h3, h4 { text-wrap: balance; }
p { text-wrap: pretty; }

/* ============================================================
   1 · BARRA DE PROGRESO DE SCROLL
   ============================================================ */
.scroll-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 100%;
  transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, #8a7434, var(--gold, #b59b5c) 40%, var(--gold-light, #d4c08c));
  z-index: 300; will-change: transform;
  box-shadow: 0 0 14px rgba(181,155,92,.6);
  pointer-events: none;
}

/* ============================================================
   2 · NAV TRANSFORMANTE
   ============================================================ */
nav {
  transition: height .45s cubic-bezier(.22,1,.36,1),
              background .45s ease, border-color .45s ease,
              box-shadow .45s ease;
  will-change: height, background;
}
body > nav.scrolled {
  height: 62px !important;
  background: rgba(12,20,7,.9) !important;
  border-bottom-color: rgba(181,155,92,.28) !important;
  box-shadow: 0 10px 40px -16px rgba(0,0,0,.8);
}
body > nav.scrolled .nav-logo img { height: 42px; }
body > nav.scrolled .nav-fundacion img { height: 36px; }
body > nav .nav-logo img { transition: height .45s cubic-bezier(.22,1,.36,1); }
body > nav .nav-fundacion img { transition: height .45s cubic-bezier(.22,1,.36,1), opacity .3s; }

/* Subrayado animado en enlaces del nav */
.nav-links a { position: relative; }
.nav-links a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -7px;
  height: 1px; background: var(--gold, #b59b5c);
  transition: right .35s cubic-bezier(.22,1,.36,1);
}
.nav-links a:hover::after, .nav-links a.active::after { right: 0; }

/* Evita que la barra se sature en tablets (botón Reservar se recortaba) */
@media (max-width: 1140px) {
  body > nav .nav-fundacion { display: none; }
  body > nav .nav-links { gap: 24px; }
  body > nav .nav-actions { gap: 0; }
}

/* ============================================================
   3 · CURSOR IMÁN DORADO  (solo punteros finos)
   ============================================================ */
.cursor-dot, .cursor-ring { display: none; }
@media (hover: hover) and (pointer: fine) {
  body.has-cursor { cursor: none; }
  body.has-cursor a, body.has-cursor button { cursor: none; }
  .cursor-dot, .cursor-ring {
    display: block; position: fixed; top: 0; left: 0;
    border-radius: 50%; pointer-events: none; z-index: 9999;
    transform: translate(-50%, -50%); will-change: transform;
  }
  .cursor-dot {
    width: 7px; height: 7px; background: var(--gold-light, #d4c08c);
    transition: width .25s, height .25s, background .25s;
  }
  .cursor-ring {
    width: 34px; height: 34px; border: 1px solid rgba(181,155,92,.55);
    transition: width .3s cubic-bezier(.22,1,.36,1), height .3s cubic-bezier(.22,1,.36,1),
                border-color .3s, background .3s, opacity .3s;
  }
  body.cursor-hover .cursor-ring {
    width: 64px; height: 64px; border-color: var(--gold, #b59b5c);
    background: rgba(181,155,92,.1);
  }
  body.cursor-hover .cursor-dot { width: 4px; height: 4px; }
  body.cursor-down .cursor-ring { width: 26px; height: 26px; }
}

/* ============================================================
   4 · REVEALS AL HACER SCROLL
   ============================================================ */
[data-reveal] {
  opacity: 0;
  transform: translateY(34px);
  transition: opacity .9s cubic-bezier(.22,1,.36,1),
              transform .9s cubic-bezier(.22,1,.36,1);
  transition-delay: var(--reveal-delay, 0ms);
  will-change: opacity, transform;
}
[data-reveal="left"]  { transform: translateX(-44px); }
[data-reveal="right"] { transform: translateX(44px); }
[data-reveal="scale"] { transform: scale(.92); }
[data-reveal="blur"]  { filter: blur(12px); transform: translateY(20px); }
[data-reveal].in {
  opacity: 1; transform: none; filter: none;
}
@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
}

/* Texto que se revela palabra por palabra / línea */
.reveal-line { display: block; overflow: hidden; }
.reveal-line > span {
  display: block;
  transform: translateY(110%);
  transition: transform 1s cubic-bezier(.22,1,.36,1);
  transition-delay: var(--line-delay, 0ms);
}
.reveal-line.in > span { transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .reveal-line > span { transform: none !important; }
}

/* ============================================================
   5 · BOTONES IMÁN / BRILLO
   ============================================================ */
.mag { will-change: transform; transition: transform .35s cubic-bezier(.22,1,.36,1); }
.btn-primary, .btn-reservar { position: relative; overflow: hidden; }
.btn-primary::before, .btn-reservar::before {
  content: ''; position: absolute; top: 0; left: -130%;
  width: 60%; height: 100%;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.55), transparent);
  transform: skewX(-20deg); pointer-events: none;
}
.btn-primary:hover::before, .btn-reservar:hover::before {
  animation: sheen .9s cubic-bezier(.22,1,.36,1);
}
@keyframes sheen { to { left: 140%; } }
@media (prefers-reduced-motion: reduce) {
  .btn-primary:hover::before, .btn-reservar:hover::before { animation: none; }
}

/* ============================================================
   6 · BOTÓN VOLVER ARRIBA
   ============================================================ */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 250;
  width: 50px; height: 50px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(18,29,10,.8); backdrop-filter: blur(10px);
  border: 1px solid rgba(181,155,92,.35); color: var(--gold, #b59b5c);
  opacity: 0; transform: translateY(20px) scale(.8); pointer-events: none;
  transition: opacity .4s, transform .4s cubic-bezier(.22,1,.36,1), background .25s, border-color .25s;
}
.to-top.show { opacity: 1; transform: none; pointer-events: auto; }
.to-top:hover { background: var(--gold, #b59b5c); color: var(--forest-dark, #121d0a); border-color: var(--gold, #b59b5c); }
.to-top svg { width: 18px; height: 18px; }

/* ============================================================
   7 · COMPARADOR ANTES / DESPUÉS
   ============================================================ */
.compare {
  position: relative; width: 100%; aspect-ratio: 16 / 10;
  overflow: hidden; user-select: none; touch-action: pan-y;
  border: 1px solid rgba(181,155,92,.2);
  box-shadow: 0 30px 80px -24px rgba(0,0,0,.7);
  cursor: ew-resize;
}
.compare img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; pointer-events: none;
}
.compare .after-wrap {
  position: absolute; inset: 0;
  width: var(--split, 50%); overflow: hidden;
  border-right: 2px solid rgba(242,237,224,.9);
}
.compare .after-wrap img { width: 100vw; max-width: none; }
.compare .c-label {
  position: absolute; bottom: 16px; z-index: 4;
  font-family: 'Cinzel', serif; font-size: .58rem; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase;
  padding: 7px 14px; background: rgba(12,20,7,.72); backdrop-filter: blur(6px);
  color: var(--gold, #b59b5c); border: 1px solid rgba(181,155,92,.3);
}
.compare .c-label.before { right: 16px; }
.compare .c-label.after  { left: 16px; }
.compare .handle {
  position: absolute; top: 0; bottom: 0; left: var(--split, 50%);
  width: 2px; background: rgba(242,237,224,.9); transform: translateX(-1px);
  z-index: 5; pointer-events: none;
}
.compare .handle::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 52px; height: 52px; transform: translate(-50%, -50%);
  border-radius: 50%; background: rgba(18,29,10,.85); backdrop-filter: blur(8px);
  border: 1px solid var(--gold, #b59b5c);
  box-shadow: 0 0 0 6px rgba(181,155,92,.12), 0 8px 30px rgba(0,0,0,.5);
}
.compare .handle .arrows {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 6; color: var(--gold, #b59b5c); font-size: 1rem; letter-spacing: 2px;
}
@media (max-width: 600px) {
  .compare { aspect-ratio: 4 / 5; }
}

/* Utilidad: aparición suave del contenido al cargar (sin ocultar el body) */
body { opacity: 1; }
.page-fade { animation: pageFade .7s ease both; }
@keyframes pageFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .page-fade { animation: none; } }
