/* Rentas Tulum v7 — Tulum en 3D.
   Un mundo 3D fijo detrás de TODA la página principal: la cámara viaja de zona en zona con el scroll.
   Capas (de atrás hacia adelante): .world (canvas) → .w3d-beacons (etiquetas de zona) → contenido.
   El contenido se divide en: opening (texto sobre velo), "paradas" transparentes (.interlude) donde se ve
   el mundo —una por zona— y paneles opacos (.panel) para leer y filtrar con calma. */

/* ——— Mundo fijo ——— */
.world {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  height: 100vh; height: 100lvh;
  /* Fondo ilustrado mientras carga (y sin WebGL): cielo → horizonte → arena → mar */
  background:
    radial-gradient(120% 60% at 70% 38%, rgba(255, 244, 222, .9), rgba(255, 244, 222, 0) 60%),
    linear-gradient(180deg, #a9cbd7 0%, #dfe7e2 42%, #f1efe7 58%, #d9cfb9 66%, #8fb8b4 78%, #4f8f95 100%);
}
.world canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 900ms var(--ease); }
html.w3d-ready .world canvas { opacity: 1; }

.w3d-beacons { position: fixed; inset: 0; z-index: 1; pointer-events: none; height: 100vh; height: 100lvh; overflow: hidden; }
.beacon {
  position: absolute; left: 0; top: 0; pointer-events: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer;
  opacity: 0; visibility: hidden; transition: opacity 320ms var(--ease), visibility 0s linear 320ms;
  will-change: transform; -webkit-tap-highlight-color: transparent;
}
.beacon.on { opacity: 1; visibility: visible; transition: opacity 320ms var(--ease), visibility 0s; }
.beacon span {
  order: 0; display: grid; text-align: center; line-height: 1.2; min-height: 48px; align-content: center;
  padding: 6px 14px; border-radius: 16px; white-space: nowrap;
  background: rgba(251, 250, 247, .95); box-shadow: var(--shadow-2); border: 1px solid rgba(255, 255, 255, .7);
  transition: transform var(--dur-fast) var(--ease), background-color var(--dur-fast) var(--ease);
}
.beacon b { font-size: .9375rem; font-weight: 650; }
.beacon small { font-size: .75rem; font-weight: 600; color: var(--gold-ink); }
.beacon.empty small { color: var(--muted); }
.beacon i { order: 1; width: 2px; height: 22px; background: linear-gradient(rgba(251, 250, 247, .95), rgba(251, 250, 247, 0)); position: relative; }
.beacon i::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; margin-left: -5px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px rgba(166, 124, 61, .28); }
.beacon:hover span { transform: translateY(-2px); background: #fff; }

/* ——— Capas de contenido sobre el mundo ——— */
main, .footer { position: relative; z-index: 2; }
/* Las zonas transparentes dejan pasar el toque al mundo (etiquetas); sólo sus tarjetas son interactivas */
.hero, .interlude, .contact { pointer-events: none; }
.hero-copy, .hero-pick, .scroll-cue, .il-card, .contact-card { pointer-events: auto; }

/* ——— Opening ——— */
.hero { position: relative; min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: -1;
  background: linear-gradient(180deg, rgba(243, 241, 236, .97) 0%, rgba(243, 241, 236, .92) 40%, rgba(243, 241, 236, 0) 70%);
}
.hero-inner {
  flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: calc(var(--topbar-h) + env(safe-area-inset-top) + clamp(1.25rem, .6rem + 2.4vw, 3rem)) var(--gutter) var(--s5);
  display: flex; flex-direction: column; gap: var(--s5);
}
.hero-copy { min-width: 0; max-width: 620px; }
.hero h1 { font-size: clamp(2.375rem, 1.5rem + 3.6vw, 4.75rem); font-weight: 700; letter-spacing: -.035em; line-height: 1; max-width: 12ch; }
.hero-sub { margin-top: var(--s4); max-width: 42ch; font-size: clamp(1.0625rem, 1rem + .3vw, 1.25rem); color: var(--ink-2); }
.hero .hero-search { margin-top: var(--s5); }
.hero-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: calc(var(--gutter) * -1); padding: 2px var(--gutter); scroll-padding-inline: var(--gutter); }
.hero-chips::-webkit-scrollbar { display: none; }
.hero-chips .chip { flex: none; background: rgba(255, 255, 255, .9); }
.hero-count { margin-top: var(--s4); }

