/* ============ WebMasterMexico — galería esférica ============ */
:root {
  --bg: #060607;
  --ink: #f2f1ed;
  --ink-dim: rgba(242, 241, 237, 0.55);
  --ink-faint: rgba(242, 241, 237, 0.28);
  --accent: #d8ff3e;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Archivo', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }
#scene.hovering { cursor: pointer; }

/* ---------- atmósfera ---------- */
.grain {
  position: fixed;
  inset: -50%;
  pointer-events: none;
  z-index: 40;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 0.9s steps(4) infinite;
}
@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-2%, 3%); }
  50% { transform: translate(3%, -2%); }
  75% { transform: translate(-3%, -3%); }
  100% { transform: translate(2%, 2%); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background: radial-gradient(ellipse 90% 80% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

/* ---------- loader ---------- */
#loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
}
.loader-logo img { display: block; height: clamp(40px, 7vw, 64px); width: auto; }
.loader-bar {
  width: min(280px, 60vw);
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
}
.loader-bar-fill {
  width: 0%;
  height: 100%;
  background: var(--ink);
}
.loader-meta {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--ink-dim);
}

/* ---------- UI común ---------- */
.ui { z-index: 50; }

.pill {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  text-decoration: none;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 9px 20px;
  transition: background 0.25s, color 0.25s, border-color 0.25s;
  background: rgba(10, 10, 10, 0.35);
  backdrop-filter: blur(8px);
}
.pill:hover { border-color: var(--ink); }
.pill-solid {
  background: var(--ink);
  color: #0a0a0a;
  border-color: var(--ink);
}
.pill-solid:hover { background: var(--accent); border-color: var(--accent); }

/* ---------- barra superior ---------- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.logo { display: block; text-decoration: none; }
.logo img { display: block; height: 30px; width: auto; }
.tagline {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* ---------- etiqueta de tarjeta (hover) ---------- */
#card-label {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -100%);
  text-align: center;
  white-space: nowrap;
}
#card-label .cl-tag {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 6px;
}
#card-label .cl-title {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--ink);
  text-transform: uppercase;
}

/* ---------- pista de arrastre ---------- */
#drag-hint {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--ink-dim);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}
.hint-ring {
  width: 8px;
  height: 8px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  animation: pulse 1.8s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
}

/* ---------- HUD ---------- */
.hud {
  position: fixed;
  bottom: 26px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--ink-dim);
}
.hud-left { left: 28px; }
#hud-count { color: var(--ink); }

/* ---------- navegación central ---------- */
.navpill {
  position: fixed;
  bottom: 22px;
  left: 44%; /* corrido a la izquierda para no chocar con el filtro */
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  background: rgba(12, 12, 13, 0.55);
  backdrop-filter: blur(12px);
}
.navpill a {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-dim);
  text-decoration: none;
  padding: 8px 18px;
  border-radius: 999px;
  transition: color 0.25s, background 0.25s;
}
.navpill a:hover { color: var(--ink); }
.navpill a.active {
  background: var(--ink);
  color: #0a0a0a;
}

/* ---------- filtro ---------- */
.filterbox {
  position: fixed;
  bottom: 26px;
  right: 28px;
  display: flex;
  flex-direction: column; /* etiqueta arriba de los botones */
  align-items: flex-end;
  gap: 8px;
}
.filter-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.25em;
  color: var(--ink-faint);
}
#filter-buttons { display: flex; gap: 6px; }
#filter-buttons button {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  background: rgba(12, 12, 13, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.25s;
  backdrop-filter: blur(12px);
}
#filter-buttons button:hover { color: var(--ink); border-color: rgba(255, 255, 255, 0.45); }
#filter-buttons button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0a;
}

