/* ============================================================
   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; }
}

/* Los elementos con animación de entrada (data-reveal="right"/"left")
   empiezan desplazados ±44px y ensanchan el documento antes de
   revelarse: en móvil eso permite panear/alejar la página y descuadra
   el nav sticky. "clip" recorta ese excedente sin crear un contenedor
   de scroll (a diferencia de "hidden", no rompe position: sticky). */
html, body { overflow-x: clip; }

/* ---- 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;
}
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; }

/* En móvil, la barra de direcciones del navegador se contrae/expande
   dinámicamente durante el scroll, cambiando la altura del viewport
   al mismo tiempo que estas transiciones. Esa doble animación de
   tamaño puede producir un parpadeo/recorte del logo en algunos
   navegadores. Se evita haciendo el cambio de tamaño instantáneo. */
@media (max-width: 768px) {
  nav, body > nav.scrolled { transition: background .45s ease, border-color .45s ease, box-shadow .45s ease; }
  body > nav .nav-logo img, body > nav .nav-fundacion img { transition: none; }
}

/* 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; }
@media (max-width: 480px) {
  .to-top { right: 14px; bottom: 14px; width: 40px; height: 40px; }
  .to-top svg { width: 15px; height: 15px; }
}

/* ============================================================
   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; } }

/* ============================================================
   8 · CAPA COMPARTIDA DE LAYOUT
   Componentes idénticos en Inicio, Restauración, Actividades y
   Jardín: variables, reset, nav, footer, breadcrumb, hero de
   página interior, carrusel de galería y lightbox. Extraído de
   los <style> de cada página para que el navegador lo cachee
   una sola vez. Cada página conserva en su propio <style> lo
   que le es exclusivo (p. ej. el hero día/noche del Inicio, o
   el layout de tarjetas de Actividades).
   ============================================================ */
:root {
  --forest:      #223311;
  --forest-dark: #121d0a;
  --gold:        #b59b5c;
  --gold-light:  #d4c08c;
  --cream:       #f2ede0;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--forest-dark);
  color: var(--cream);
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { font-family: 'Cinzel', serif; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

/* Contenedor y tipografía de sección */
.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }
.section-label { font-family: 'Cinzel', serif; font-size: .62rem; font-weight: 600; letter-spacing: .55em; text-transform: uppercase; color: var(--gold); margin-bottom: 16px; }
.section-title { font-family: 'Cinzel', serif; font-size: clamp(1.8rem,3.5vw,3rem); font-weight: 700; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 20px; }
.gold-rule { width: 80px; height: 2px; background: var(--gold); }
.gold-rule.center { margin: 0 auto; }

/* Nav: estructura interna compartida (cada página define su propia regla base "nav{}" con position:fixed/sticky) */
.nav-inner { max-width: 1280px; margin: 0 auto; padding: 0 24px; width: 100%; display: flex; align-items: center; justify-content: space-between; }
.nav-logo { display: flex; align-items: center; gap: 14px; flex: 1 1 0; }
.nav-logo img { height: 76px; width: auto; }
.nav-actions { flex: 1 1 0; display: flex; align-items: center; justify-content: flex-end; gap: 18px; }
.nav-brand { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700; letter-spacing: .22em; color: var(--gold); line-height: 1.2; }
.nav-links { display: flex; align-items: center; justify-content: center; gap: 36px; flex: 0 1 auto; }
.nav-fundacion { display: flex; align-items: center; gap: 18px; }
.nav-fundacion .nav-divider { width: 1px; height: 38px; background: rgba(181,155,92,.28); }
.nav-fundacion img { height: 54px; width: auto; opacity: .95; }
.nav-links a { font-size: .72rem; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: rgba(242,237,224,.75); transition: color .2s; }
.nav-links a:hover, .nav-links a.active { color: var(--gold); }
.nav-links a:last-child { margin-right: 28px; }
.btn-reservar { background: var(--gold); color: var(--forest-dark); padding: 12px 28px; font-family: 'Cinzel', serif; font-size: .68rem; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; transition: background .2s, box-shadow .2s; white-space: nowrap; }
.btn-reservar:hover { background: var(--gold-light); box-shadow: 0 0 24px rgba(181,155,92,.45); }
.hamburger { display: none; flex-direction: column; gap: 5px; cursor: pointer; background: none; border: 0; }
.hamburger span { display: block; width: 26px; height: 2px; background: var(--gold); }
.mobile-menu { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(18,29,10,.98); flex-direction: column; align-items: center; justify-content: center; gap: 32px; }
.mobile-menu.open { display: flex; }
.mobile-menu a { font-family: 'Cinzel', serif; font-size: 1.1rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.mobile-menu a.btn-reservar { color: var(--forest-dark); font-size: .68rem; }
.mobile-menu .close-btn { position: absolute; top: 28px; right: 28px; background: none; border: none; color: var(--gold); font-size: 2rem; cursor: pointer; }
.mobile-menu-fundacion { display: flex; align-items: center; gap: 10px; opacity: .85; }
.mobile-menu-fundacion img { height: 46px; width: auto; }
@media (max-width: 768px) {
  .nav-links { display: none; }
  .nav-actions { display: none; }
  .hamburger { display: flex; }
}

/* Breadcrumb (páginas interiores) */
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: .7rem; color: rgba(242,237,224,.45); margin-bottom: 24px; }
.breadcrumb a { color: rgba(181,155,92,.7); transition: color .2s; }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb span { color: rgba(242,237,224,.3); }

/* Hero de página interior (Restauración, Actividades, Jardín) */
.page-hero { position: relative; height: 60vh; min-height: 420px; display: flex; align-items: flex-end; padding-bottom: 64px; overflow: hidden; }
.page-hero-bg { position: absolute; inset: 0; }
.page-hero-bg img { width: 100%; height: 100%; object-fit: cover; }
.page-hero-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(18,29,10,1) 0%, rgba(18,29,10,.5) 50%, rgba(18,29,10,.3) 100%); }
.page-hero-content { position: relative; z-index: 2; max-width: 1280px; margin: 0 auto; padding: 0 24px; width: 100%; }

