/* ==========================================================================
   DOMS.lat — Ultra-minimalist, high-contrast monochrome theme
   ========================================================================== */
:root {
  --bg-primary: #FFFFFF;
  --bg-secondary: #FAFAFA;
  --text-primary: #09090B;
  --text-secondary: #52525B;
  --text-muted: #A1A1AA;
  --border-hairline: #E4E4E7;
  --accent-contrast: #09090B;
  --accent-contrast-fg: #FFFFFF;
  --stickman-stroke: #09090B;
  --surface-glass: rgba(255, 255, 255, 0.86);
  --accent-success: #10B981;
  --accent-blue: #3B82F6;
}

html.dark {
  --bg-primary: #09090B;
  --bg-secondary: #121215;
  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #52525B;
  --border-hairline: #27272A;
  --accent-contrast: #FAFAFA;
  --accent-contrast-fg: #09090B;
  --stickman-stroke: #FAFAFA;
  --surface-glass: rgba(9, 9, 11, 0.86);
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html { scroll-behavior: smooth; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  overflow-x: hidden;
  transition: background-color 0.35s ease, color 0.35s ease;
}

/* Three.js: fondo inmersivo detrás de todo */
#three-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
  transition: opacity 0.35s ease;
}
html.dark #three-bg { opacity: 0.4; }

/* Header glassmorphism */
.glass-header {
  background-color: var(--surface-glass);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

/* Fondo arquitectónico minimalista */
.bg-minimal-grid {
  background-size: 48px 48px;
  background-image:
    linear-gradient(to right, var(--border-hairline) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border-hairline) 1px, transparent 1px);
  mask-image: radial-gradient(ellipse 80% 70% at 50% 25%, #000 50%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 25%, #000 50%, transparent 100%);
  opacity: 0.45;
}

/* ==========================================================================
   Tech Orbs — esferas de tecnologías (Sobre Mí), logo al hover
   ========================================================================== */
.tech-orb {
  position: relative;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  border: 1px solid var(--border-hairline);
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: border-color 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.tech-orb:hover {
  border-color: var(--text-primary);
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.15);
}

/* Recorrido del anfitrión: las esferas se van activando 1 a 1 y quedan encendidas */
.tech-orb.visited {
  border-color: var(--text-primary);
  transform: translateY(-4px) scale(1.06);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.15);
}

/* La etiqueta solo se oculta si hay logo que mostrar */
.tech-orb:has(.tech-logo):hover .tech-label,
.tech-orb:has(.tech-logo).visited .tech-label { opacity: 0; }

.tech-orb:has(.tech-logo).visited .tech-logo { opacity: 1; transform: scale(1) rotate(0deg); }

.tech-orb.current {
  border-color: var(--text-primary);
  transform: translateY(-4px) scale(1.14);
  box-shadow: 0 12px 24px -10px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   Pitch layer — presentación de venta que se abre al llegar el anfitrión
   ========================================================================== */
.pitch-layer {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.65rem;
  padding: 1.75rem 1.5rem;
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 5;
}

.app-card.current .pitch-layer {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  /* entra después de que la anterior se cierre: evita que los textos se pisen */
  transition: opacity 0.35s ease 0.18s, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1) 0.18s;
}

.pitch-emoji {
  font-size: 3rem;
  line-height: 1;
}

.pitch-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--text-primary);
}

.pitch-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 16rem;
  line-height: 1.5;
}

.pitch-benefit {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  color: var(--text-secondary);
  border: 1px solid var(--border-hairline);
  border-radius: 9999px;
  padding: 0.22rem 0.6rem;
}

.pitch-ring {
  position: absolute;
  width: 6rem;
  height: 6rem;
  top: 26%;
  left: calc(50% - 3rem);
  border: 2px solid var(--text-primary);
  border-radius: 9999px;
  opacity: 0;
  pointer-events: none;
}

/* Activación de cards durante el recorrido del anfitrión */
.app-card.visited {
  border-color: var(--text-primary);
}

.app-card.current {
  border-color: var(--text-primary);
  box-shadow: 0 20px 40px -14px rgba(0, 0, 0, 0.18);
}

.tech-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: opacity 0.2s ease;
}

/* (la etiqueta se oculta solo si hay logo: reglas :has arriba) */

.tech-logo {
  position: absolute;
  width: 1.55rem;
  height: 1.55rem;
  opacity: 0;
  transform: scale(0.4) rotate(-10deg);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tech-orb:hover .tech-logo {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.tech-logo path,
.tech-logo circle,
.tech-logo rect {
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ==========================================================================
   Entorno: barra de progreso, dots de capítulos, separadores
   ========================================================================== */
.scroll-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 2px;
  width: 100%;
  background-color: var(--accent-success);
  transform: scaleX(0);
  transform-origin: left center;
  opacity: 0.9;
}

#chapter-dots {
  position: fixed;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.9rem;
}

@media (min-width: 1280px) { #chapter-dots { display: flex; } }

#chapter-dots a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-secondary);
}

#chapter-dots a span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  opacity: 0;
  transform: translateX(6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}

#chapter-dots a i {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  border: 1px solid var(--border-hairline);
  transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.3s ease;
}

