:root {
  --bg: #0e0d0b;
  --ink: #f3eee6;
  --muted: rgba(243, 238, 230, 0.66);
  --faint: rgba(243, 238, 230, 0.38);
  --line: rgba(243, 238, 230, 0.16);
  --accent: #dcb47c;
  --glass: rgba(14, 13, 11, 0.42);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --pad: clamp(20px, 4vw, 56px);
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; scrollbar-width: none; }
html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; }
html.loading { overflow: hidden; }
body { margin: 0; font-family: var(--sans); font-size: 15px; line-height: 1.5; background: var(--bg); overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.spacer { height: 800vh; pointer-events: none; }

#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; z-index: 0; }
#drag { position: fixed; inset: 0; z-index: 2; display: none; cursor: grab; touch-action: none; }
#drag.grabbing { cursor: grabbing; }
body.m360 #drag { display: block; }

/* ---------- Preloader ---------- */
#preloader { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; transition: opacity 1.1s ease, visibility 1.1s; }
#preloader.done { opacity: 0; visibility: hidden; }
.pre-inner { width: min(360px, 80vw); text-align: center; }
.pre-brand { font-family: var(--serif); font-weight: 300; font-size: 34px; letter-spacing: -0.01em; margin: 0 0 22px; }
#preloader .bar { height: 1px; background: var(--line); overflow: hidden; }
#preloader .bar i { display: block; height: 100%; background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform 0.4s ease; }
#preloader .status { margin: 14px 0 0; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint); }

/* ---------- UI general ---------- */
.ui { position: fixed; inset: 0; z-index: 3; pointer-events: none; }
/* Veladuras para que el texto lea sobre una escena clara */
.ui::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56vh; background: linear-gradient(to top, rgba(14, 13, 11, 0.8) 0%, rgba(14, 13, 11, 0.46) 42%, rgba(14, 13, 11, 0) 100%); transition: opacity 0.5s; }
.ui::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 18vh; background: linear-gradient(to bottom, rgba(14, 13, 11, 0.5), rgba(14, 13, 11, 0)); }
body.m360 .ui::before { opacity: 0.45; }
.ui button, .ui a { pointer-events: auto; }