/* Carrusel de galería (Espacios y Detalles, Restauración, Jardín) */
.galeria-carrusel-wrap { position: relative; overflow: hidden; }
.galeria-track { display: flex; gap: 12px; transition: transform .5s cubic-bezier(.22,1,.36,1); will-change: transform; }
.galeria-slide { flex: 0 0 calc(33.33% - 8px); min-width: 0; position: relative; overflow: hidden; border: 1px solid rgba(181,155,92,.12); }
.galeria-slide img { width: 100%; height: 300px; object-fit: cover; filter: brightness(.85); transition: transform .6s, filter .5s; cursor: zoom-in; }
.galeria-slide:hover img { transform: scale(1.05); filter: brightness(1); }
.galeria-controls { display: flex; flex-wrap: nowrap; justify-content: center; align-items: center; gap: 20px; margin-top: 28px; }
.galeria-btn { width: 48px; height: 48px; flex: none; border: 1px solid rgba(181,155,92,.3); background: rgba(181,155,92,.06); color: var(--gold); font-size: 1.4rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.galeria-btn:hover { background: rgba(181,155,92,.18); border-color: var(--gold); }
.galeria-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; flex: 1 1 0; min-width: 0; }
.galeria-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(181,155,92,.25); cursor: pointer; transition: background .2s, transform .2s; border: none; }
.galeria-dot.active { background: var(--gold); transform: scale(1.4); }
@media (max-width: 1024px) { .galeria-slide { flex: 0 0 calc(50% - 6px); } }
@media (max-width: 768px) { .galeria-slide { flex: 0 0 100%; } }

/* Footer */
footer { background: #000; border-top: 1px solid rgba(181,155,92,.12); padding: 80px 24px 48px; }
.footer-inner { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; gap: 48px; text-align: center; }
.footer-logo img { height: 72px; width: auto; opacity: .85; }
.footer-brand { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 300; letter-spacing: .6em; color: var(--gold); margin-top: 12px; }
.footer-sub { font-family: 'Cinzel', serif; font-size: .55rem; letter-spacing: .5em; color: rgba(181,155,92,.55); text-transform: uppercase; margin-top: 6px; }
.footer-divider { width: 120px; height: 1px; background: linear-gradient(to right, transparent, rgba(181,155,92,.45), transparent); }
.footer-social { display: flex; flex-wrap: wrap; justify-content: center; gap: 40px; }
.footer-social a { font-family: 'Cinzel', serif; font-size: .6rem; letter-spacing: .22em; text-transform: uppercase; color: rgba(181,155,92,.8); transition: color .2s; }
.footer-social a:hover { color: #fff; }
.footer-contact { font-size: .7rem; letter-spacing: .15em; color: rgba(212,192,140,.85); line-height: 2; }
.footer-legal { font-size: .7rem; font-style: italic; letter-spacing: .1em; color: rgba(242,237,224,.2); }

/* Lightbox (ampliar fotos) */
.lightbox { position: fixed; inset: 0; z-index: 500; background: rgba(6,10,4,.94); display: none; align-items: center; justify-content: center; padding: 56px 100px; cursor: zoom-out; }
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border: 1px solid rgba(181,155,92,.25); box-shadow: 0 24px 80px rgba(0,0,0,.6); cursor: default; }
.lightbox-close {
  position: absolute; top: 28px; right: 32px; z-index: 2;
  background: rgba(181,155,92,.1); border: 1px solid rgba(181,155,92,.45); color: var(--gold);
  width: 64px; height: 64px; font-size: 2.6rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.lightbox-close:hover { background: rgba(181,155,92,.2); border-color: var(--gold); }
.lightbox-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  background: rgba(181,155,92,.1); border: 1px solid rgba(181,155,92,.45); color: var(--gold);
  width: 60px; height: 60px; font-size: 1.8rem; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.lightbox-nav:hover { background: rgba(181,155,92,.2); border-color: var(--gold); }
.lightbox-nav.prev { left: 24px; }
.lightbox-nav.next { right: 24px; }
.lightbox-nav[hidden] { display: none; }
@media (max-width: 768px) {
  .lightbox { padding: 80px 16px; }
  .lightbox-close { top: 12px; right: 12px; width: 48px; height: 48px; font-size: 2rem; }
  .lightbox-nav { width: 46px; height: 46px; font-size: 1.4rem; }
  .lightbox-nav.prev { left: 8px; }
  .lightbox-nav.next { right: 8px; }
}

/* ============================================================
   9 · CORRECCIÓN RESPONSIVE: ITEMS DE GRID/FLEX
   Por defecto, un hijo de grid o flex no se encoge más allá del
   ancho de su propio contenido ("min-width: auto" implícito). Con
   títulos en mayúsculas y letras espaciadas (Cinzel + letter-spacing)
   eso puede forzar una columna más ancha que la pantalla y romper
   el layout en móvil. Este min-width:0 lo corrige sin cambiar nada
   en escritorio, donde sobra espacio de todos modos.
   ============================================================ */
.historia-grid > *,
.texto-grid > *,
.intro-grid > *,
.jardin-intro-grid > *,
.visita-cards > .card,
.visita-extra > *,
.act-grid > .act-card,
.dual-compare > * {
  min-width: 0;
}