#chapter-dots a:hover span { opacity: 1; transform: translateX(0); }
#chapter-dots a:hover i { border-color: var(--text-primary); }

#chapter-dots a.active span { opacity: 1; transform: translateX(0); color: var(--text-primary); }
#chapter-dots a.active i {
  background-color: var(--text-primary);
  border-color: var(--text-primary);
  transform: scale(1.35);
}

.chapter-divider {
  max-width: 56rem;
  margin: 0 auto;
  padding: 7rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.chapter-divider-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1;
  color: transparent;
  -webkit-text-stroke: 1px var(--border-hairline);
}

.chapter-divider-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  white-space: nowrap;
}

.chapter-divider-line {
  flex: 1;
  height: 1px;
  background-color: var(--border-hairline);
  transform-origin: left center;
}

@media (max-width: 640px) {
  .chapter-divider { padding: 4.5rem 1.25rem; gap: 0.75rem; }
  .chapter-divider-num { font-size: 2rem; }
  .chapter-divider-label { font-size: 0.6rem; letter-spacing: 0.16em; }
}

/* ==========================================================================
   Título gigante DOMS con robot caminando encima
   ========================================================================== */
.doms-title {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 0.04em;
  margin-bottom: 1rem;
  user-select: none;
}

.doms-letter {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(5rem, 18vw, 14rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  display: inline-block;
}

@media (max-width: 640px) {
  .doms-title { gap: 0.02em; }
}

/* ==========================================================================
   Pergamino del índice — eliminado en v3.6
   ========================================================================== */

.chapter-row:hover .chapter-title { text-decoration: underline; text-underline-offset: 6px; }

.chapter-leader {
  flex: 1;
  align-self: center;
  border-bottom: 1px dotted var(--parchment-line);
}

.chapter-page {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.68rem;
  color: var(--parchment-accent);
  flex-shrink: 0;
}

.wax-seal {
  position: absolute;
  right: 1.75rem;
  bottom: 1.5rem;
  width: 3.1rem;
  height: 3.1rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: #F3EDE0;
  background: radial-gradient(circle at 34% 28%, #3d3d3d, #0c0c0c 62%);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.18);
  transform: rotate(-8deg);
  opacity: 0.9;
}

@media (max-width: 640px) {
  .parchment-sheet { padding: 2rem 1.25rem 2.75rem; }
  .chapter-title { font-size: 1.15rem; }
  .chapter-row { gap: 0.6rem; }
}

/* ==========================================================================
   HUD del anfitrión 3D — anclado a la posición proyectada del modelo
   ========================================================================== */

#host-speech {
  position: absolute;
  left: 0;
  top: 0;
  width: 8rem;
  background-color: var(--accent-contrast);
  color: var(--accent-contrast-fg);
  padding: 0.5rem 0.75rem;
  border-radius: 0.75rem;
  border-bottom-right-radius: 0;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: opacity 0.3s ease, transform 0.12s linear;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
}

#host-emoji-prop {
  position: absolute;
  left: 0;
  top: 0;
  will-change: transform;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.35));
}

/* Viñeta espacial: funde los bordes del canvas 3D */
.spatial-vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(circle at 50% 45%, transparent 45%, rgba(9, 9, 11, 0.7) 100%);
}

/* Simulador de typos del corrector */
.doms-typo {
  border-bottom: 2px wavy var(--accent-blue);
  color: #93C5FD;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-block;
}

.doms-typo:hover {
  background-color: rgba(59, 130, 246, 0.18);
  color: #FFFFFF;
}

.doms-typo.fixed-word {
  border-bottom: 2px solid var(--accent-success);
  color: #6EE7B7;
  background-color: rgba(16, 185, 129, 0.14);
}

/* ==========================================================================
   Personaje 3D (anfitrión) — el HUD se posiciona desde script.js
   ========================================================================== */

/* ==========================================================================
   Botones
   ========================================================================== */
.btn-high-contrast {
  background-color: var(--accent-contrast);
  color: var(--accent-contrast-fg);
  border: 1.5px solid var(--accent-contrast);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s ease, color 0.25s ease;
}

.btn-high-contrast:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -8px rgba(0, 0, 0, 0.22);
}

.btn-outline-minimal {
  background-color: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-hairline);
  transition: all 0.2s ease;
}

.btn-outline-minimal:hover {
  border-color: var(--text-primary);
  background-color: var(--bg-secondary);
}

/* ==========================================================================
   Filtros y tarjetas
   ========================================================================== */
.filter-pill {
  border: 1px solid var(--border-hairline);
  color: var(--text-secondary);
  background-color: transparent;
  transition: all 0.2s ease;
}

.filter-pill:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.filter-pill.active {
  background-color: var(--accent-contrast);
  color: var(--accent-contrast-fg);
  border-color: var(--accent-contrast);
}

.minimal-card {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-hairline);
  transition: border-color 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

.minimal-card:hover {
  border-color: var(--text-primary);
  transform: translateY(-3px);
  box-shadow: 0 16px 32px -12px rgba(0, 0, 0, 0.06);
}

/* ==========================================================================
   Utilidades de animación
   ========================================================================== */
.os-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", sans-serif;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.gsap-fade-up {
  opacity: 0;
  transform: translateY(40px);
  will-change: transform, opacity;
}
