* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night-900); }
body { font: var(--text-base)/1.45 var(--font-ui); color: var(--paper); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

#app { position: fixed; inset: 0; opacity: 0; transition: opacity 600ms ease; }
#app.ready { opacity: 1; }

/* Escenario */
.stage { position: absolute; inset: 0; touch-action: none; cursor: grab; user-select: none; }
.stage:active { cursor: grabbing; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hotspots { position: absolute; inset: 0; pointer-events: none; }
.walking .hotspots, .focus .hotspots { visibility: hidden; }

.hotspot {
  position: absolute; left: 0; top: 0; padding: 0; border: 0; background: transparent;
  pointer-events: auto; border-radius: 3px; cursor: pointer;
  transition: box-shadow var(--duration-fast), background var(--duration-fast);
}
.hotspot:hover, .hotspot:focus-visible {
  background: rgb(255 255 255 / 0.12);
  box-shadow: 0 0 0 1.5px var(--accent), 0 10px 24px -8px rgb(0 0 0 / 0.6);
}
/* Al llegar a una escena, un brillo recorre los libros tocables y desaparece */
.hotspots.reveal .hotspot { animation: reveal 1.5s var(--ease-out-expo) both; }
.hotspots.reveal .hotspot::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  background: linear-gradient(105deg, transparent 30%, rgb(255 255 255 / 0.55) 50%, transparent 70%) 200% 0 / 250% 100% no-repeat;
  animation: sheen 1.3s 0.15s ease-out both;
}
@keyframes reveal { 0%, 70% { box-shadow: 0 0 0 1.5px rgb(255 90 54 / 0.9); } 100% { box-shadow: 0 0 0 1.5px transparent; } }
@keyframes sheen { to { background-position: -100% 0; } }

/* Barra superior */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(var(--edge) * 0.8) var(--edge); pointer-events: none;
  background: linear-gradient(rgb(10 10 10 / 0.7), transparent);
}
.topbar > * { pointer-events: auto; }
.brand { display: grid; line-height: 1.1; }
.brand-name { font: 400 1.5rem var(--font-display); letter-spacing: 0; color: var(--accent); }
.brand-sub { font-size: var(--text-sm); color: rgb(245 242 236 / 0.7); }
.sector {
  margin: 0; display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: var(--radius-pill);
  background: rgb(17 17 17 / 0.62); backdrop-filter: blur(10px); font-weight: 500; font-size: 0.9rem;
  border: 1px solid rgb(255 90 54 / 0.25);
}
.sector-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.cart-btn {
  justify-self: end; position: relative; width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgb(255 90 54 / 0.35);
  background: rgb(17 17 17 / 0.62); backdrop-filter: blur(10px); display: grid; place-items: center;
}
.cart-btn svg { width: 22px; height: 22px; }
.cart-count {
  position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px;
  background: var(--accent); color: var(--night-900); font-size: 0.72rem; font-weight: 600; display: grid; place-items: center;
  transform: scale(0); transition: transform var(--duration-normal) var(--ease-out-expo);
}
.cart-btn.has-items .cart-count { transform: scale(1); }
.cart-btn.bump .cart-count { animation: bump 450ms var(--ease-out-expo); }
@keyframes bump { 40% { transform: scale(1.45); } }

