/* Estilos complementarios a Tailwind */

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

/* Animación de entrada al hacer scroll */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
}

/* Fondo con retícula sutil del hero */
.bg-grid {
  background-image:
    linear-gradient(to right, rgba(11, 13, 18, .05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(11, 13, 18, .05) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
}

/* Header al hacer scroll */
.header-scrolled { box-shadow: 0 1px 0 rgba(11, 13, 18, .08); background: rgba(255, 255, 255, .9); }

/* FAQ */
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details[open] .faq-icon { transform: rotate(45deg); }

/* Opciones del formulario (tarjetas radio) */
.option-card input { position: absolute; opacity: 0; pointer-events: none; }
.option-card span.card {
  display: flex; align-items: center; gap: .75rem; height: 100%;
  padding: 1rem 1.125rem; border: 1px solid #E5E7EB; border-radius: .875rem;
  background: #fff; transition: border-color .15s, box-shadow .15s, background .15s;
}
.option-card:hover span.card { border-color: #A5A9F7; }
.option-card input:checked + span.card {
  border-color: #4F46E5; background: #F4F4FF; box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.option-card input:focus-visible + span.card { outline: 2px solid #4F46E5; outline-offset: 2px; }

.form-step { display: none; }
.form-step.is-active { display: block; animation: fadeIn .3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }

.field {
  width: 100%; padding: .75rem 1rem; border: 1px solid #E5E7EB; border-radius: .75rem;
  background: #fff; font-size: .95rem; transition: border-color .15s, box-shadow .15s;
}
.field:focus { outline: none; border-color: #4F46E5; box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.field.is-invalid { border-color: #DC2626; }

/* ============ iPhone mockup ============ */
.iphone {
  --w: 240px;
  position: relative; width: var(--w); flex: none;
  padding: calc(var(--w) * .042);
  border-radius: calc(var(--w) * .17);
  background: linear-gradient(145deg, #2b2e37, #0b0d12 40%, #1c1f27);
  box-shadow:
    inset 0 0 0 1.5px #3c404b,
    inset 0 0 0 4px #0b0d12,
    0 50px 80px -30px rgba(11, 13, 18, .55),
    0 20px 40px -20px rgba(79, 70, 229, .35);
}
.iphone::before, .iphone::after { /* botones laterales */
  content: ''; position: absolute; width: 3px; border-radius: 2px; background: #2b2e37;
}
.iphone::before { left: -2px; top: 22%; height: 12%; box-shadow: 0 calc(var(--w) * .2) 0 #2b2e37; }
.iphone::after { right: -2px; top: 28%; height: 16%; }
.iphone .screen {
  position: relative; overflow: hidden; aspect-ratio: 390 / 844; background: #000;
  border-radius: calc(var(--w) * .13);
}
.iphone .screen img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.iphone .screen::after { /* reflejo */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .22) 0%, rgba(255, 255, 255, 0) 32%);
}
.iphone .island {
  position: absolute; z-index: 2; left: 50%; top: calc(var(--w) * .07); transform: translateX(-50%);
  width: 30%; height: calc(var(--w) * .075); border-radius: 999px; background: #000;
}

/* Flotación (usa la propiedad translate para no chocar con el transform de la inclinación) */
.float { animation: float var(--dur, 6s) ease-in-out infinite; animation-delay: var(--delay, 0s); }
@keyframes float { 0%, 100% { translate: 0 0; } 50% { translate: 0 -16px; } }

.tilt { transition: transform .4s cubic-bezier(.2, .7, .2, 1); transform-style: preserve-3d; will-change: transform; }

/* Carrusel 3D de proyectos */
.stage { position: relative; height: 560px; perspective: 1600px; }
.stage .slot {
  position: absolute; left: 50%; top: 50%; cursor: pointer;
  transition: transform .8s cubic-bezier(.2, .7, .2, 1), opacity .8s, filter .8s;
}
.stage .slot[data-pos="0"] { transform: translate(-50%, -50%) scale(1); z-index: 5; cursor: default; }
.stage .slot[data-pos="1"] { transform: translate(15%, -50%) scale(.82) rotateY(-22deg); z-index: 4; filter: brightness(.85); }
.stage .slot[data-pos="-1"] { transform: translate(-115%, -50%) scale(.82) rotateY(22deg); z-index: 4; filter: brightness(.85); }
.stage .slot[data-pos="2"] { transform: translate(65%, -50%) scale(.66) rotateY(-30deg); z-index: 3; filter: brightness(.65); }
.stage .slot[data-pos="-2"] { transform: translate(-165%, -50%) scale(.66) rotateY(30deg); z-index: 3; filter: brightness(.65); }
.stage .slot[data-pos="hidden"] { transform: translate(-50%, -50%) scale(.5); opacity: 0; pointer-events: none; z-index: 1; }
@media (max-width: 640px) {
  .stage { height: 470px; }
  .stage .iphone { --w: 200px !important; }
  .stage .slot[data-pos="1"] { transform: translate(-5%, -50%) scale(.78) rotateY(-22deg); }
  .stage .slot[data-pos="-1"] { transform: translate(-95%, -50%) scale(.78) rotateY(22deg); }
  .stage .slot[data-pos="2"], .stage .slot[data-pos="-2"] { opacity: 0; pointer-events: none; }
}

/* Marquesina infinita */
.marquee { mask-image: linear-gradient(to right, transparent, #000 10%, #000 90%, transparent); }
.marquee-track { display: flex; width: max-content; animation: marquee 32s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* Mancha de color animada detrás de los teléfonos */
.blob { filter: blur(60px); animation: blob 12s ease-in-out infinite alternate; }
@keyframes blob { 0% { transform: translate(0, 0) scale(1); } 100% { transform: translate(30px, -20px) scale(1.15); } }

/* Página activa en el menú */
.nav-active { color: #0B0D12; }

@media (prefers-reduced-motion: reduce) {
  .float, .marquee-track, .blob { animation: none; }
  .stage .slot, .tilt { transition: none; }
}

/* ============ Inicio: componentes interactivos ============ */

/* Palabra rotativa del H1 */
.rotator { display: inline-block; position: relative; vertical-align: bottom; overflow: hidden; padding-bottom: .08em; }
.rotator .rot-word { display: inline-block; transition: transform .45s cubic-bezier(.2, .8, .2, 1), opacity .45s; }
.rotator .rot-word.is-out { transform: translateY(-100%); opacity: 0; }
.rotator .rot-word.is-in { transform: translateY(100%); opacity: 0; transition: none; }

/* Dynamic Island */
.island-pill {
  position: relative; margin: 0 auto; overflow: hidden; color: #fff; background: #000;
  width: 132px; height: 38px; border-radius: 999px;
  box-shadow: 0 18px 40px -16px rgba(11, 13, 18, .6);
  transition: width .65s cubic-bezier(.34, 1.56, .64, 1), height .65s cubic-bezier(.34, 1.56, .64, 1), border-radius .65s cubic-bezier(.34, 1.56, .64, 1);
}
.island-view {
  position: absolute; inset: 0; display: flex; align-items: center; gap: .75rem; padding: 0 .75rem 0 .6rem;
  opacity: 0; transform: scale(.92); filter: blur(6px); pointer-events: none;
  transition: opacity .25s, transform .25s, filter .25s;
}
.island-view.is-on { opacity: 1; transform: none; filter: none; transition-delay: .18s; transition-duration: .35s; }
.island-bar { height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.island-bar > span { display: block; height: 100%; width: 0; border-radius: inherit; background: #34D399; transition: width 1.6s cubic-bezier(.2, .8, .2, 1) .3s; }

/* Chat con el cliente */
.chat-msg { animation: msgIn .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.typing span { width: 6px; height: 6px; border-radius: 99px; background: #9CA3AF; display: inline-block; animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Tarjetas con brillo que sigue al cursor */
.spotlight { position: relative; overflow: hidden; isolation: isolate; }
.spotlight::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(420px circle at var(--x, 50%) var(--y, 50%), var(--glow, rgba(99, 102, 241, .14)), transparent 45%);
}
.spotlight:hover::before { opacity: 1; }

/* Carrusel arrastrable */
.drag-scroll { cursor: grab; scrollbar-width: none; -ms-overflow-style: none; scroll-snap-type: x mandatory; }
.drag-scroll::-webkit-scrollbar { display: none; }
.drag-scroll > * { scroll-snap-align: start; }
.drag-scroll.is-dragging { cursor: grabbing; scroll-snap-type: none; user-select: none; }
.drag-scroll.is-dragging * { pointer-events: none; }

/* Estela de imágenes que sigue al cursor */
.trail-img {
  position: absolute; z-index: 0; width: 110px; aspect-ratio: 390 / 600; object-fit: cover; object-position: top;
  border-radius: 14px; pointer-events: none; box-shadow: 0 20px 40px -10px rgba(0, 0, 0, .5);
  animation: trail 1.1s cubic-bezier(.2, .8, .2, 1) forwards;
}
@keyframes trail {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.5) rotate(var(--r)); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(var(--r)); }
  100% { opacity: 0; transform: translate(-50%, -20%) scale(.85) rotate(var(--r)); }
}

/* Comparativa: fila que se ilumina */
.compare-row { transition: background .2s; }
.compare-row:hover { background: #F4F4FF; }

@media (prefers-reduced-motion: reduce) {
  .island-pill, .island-view, .rotator .rot-word, .chat-msg, .trail-img { transition: none; animation: none; }
}

/* Traducción: oculta la página hasta aplicar el idioma */
.i18n-pending body { visibility: hidden; }
