/* ============================================
   TEMA OSCURO / CLARO — CSS Variables
   ============================================ */
:root {
  --bg1: #181818;
  --bg2: #1e1e1e;
  --bg3: #353535;
  --tx1: #fff;
  --tx2: #868585;
  --bd:  #353535;
  --sb:  #404040;
}

html.light {
  --bg1: #f5f5f5;
  --bg2: #fff;
  --bg3: #e5e5e5;
  --tx1: #1a1a1a;
  --tx2: #666;
  --bd:  #d4d4d4;
  --sb:  #ccc;
}

/* Aplica colores del tema */
html.light body {
  background: var(--bg1) !important;
  color: var(--tx1) !important;
}
html.light .bg-800,
html.light .card {
  background: var(--bg2) !important;
}
html.light .bg-900 {
  background: var(--bg1) !important;
}
html.light .border-600,
html.light .border-700,
html.light .border-white\/10 {
  border-color: var(--bd) !important;
}
html.light .text-500 {
  color: var(--tx2) !important;
}
html.light .text-600 {
  color: #999 !important;
}
html.light .bg-600 {
  background: var(--bg3) !important;
}
html.light .bg-black\/60 {
  background: rgba(0,0,0,.4) !important;
}
html.light .from-800 {
  --tw-gradient-from: var(--bg2) !important;
}
html.light .scroll-container::-webkit-scrollbar-thumb {
  background: var(--sb) !important;
}
html.light html,
html.light .scroll-container {
  scrollbar-color: var(--sb) transparent !important;
}
html.light .sm\:shadow-900 {
  --tw-shadow-color: rgba(0,0,0,.1) !important;
}

/* ============================================
   SELECTOR SUPERIOR — Theme + Language
   ============================================ */
.top-bar {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 9999;
  display: flex;
  gap: 4px;
  align-items: center;
  background: var(--bg2);
  border: 1px solid var(--bd);
  border-radius: 999px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
  font-family: Outfit, Inter, ui-sans-serif, system-ui;
}

.top-bar button {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--tx2);
  transition: all .2s;
  line-height: 1;
  font-family: inherit;
}

.top-bar button:hover,
.top-bar button.active {
  color: var(--tx1);
  background: var(--bg3);
}

.top-bar .sep {
  width: 1px;
  height: 18px;
  background: var(--bd);
}

@media (max-width: 640px) {
  .top-bar { top: 4px; right: 4px; }
  .top-bar button { padding: 4px 8px; font-size: 11px; }
}

.lang-selector-bottom {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 9999;
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--bd);
  border-radius: 999px;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  transform: translate(-50%, 10px) scale(0.5);
  backdrop-filter: blur(10px);
  opacity: 0;
}

.lang-selector-bottom.animate {
  /* Animación de entrada similar a la UI (scale-pop) */
  animation: lang-scale-pop 0.8s cubic-bezier(0.34, 1.3, 0.64, 1) 0.2s both;
}

@keyframes lang-scale-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.5);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}

.lang-selector-bottom button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 58px;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: transparent;
  color: var(--tx2);
  cursor: pointer;
  font-family: Outfit, Inter, ui-sans-serif, system-ui;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.lang-selector-bottom button:hover,
.lang-selector-bottom button.active {
  background: var(--bg3);
  color: var(--tx1);
}

.flag-icon {
  width: 16px;
  height: 16px;
}

/* ============================================
   PATRÓN DE FONDO (GRID)
   ============================================ */
.grid-pattern {
  background-image: linear-gradient(rgba(128, 128, 128, 0.05) 2px, transparent 2px),
                    linear-gradient(90deg, rgba(128, 128, 128, 0.05) 2px, transparent 2px);
  background-size: 60px 60px;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 60%, transparent 95%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 60%, transparent 95%);
}

html.light .grid-pattern {
  background-image: linear-gradient(rgba(128, 128, 128, 0.07) 2px, transparent 2px),
                    linear-gradient(90deg, rgba(128, 128, 128, 0.07) 2px, transparent 2px);
}

/* ============================================
   CONTACT FORM CUSTOM STYLES
   ============================================ */
/* Eliminar la separación tan grande entre la descripción y el primer campo (Name) */
form.flex-col > div.flex-1 {
  flex: none !important;
  justify-content: flex-start !important;
}

/* Evitar que se corte el hover, los anillos de enfoque y el autocompletado en el formulario de contacto sin bloquear el scroll del contenedor principal */
form {
  overflow: visible !important;
}

/* Reemplazar el color dorado de selección por blanco en el formulario de contacto */
form input:focus,
form textarea:focus {
  border-color: #ffffff !important;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4) !important;
  outline: none !important;
}

form input:hover,
form textarea:hover {
  border-color: rgba(255, 255, 255, 0.7) !important;
}

/* En modo claro, usamos tonos oscuros/neutros */
html.light form input:focus,
html.light form textarea:focus {
  border-color: #1a1a1a !important;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.15) !important;
  outline: none !important;
}

html.light form input:hover,
html.light form textarea:hover {
  border-color: rgba(0, 0, 0, 0.5) !important;
}

/* Centrar y redondear la imagen de perfil (avatar) en ambas caras de la tarjeta */
.avatar-container {
  perspective: 1000px !important;
}

.avatar-flip-card {
  width: 100% !important;
  height: 100% !important;
  position: relative !important;
  transform-style: preserve-3d !important;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.avatar-flip-card.is-flipped {
  transform: rotateY(180deg) !important;
}

.avatar-container .face {
  position: absolute !important;
  inset: 0 !important;
  backface-visibility: hidden !important;
  -webkit-backface-visibility: hidden !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  transition: opacity 0.6s ease !important;
}

.avatar-container .back-face {
  transform: rotateY(180deg) !important;
}

.avatar-container .avatar-img {
  bottom: auto !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  translate: -50% -50% !important;
  scale: 1 !important;
  transform: none !important;
  
  width: 78% !important;
  height: auto !important;
  aspect-ratio: 1 / 1 !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: none !important;
  background: transparent !important;
  transition: scale 0.3s ease, filter 0.3s ease !important;
}

.avatar-container:hover .avatar-img {
  scale: 1.05 !important;
  filter: drop-shadow(10px 10px 2px #000) !important;
}

/* Forzar el cambio de visibilidad de las caras al girar para solucionar bugs de renderizado 3D */
.avatar-flip-card:not(.is-flipped) .back-face {
  opacity: 0 !important;
  pointer-events: none !important;
}
.avatar-flip-card:not(.is-flipped) .front-face {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.avatar-flip-card.is-flipped .front-face {
  opacity: 0 !important;
  pointer-events: none !important;
}
.avatar-flip-card.is-flipped .back-face {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Asegurar que el contenedor principal no se colapse al expandir una sola sección (como Proyectos) */
.page-wrapper {
  width: 100%;
}

/* Colocar el selector de idioma dentro del contenedor del nombre en móviles */
@media (max-width: 640px) {
  /* Ocultar barra de scroll en móviles conservando el desplazamiento */
  ::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
  }
  html, body, * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
  }

  .page-wrapper {
    position: relative !important;
  }
  .lang-selector-bottom {
    position: relative !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translate(-50%, 0);
    margin-top: 12px !important;
    margin-bottom: 24px !important;
    z-index: 10 !important;
    width: fit-content !important;
  }
}