.nav { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-between; padding: calc(var(--pad) * 0.6) var(--pad); transition: opacity 0.6s; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--serif); font-weight: 400; font-size: 20px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); margin-top: 3px; }
.controls { display: flex; gap: 6px; }
.ctl { display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 13px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 12.5px; font-weight: 500; letter-spacing: 0.01em; transition: background 0.25s, border-color 0.25s; }
.ctl:hover { background: rgba(243, 238, 230, 0.1); border-color: rgba(243, 238, 230, 0.3); }
.ctl .i { width: 15px; height: 15px; }
.ctl .on-on { display: none; }
.ctl[aria-pressed="true"] .on-on { display: block; }
.ctl[aria-pressed="true"] .on-off { display: none; }
.ctl[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.progress { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: rgba(243, 238, 230, 0.08); }
.progress i { display: block; height: 100%; background: var(--accent); transform: scaleX(0); transform-origin: left; }

.layer { position: absolute; transition: opacity 0.2s linear; }
.layer.off { pointer-events: none; visibility: hidden; }
.layer.off * { pointer-events: none !important; }

/* ---------- Hero ---------- */
#hero { left: var(--pad); right: var(--pad); bottom: calc(var(--pad) * 1.2); max-width: 720px; }
.eyebrow { margin: 0 0 14px; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
#hero h1 { margin: 0; font-family: var(--serif); font-weight: 300; font-size: clamp(2.6rem, 6.4vw, 6rem); line-height: 0.98; letter-spacing: -0.025em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 40px rgba(0, 0, 0, 0.45); }
#hero .lead { margin: 22px 0 0; max-width: 46ch; font-size: clamp(14px, 1.25vw, 16.5px); color: var(--ink); opacity: 0.86; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 26px; }
.btn { display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 20px; border-radius: 999px; font-size: 14px; font-weight: 500; border: 1px solid transparent; transition: transform 0.25s, background 0.25s, border-color 0.25s; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: var(--bg); }
.btn.primary:hover { background: #fff; }
.btn.ghost { border-color: var(--line); background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.btn.ghost:hover { border-color: rgba(243, 238, 230, 0.4); }
.btn.text { padding: 0 10px; color: var(--muted); }
.btn.text:hover { color: var(--ink); }
.btn .i { width: 16px; height: 16px; }
.scroll-hint { display: flex; align-items: center; gap: 10px; margin-top: 34px; color: var(--faint); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; transition: opacity 0.6s; }
.scroll-hint .i { width: 14px; height: 14px; animation: bob 1.8s ease-in-out infinite; }
.scroll-hint.gone { opacity: 0; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(5px); } }

/* ---------- Capítulos ---------- */
.captions { position: absolute; left: var(--pad); bottom: calc(var(--pad) * 1.2); width: min(520px, calc(100vw - 2 * var(--pad))); }
.caption { position: absolute; left: 0; bottom: 0; opacity: 0; will-change: opacity, transform; }
.caption .num { display: block; font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.caption p { margin: 0; font-family: var(--serif); font-weight: 300; font-size: clamp(1.25rem, 2.1vw, 1.85rem); line-height: 1.28; letter-spacing: -0.01em; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 2px 30px rgba(0, 0, 0, 0.5); }

.rail { position: absolute; right: var(--pad); top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; gap: 14px; align-items: flex-end; transition: opacity 0.6s; }
.rail button { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 12px; letter-spacing: 0.06em; transition: color 0.4s; }
.rail button i { font-style: normal; font-variant-numeric: tabular-nums; order: 2; width: 22px; text-align: right; }
.rail button span { opacity: 0; transform: translateX(6px); transition: opacity 0.4s, transform 0.4s; }
.rail button::after { content: ""; order: 3; width: 18px; height: 1px; background: currentColor; transition: width 0.4s; }
.rail button.on { color: var(--ink); }
.rail button.on span, .rail:hover button span { opacity: 1; transform: none; }
.rail button.on::after { width: 34px; background: var(--accent); }
.rail.dense { gap: 9px; }
.rail.dense button { font-size: 11px; }
.p-street { fill: rgba(243, 238, 230, 0.08); }
.p-road { fill: rgba(243, 238, 230, 0.03); }
.p-core { fill: rgba(220, 180, 124, 0.35); }
.p-pool { fill: rgba(120, 190, 220, 0.4); }

/* ---------- Final ---------- */
#final { left: 0; right: 0; bottom: 0; padding: 0 var(--pad) calc(var(--pad) * 0.9); background: linear-gradient(to top, rgba(14, 13, 11, 0.86) 40%, rgba(14, 13, 11, 0)); padding-top: 22vh; }
.final-inner { max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 28px 48px; align-items: end; }
.final-head h2 { margin: 0; font-family: var(--serif); font-weight: 300; font-size: clamp(2.4rem, 5vw, 4.6rem); line-height: 1; letter-spacing: -0.025em; }
.price { margin: 10px 0 0; font-family: var(--serif); font-weight: 400; font-size: clamp(1.3rem, 2vw, 1.8rem); color: var(--accent); }
.specs { margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.specs div { display: flex; flex-direction: column; gap: 3px; }
.specs dt { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.specs dd { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
#final .actions { grid-column: 1 / -1; margin-top: 4px; }
.credit { grid-column: 1 / -1; margin: 6px 0 0; font-size: 12px; color: var(--faint); }

/* ---------- Planta ---------- */
.plan { position: absolute; right: var(--pad); bottom: calc(var(--pad) * 1.1); display: flex; flex-direction: column; align-items: center; gap: 8px; opacity: 0.9; transition: opacity 0.5s, transform 0.5s; }
.plan svg { width: 76px; height: auto; overflow: visible; }
.p-room { fill: rgba(243, 238, 230, 0.05); stroke: rgba(243, 238, 230, 0.45); stroke-width: 1; }
.p-house { fill: rgba(243, 238, 230, 0.08); stroke: rgba(243, 238, 230, 0.7); stroke-width: 1.2; }
.p-fill { fill: rgba(243, 238, 230, 0.22); }
.p-lines { stroke: rgba(14, 13, 11, 0.5); stroke-width: 0.6; }
.p-tree { fill: rgba(150, 190, 120, 0.22); }
.cone { fill: rgba(220, 180, 124, 0.32); }
.dot { fill: var(--accent); }
.plan-label { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }
body.plan-off .plan { opacity: 0; transform: translateY(8px); }

/* ---------- Modo 360 ---------- */
.m360-ui { position: absolute; inset: 0; opacity: 0; transition: opacity 0.4s; pointer-events: none; }
body.m360 .m360-ui { opacity: 1; }
.pill { position: absolute; top: calc(var(--pad) * 0.6 + 50px); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 6px 0 14px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.pill .i { width: 15px; height: 15px; }
.pill b { color: var(--ink); font-weight: 500; }
.pill b::before { content: "·"; margin-right: 12px; color: var(--faint); }
#btn-exit { display: inline-flex; align-items: center; gap: 8px; height: 28px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--ink); color: var(--bg); font-size: 12px; font-weight: 500; }
#btn-exit .i { width: 13px; height: 13px; }
.nodes { position: absolute; left: 50%; bottom: calc(var(--pad) * 1.1); transform: translateX(-50%); display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.nodes button { height: 32px; padding: 0 14px; border-radius: 999px; font-size: 12.5px; color: var(--muted); transition: background 0.25s, color 0.25s; }
.nodes button:hover { color: var(--ink); }
.nodes button.on { background: var(--ink); color: var(--bg); }
body.m360 #hero, body.m360 .captions, body.m360 .rail, body.m360 #final { opacity: 0 !important; pointer-events: none; }
body.m360 .plan { opacity: 0.9; }

#hotspots .hot { position: absolute; left: -100px; top: -100px; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--ink); z-index: 4; }
#hotspots .hot[hidden] { display: none; }
#hotspots .hot i { position: relative; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--ink); background: rgba(243, 238, 230, 0.12); backdrop-filter: blur(4px); }
#hotspots .hot i::after { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--ink); }
#hotspots .hot i::before { content: ""; position: absolute; inset: -8px; border-radius: 50%; border: 1px solid rgba(243, 238, 230, 0.5); animation: pulse 2s ease-out infinite; }
#hotspots .hot span { font-size: 12px; letter-spacing: 0.06em; padding: 5px 11px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(8px); }
@keyframes pulse { 0% { transform: scale(0.7); opacity: 0.9; } 100% { transform: scale(1.5); opacity: 0; } }

/* ---------- Modo automático: barras de cine ---------- */
.bars i { position: absolute; left: 0; right: 0; height: 0; background: #000; transition: height 1.1s cubic-bezier(0.7, 0, 0.2, 1); }
.bars .top { top: 0; } .bars .bottom { bottom: 0; }
body.auto .bars i { height: 7vh; }
body.auto .nav, body.auto .rail, body.auto .plan { opacity: 0.55; }
body.auto .captions { bottom: calc(var(--pad) * 1.2 + 7vh); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .final-inner { grid-template-columns: 1fr; gap: 18px; }
  .specs { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .rail { display: none; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .ctl .lbl { display: none; }
  .ctl { width: 36px; padding: 0; justify-content: center; }
  .only-desk, .plan { display: none; }
  #hero { bottom: calc(var(--pad) * 1.6); }
  #hero h1 { font-size: clamp(2.3rem, 11vw, 3.4rem); }
  .captions { width: calc(100vw - 2 * var(--pad)); bottom: calc(var(--pad) * 1.6); }
  .caption p { font-size: 1.2rem; }
  .specs { grid-template-columns: repeat(2, 1fr); }
  .pill span { display: none; }
  .pill b::before { display: none; }
  .nodes { max-width: calc(100vw - 32px); overflow-x: auto; }
  #final { padding-top: 16vh; }
}
@media (prefers-reduced-motion: reduce) {
  .scroll-hint .i, #hotspots .hot i::before { animation: none; }
  .bars i, .btn, .ctl { transition: none; }
}