.hero-pick {
  align-self: flex-start; margin-top: auto; max-width: min(100%, 380px);
  display: flex; align-items: center; gap: .75em; min-height: 60px; padding: 6px 16px 6px 6px;
  border-radius: 18px; background: rgba(251, 250, 247, .96); box-shadow: var(--shadow-3);
  text-decoration: none; color: var(--ink); transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.hero-pick:hover { transform: translateY(-2px); }
.hero-pick img { width: 48px; height: 48px; flex: none; border-radius: 12px; object-fit: cover; background: var(--sand); }
.hero-pick span { min-width: 0; display: grid; line-height: 1.25; }
.hero-pick b { font-size: .9375rem; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-pick small { font-size: .8125rem; color: var(--gold-ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.scroll-cue {
  position: absolute; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: .6em; min-height: 48px; padding: 0 1.1em;
  border-radius: var(--r-pill); background: rgba(251, 250, 247, .92); box-shadow: var(--shadow-2);
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.scroll-cue i { width: 14px; height: 22px; border: 2px solid currentColor; border-radius: 8px; position: relative; flex: none; }
.scroll-cue i::after { content: ""; position: absolute; left: 50%; top: 4px; width: 2px; height: 5px; margin-left: -1px; border-radius: 2px; background: currentColor; animation: cue 1.8s var(--ease) infinite; }
@keyframes cue { 0% { transform: translateY(0); opacity: 1; } 70% { transform: translateY(7px); opacity: 0; } 100% { transform: translateY(0); opacity: 0; } }

/* Escritorio: velo lateral, texto a la izquierda, el mundo respira a la derecha */
@media (min-width: 1024px) {
  .hero::before { background: linear-gradient(90deg, rgba(243, 241, 236, .97) 0%, rgba(243, 241, 236, .9) 36%, rgba(243, 241, 236, 0) 64%); }
  .hero-inner { justify-content: center; padding-bottom: calc(var(--s9) + var(--s4)); }
  .hero-chips { flex-wrap: wrap; overflow: visible; margin-inline: 0; padding: 0; }
  .hero-pick { position: absolute; right: var(--gutter); bottom: calc(var(--s5) + 4px); margin: 0; }
  .scroll-cue { left: var(--gutter); transform: none; }
}
@media (min-width: 1368px) { .hero-pick { right: calc((100% - var(--maxw)) / 2 + var(--gutter)); } .scroll-cue { left: calc((100% - var(--maxw)) / 2 + var(--gutter)); } }
/* Móvil: el opening no ocupa más de lo necesario; el mundo se ve debajo del buscador */
@media (max-width: 1023px) {
  .hero-count { display: none; }
  .hero-pick { margin-bottom: calc(var(--dock-h) + 40px + env(safe-area-inset-bottom)); }
  .scroll-cue { display: none; }
}
@media (max-width: 1023px) and (max-height: 700px) { .hero-sub { display: none; } }
@media (max-width: 380px) { .hero-pick small { display: none; } }

/* ——— Paradas del recorrido (el mundo a la vista): una por zona ——— */
.interlude {
  position: relative; min-height: 96vh; min-height: 96svh;
  display: flex; align-items: center;
  max-width: var(--maxw); margin: 0 auto; padding: var(--s8) var(--gutter);
}
.il-right { justify-content: flex-end; }
.il-card {
  width: min(100%, 440px); display: grid; gap: var(--s3);
  padding: clamp(1.25rem, .9rem + 1.6vw, 2rem); border-radius: var(--r-xl);
  background: rgba(251, 250, 247, .95); box-shadow: var(--shadow-3); border: 1px solid rgba(255, 255, 255, .7);
}
.il-card .kicker { margin-bottom: 0; }
.il-card h2 { font-size: clamp(1.875rem, 1.4rem + 2vw, 3rem); }
.il-text { color: var(--ink-2); max-width: 40ch; }
.il-devs { margin: 0; color: var(--gold-ink); font-size: .875rem; font-weight: 600; line-height: 1.4; }
.il-thumbs { display: flex; gap: var(--s2); }
.il-thumbs:empty { display: none; }
.il-thumbs a { flex: none; width: 72px; height: 72px; border-radius: 14px; overflow: hidden; background: var(--sand); box-shadow: var(--shadow-1); transition: transform var(--dur-fast) var(--ease); }
.il-thumbs a:hover { transform: translateY(-2px); }
.il-thumbs a:focus-visible { outline: none; box-shadow: var(--focus); }
.il-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.il-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s1); }
.il-n { display: inline-grid; place-items: center; min-width: 1.75em; height: 1.75em; padding: 0 .45em; margin-left: .15em; border-radius: var(--r-pill); background: rgba(255, 255, 255, .18); font-size: .875em; }
.il-n:empty { display: none; }
@media (max-width: 1023px) {
  /* La tarjeta se queda pegada sobre el dock mientras la parada está en pantalla; el mundo ocupa la mitad superior */
  .interlude { min-height: 92vh; min-height: 92svh; align-items: flex-end; padding-bottom: var(--s4); }
  .il-right { justify-content: flex-start; }
  .il-card { position: sticky; bottom: calc(var(--dock-h) + 20px + env(safe-area-inset-bottom)); gap: var(--s2); }
  .il-thumbs a { width: 56px; height: 56px; border-radius: 12px; }
}
@media (max-width: 640px), (max-width: 1023px) and (max-height: 720px) { .il-text { display: none; } }

/* ——— Paneles opacos (leer, filtrar, comparar) ——— */
.panel {
  position: relative; background: var(--bg);
  border-radius: var(--r-xl); box-shadow: 0 -8px 40px rgba(42, 33, 25, .08), 0 24px 60px rgba(42, 33, 25, .1);
  margin-inline: clamp(0px, 1.6vw - 8px, 24px);
}
.panel > .section { padding-bottom: var(--section-pad); }
@media (max-width: 1023px) { .panel { margin-inline: 0; border-radius: 26px; } }

/* Contacto: tarjeta con el formulario sobre el atardecer en las ruinas */
.contact { min-height: 100vh; min-height: 100svh; display: flex; align-items: center; }
.contact-card { width: min(100%, 920px); margin-inline: 0 auto; background: linear-gradient(135deg, rgba(255, 253, 248, .97), rgba(232, 224, 210, .96)); box-shadow: var(--shadow-3); }
/* En escritorio la tarjeta va a la izquierda y las ruinas al atardecer se ven a la derecha */
@media (max-width: 1023px) { .contact { align-items: flex-end; padding-bottom: calc(var(--s6) + env(safe-area-inset-bottom)); } }
@media (max-width: 640px) {
  .contact-card { gap: var(--s4); padding: var(--s5); }
  .contact-card h2 { font-size: 1.75rem; }
}

/* Pie: panel opaco de ancho completo; en móvil el espacio del dock queda dentro del pie */
.footer {
  max-width: none; margin: 0; border-top: 0; background: var(--bg);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding-inline: max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
}
@media (max-width: 1023px) {
  body { padding-bottom: 0; }
  .footer { padding-bottom: calc(var(--dock-h) + 36px + env(safe-area-inset-bottom)); }
}

/* La barra superior se aclara un poco más sobre el mundo */
html.w3d-on .topbar:not(.scrolled), html.w3d-static .topbar:not(.scrolled) { background: rgba(243, 241, 236, .72); }

/* ——— Sin WebGL: fondo ilustrado + fotos reales de cada zona ——— */
html.w3d-nogl .hero { background: var(--hero-photo, none) center / cover no-repeat; }
html.w3d-nogl .interlude {
  max-width: none; margin: 0;
  padding-inline: max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  background: var(--il-photo, none) center / cover no-repeat;
  min-height: 80vh; min-height: 80svh;
}

/* ——— Entrada 3D de los bloques al hacer scroll ——— */
html.w3d-rise .rise { opacity: 0; transform: perspective(1200px) translate3d(0, 48px, -60px) rotateX(14deg); transform-origin: 50% 100%; transition: opacity 900ms var(--ease), transform 1100ms var(--ease); }
html.w3d-rise .rise.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html.w3d-rise .rise { opacity: 1 !important; transform: none !important; }
  .world canvas, .beacon { transition: none; }
  .scroll-cue i::after { animation: none; }
}