/* ---------- prompt flotante del bot ---------- */
/* ---------- OVNI mascota ---------- */
#chat-ufo {
  pointer-events: auto;
  cursor: pointer;
  width: 92px;
  margin: 0 0 2px -6px;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.55));
}
#chat-ufo svg { display: block; width: 100%; height: auto; overflow: visible; }
.ufo-bob {
  animation: ufo-bob 3.2s ease-in-out infinite;
  transform-origin: 50% 60%;
}
@keyframes ufo-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-7px) rotate(2deg); }
}
#chat-ufo .light { animation: ufo-blink 1.6s ease-in-out infinite; }
#chat-ufo .light:nth-child(2) { animation-delay: 0.4s; }
#chat-ufo .light:nth-child(3) { animation-delay: 0.8s; }
#chat-ufo .light:nth-child(4) { animation-delay: 1.2s; }
@keyframes ufo-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
#chat-ufo .antenna-ball { animation: ufo-glow 2.4s ease-in-out infinite; }
@keyframes ufo-glow {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.4; }
}
#chat-ufo .shine { animation: ufo-shine 4s ease-in-out infinite; }
@keyframes ufo-shine {
  0%, 70%, 100% { opacity: 0.8; }
  80% { opacity: 0.2; }
}
#chat-ufo .wave {
  animation: ufo-wave 2.6s ease-in-out infinite;
  transform-origin: 140px 178px;
}
@keyframes ufo-wave {
  0%, 60%, 100% { transform: rotate(0deg); }
  70% { transform: rotate(14deg); }
  80% { transform: rotate(-6deg); }
  90% { transform: rotate(10deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ufo-bob, #chat-ufo .light, #chat-ufo .antenna-ball, #chat-ufo .shine, #chat-ufo .wave { animation: none; }
}

/* Sin cajas: micrófono rojo + "Pregúntame" + cursor 3D parpadeante. El
   bloque flota por la ventana (motor en chat.js) esquivando las tarjetas. */
#chat {
  position: fixed;
  left: 0;
  top: 0;
  width: min(40vw, 430px);
  z-index: 55;
  pointer-events: none; /* la esfera se arrastra a través del bloque */
  will-change: transform;
}
#chat-form {
  display: flex;
  align-items: center;
  gap: 16px;
}
#chat-mic {
  pointer-events: auto;
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  padding: 0;
  border: none;
  background: none;
  color: #ff3b30;
  cursor: pointer;
  filter: drop-shadow(0 0 12px rgba(255, 59, 48, 0.45));
  animation: mic-pulse 2.6s ease-in-out infinite;
  transition: transform 0.25s;
}
#chat-mic:hover { transform: scale(1.12); }
#chat-mic svg { width: 100%; height: 100%; display: block; }
@keyframes mic-pulse {
  50% { filter: drop-shadow(0 0 22px rgba(255, 59, 48, 0.85)); }
}
#chat-line {
  pointer-events: auto;
  cursor: text;
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.9);
  overflow-wrap: anywhere;
  transition: color 0.3s;
}
/* En reposo la palabra casi se funde con el vacío. */
#chat-line:has(#chat-text.empty) {
  font-size: 10.5px;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
#chat-line:has(#chat-text.empty):hover { color: var(--ink-dim); }
/* Cursor de bloque con extrusión 3D, parpadeo duro de terminal. */
#chat-caret {
  display: inline-block;
  width: 0.4em;
  height: 0.9em;
  margin-left: 0.14em;
  vertical-align: -0.08em;
  transform: skewY(-5deg);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 70%, #fff), var(--accent));
  box-shadow:
    0.085em 0.085em 0 color-mix(in srgb, var(--accent) 55%, #000),
    0.17em 0.17em 0 color-mix(in srgb, var(--accent) 28%, #000),
    0.2em 0.2em 16px rgba(0, 0, 0, 0.55);
  animation: caret-flash 0.9s steps(2, jump-none) infinite;
}
@keyframes caret-flash { 50% { opacity: 0; } }
/* El input real vive oculto: captura teclado e IME, el span lo refleja. */
#chat-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
#chat-q {
  margin: 12px 0 6px 2px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}
#chat-q:empty, #chat-a:empty, #chat-hub:empty { display: none; }
#chat-q::before { content: '— '; color: var(--accent); }
#chat-a {
  margin-left: 2px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95), 0 0 24px rgba(0, 0, 0, 0.7);
  white-space: pre-wrap;
}
#chat-a.typing::after {
  content: '▍';
  color: var(--accent);
  animation: caret-flash 0.9s steps(2) infinite;
}
#chat-hub {
  pointer-events: auto;
  margin: 8px 0 0 2px;
  font-family: var(--mono);
  font-size: 12px;
}
#chat-hub a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); }
#chat-hub a:hover { opacity: 0.8; }

/* ---------- transición ---------- */
#transition {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: var(--bg);
  opacity: 0;
  pointer-events: none;
}

/* ---------- móvil ---------- */
@media (max-width: 720px) {
  .tagline { display: none; }
  .topbar { padding: 16px 18px; }
  .hud-left { display: none; }
  .filterbox {
    bottom: 80px;
    right: 50%;
    transform: translateX(50%);
    align-items: center;
  }
  .filter-label { display: none; }
  .navpill { bottom: 16px; left: 50%; }
  #drag-hint { bottom: 150px; }
  #chat { width: 86vw; }
  #chat-ufo { width: 76px; }
}