/* Flechas para caminar */
.walk { position: absolute; inset: 0; pointer-events: none; }
.arrow {
  position: absolute; pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px 10px 12px; border-radius: var(--radius-pill); border: 1px solid rgb(245 242 236 / 0.28);
  background: rgb(17 17 17 / 0.55); backdrop-filter: blur(12px); font-weight: 500; font-size: 0.9rem;
  transition: transform var(--duration-normal) var(--ease-out-expo), background var(--duration-fast), opacity var(--duration-normal);
}
.arrow:hover { background: rgb(38 38 38 / 0.85); border-color: var(--accent); }
.arrow:active { transform: var(--rest) scale(0.95); }
.chev { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.chev::before {
  content: ''; position: absolute; inset: 0; margin: auto; width: 8px; height: 8px;
  border: solid var(--night-900); border-width: 2.2px 2.2px 0 0; transform: translate(-1px, 2px) rotate(-45deg);
}
.arrow[data-dir="up"] { --rest: translateX(-50%); left: 50%; top: calc(var(--edge) * 4.2); transform: var(--rest); }
.arrow[data-dir="down"] { --rest: translateX(-50%); left: 50%; bottom: calc(var(--edge) * 1.1); transform: var(--rest); }
.arrow[data-dir="down"] .chev::before { transform: translate(-1px, -2px) rotate(135deg); }
.arrow[data-dir="left"] { --rest: translateY(-50%); left: var(--edge); top: 50%; transform: var(--rest); }
.arrow[data-dir="left"] .chev::before { transform: translate(2px, 0) rotate(-135deg); }
.arrow[data-dir="right"] { --rest: translateY(-50%); right: var(--edge); top: 50%; transform: var(--rest); flex-direction: row-reverse; padding: 10px 12px 10px 16px; }
.arrow[data-dir="right"] .chev::before { transform: translate(-2px, 0) rotate(45deg); }
.walking .arrow, .focus .arrow, .focus .intro, .walking .intro, .focus .hint, .walking .hint,
.focus .assistant-btn, .focus .topbar .sector, .focus .topbar .brand, .focus #find-btn, .focus #share-btn, .focus #admin-btn { opacity: 0; pointer-events: none; }
.focus .hint, .walking .hint { visibility: hidden; }

/* Vidriera: presentación */
.intro {
  position: absolute; left: var(--edge); bottom: calc(var(--edge) * 1.2); max-width: 480px; padding: 26px 26px 24px;
  border-radius: var(--radius-panel); background: rgb(17 17 17 / 0.78); backdrop-filter: blur(14px);
  border: 1px solid rgb(255 90 54 / 0.22); box-shadow: var(--shadow-panel);
  opacity: 0; transform: translateY(16px); pointer-events: none;
  transition: opacity 500ms var(--ease-out-expo), transform 500ms var(--ease-out-expo);
}
.at-window:not(.focus):not(.walking) .intro { opacity: 1; transform: none; pointer-events: auto; }
.at-window .assistant-btn, .at-window .arrow[data-dir="up"] { opacity: 0; pointer-events: none; }
.intro-kicker { margin: 0 0 10px; font-size: var(--text-sm); color: var(--accent); letter-spacing: 0.02em; }
.intro h1 { margin: 0 0 12px; font: 400 var(--text-hero)/0.92 var(--font-display); letter-spacing: -0.02em; }
.intro h1 em { font-style: italic; color: var(--accent); }
.intro-copy { margin: 0 0 20px; color: rgb(245 242 236 / 0.82); }

.btn-primary {
  border: 0; border-radius: var(--radius-pill); padding: 13px 22px; background: var(--accent); color: var(--night-900);
  font-weight: 600; transition: background var(--duration-fast), transform var(--duration-fast);
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:active { transform: scale(0.97); }
.btn-primary span { display: inline-block; transition: transform var(--duration-normal) var(--ease-out-expo); }
.btn-primary:hover span { transform: translateX(4px); }
.btn-ghost { border: 1px solid rgb(28 27 23 / 0.2); border-radius: var(--radius-pill); padding: 12px 18px; background: transparent; font-weight: 500; }
.btn-ghost:hover { border-color: var(--ink); }

.hint {
  position: absolute; left: 50%; bottom: calc(var(--edge) * 4.6); transform: translateX(-50%); margin: 0;
  padding: 7px 14px; border-radius: var(--radius-pill); background: rgb(0 0 0 / 0.45); font-size: var(--text-sm);
  white-space: nowrap; pointer-events: none; animation: hint 7s 1.2s both;
}
@keyframes hint { 0% { opacity: 0; } 8%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* Libro que sale del estante */
.sheet-backdrop { position: absolute; inset: 0; pointer-events: none; }
.focus .sheet-backdrop { pointer-events: auto; }
.pull-layer { position: absolute; inset: 0; pointer-events: none; perspective: 1400px; }
.pull { position: absolute; transform-origin: 50% 50%; transform-style: preserve-3d; }
.tilt { position: absolute; inset: 0; transform-style: preserve-3d; }
.book { position: absolute; inset: 0; transform-style: preserve-3d; }
.face { position: absolute; left: 50%; top: 50%; backface-visibility: hidden; background-repeat: no-repeat; }
.face.front { box-shadow: inset 0 0 0 0.5px rgb(0 0 0 / 0.35); }
.face.right:not(:has(.gen-cover)), .face.top, .face.bottom {
  background: repeating-linear-gradient(90deg, #f3ead6 0 1px, #e0d4ba 1px 2px);
}
.face.top, .face.bottom { background: repeating-linear-gradient(0deg, #f3ead6 0 1px, #e0d4ba 1px 2px); }
.gen-cover {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 12% 10%;
  color: var(--paper); background: linear-gradient(160deg, rgb(255 255 255 / 0.12), rgb(0 0 0 / 0.25));
  box-shadow: inset 3px 0 0 rgb(0 0 0 / 0.25);
}
.gen-cover.on-light { color: var(--ink); }
.gen-cover strong { font: 400 1em/1.05 var(--font-display); letter-spacing: -0.01em; }
.gen-cover span { font-size: 0.42em; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.85; }
.pull-hole {
  position: absolute; border-radius: 2px; opacity: 0;
  background: linear-gradient(rgb(12 9 6 / 0.95), rgb(30 22 14 / 0.9));
  box-shadow: inset 0 3px 8px rgb(0 0 0 / 0.9);
}

.boot-error { position: absolute; inset: auto 0 40% 0; text-align: center; padding: 20px; }

@media (max-width: 700px) {
  .topbar { grid-template-columns: 1fr auto; }
  .sector { grid-column: 1 / -1; grid-row: 2; justify-self: start; margin-top: 8px; font-size: 0.82rem; }
  .arrow-label { font-size: 0.8rem; }
  .arrow[data-dir="left"] .arrow-label, .arrow[data-dir="right"] .arrow-label { display: none; }
  .arrow[data-dir="left"], .arrow[data-dir="right"] { padding: 9px; }
  .arrow[data-dir="up"] { top: 116px; }
  .arrow[data-dir="down"] { bottom: 84px; }
  .intro { right: var(--edge); max-width: none; padding: 20px; }
  .intro-copy { font-size: 0.9rem; }
  .hint { bottom: 140px; font-size: 0.72rem; }
  .at-window .hint { display: none; }
  .intro h1 { font-size: 2.6rem; }
  .intro-kicker { margin-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* Capas: la barra (con el carrito) queda sobre el fondo que cierra la ficha; los paneles, sobre la barra. */
.topbar { z-index: 2; }
.pull-layer { z-index: 2; }
.sheet, .cart, .assistant, .finder, .admin, .zone-popover, .toast { z-index: 3; }

/* Aviso de demo (fotos reales, imágenes de productos ilustrativas) */
.disclaimer { position: absolute; right: var(--edge); bottom: calc(var(--edge) * 0.9); margin: 0; padding: 6px 12px; border-radius: var(--radius-pill); background: rgb(17 17 17 / 0.6); backdrop-filter: blur(8px); color: rgb(245 242 236 / 0.85); font-size: 0.72rem; letter-spacing: 0.02em; pointer-events: none; z-index: 2; }
.focus .disclaimer { opacity: 0; }
