/* ==========================================================================
   AB-Tech v2 — Mission Control
   Complete stylesheet
   Performance notes:
   - Animations use transform / opacity only where possible (compositor-friendly)
   - Hover lifts use transform (not top/margin) to avoid layout
   - Grain is a static fixed layer, no repaint cost beyond initial paint
   ========================================================================== */

/* === CUSTOM PROPERTIES === */
:root {
  --bg: #0b1220;
  --surface: #111a2e;
  --accent: #38bdf8;
  --accent-2: #2563eb;
  --text: #e5e7eb;
  --text-dim: #94a3b8;
  --border: rgba(56, 189, 248, 0.15);
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.25, 0.1, 0.25, 1);
}

/* === RESET & BASE === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

/* === TYPOGRAPHY === */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* === LAYOUT === */
.chapter {
  padding: 6rem 2rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
}

@media (max-width: 768px) {
  .chapter {
    padding: 4rem 1.25rem;
  }
}

/* === PRELOADER === */
#preloader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.5s var(--ease-smooth), visibility 0.5s var(--ease-smooth);
}

#preloader.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#preloader img {
  width: 96px;
  height: 96px;
  opacity: 0;
  transform: scale(0.88);
  animation: pre-logo-in 0.9s var(--ease-smooth) forwards 0.15s;
  filter: drop-shadow(0 0 24px rgba(56, 189, 248, 0.3));
}

@keyframes pre-logo-in {
  to { opacity: 1; transform: scale(1); }
}

#preloader #preloader-pct {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.25em;
  color: #94a3b8;
}

/* === LAYOUT UTILITIES === */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

.dim {
  color: var(--text-dim);
}

.center {
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === FIXED BACKGROUND (mission-control) — sits behind ALL content === */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

/* Subtle CSS grid overlay on top of the canvas, for depth */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(56, 189, 248, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 189, 248, 0.03) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 20%, transparent 70%);
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, black 20%, transparent 70%);
}

/* Radial glow behind the hero center — persists across the whole page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 70% 50% at 50% 38%,
    rgba(56, 189, 248, 0.07) 0%,
    rgba(37, 99, 235, 0.04) 40%,
    transparent 70%
  );
}

/* Content sits above the fixed background */
header.nav,
main,
footer {
  position: relative;
  z-index: 1;
}

/* === NAV === */
header.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.3s, border-color 0.3s;
  border-bottom: 1px solid transparent;
}

header.nav.scrolled {
  background: rgba(11, 18, 32, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}

header.nav .nav-logo {
  display: flex;
  align-items: center;
}

header.nav .nav-logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  transition: transform 0.3s var(--ease-smooth);
}

header.nav.scrolled .nav-logo img {
  width: 36px;
  height: 36px;
}

header.nav .nav-links {
  list-style: none;
  display: flex;
  gap: 2.5rem;
  margin: 0;
  padding: 0;
}

nav .nav-links a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  transition: color 0.2s;
}

nav .nav-links a:hover {
  color: var(--accent);
}

@media (max-width: 768px) {
  header.nav {
    padding: 0.75rem 1rem;
  }

  header.nav .nav-links {
    gap: 1.25rem;
  }
}

/* === HERO === */
#hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  text-align: center;
}

@supports (min-height: 100svh) {
  #hero {
    min-height: 100svh;
  }
}

#hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#hero .hero-content {
  position: relative;
  z-index: 1;
  max-width: 900px;
  padding: 0 2rem;
}

#hero .hero-logo {
  display: block;
  width: clamp(180px, 32vw, 380px);
  height: auto;
  margin: 0.75rem auto 1rem;
  filter: drop-shadow(0 0 32px rgba(56, 189, 248, 0.25));
  animation: hero-logo-in 1.2s var(--ease-smooth) both;
}

@keyframes hero-logo-in {
  from { opacity: 0; transform: scale(0.92) translateY(12px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

#hero .hero-sub {
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: var(--text-dim);
  max-width: 500px;
  margin: 0 auto 2rem;
  line-height: 1.6;
}

#hero .cta-btn {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.85rem 2rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  transition: all 0.3s var(--ease-smooth);
  cursor: pointer;
  background: transparent;
}

#hero .cta-btn:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.2);
}

/* === HUD ELEMENTS (hero corners) === */
.hud {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  opacity: 0.6;
  z-index: 1;
  letter-spacing: 0.05em;
}

.hud-tl {
  top: 1.5rem;
  left: 2rem;
}

.hud-tr {
  top: 1.5rem;
  right: 2rem;
}

.hud-br {
  bottom: 1.5rem;
  right: 2rem;
}

.hud .dot-live {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 0.5rem;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* === SCROLL INDICATOR === */
.scroll-indicator {
  position: absolute;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1;
}

.scroll-indicator .scroll-line {
  width: 2px;
  height: 40px;
  background: var(--border);
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.scroll-indicator .scroll-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  animation: scrollDot 2s var(--ease-smooth) infinite;
}

@keyframes scrollDot {
  0% {
    top: -4px;
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    top: 40px;
    opacity: 0;
  }
}

/* === SERVICES === */
#servicios .section-header {
  margin-bottom: 3rem;
}

#servicios h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-top: 0.5rem;
}

.svc-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .svc-grid {
    grid-template-columns: 1fr;
  }
}

.svc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  transition: all 0.4s var(--ease-smooth);
  position: relative;
  overflow: hidden;
}

.svc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease-smooth);
}

.svc-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, 0.4);
  box-shadow: 0 8px 32px rgba(56, 189, 248, 0.08);
}

.svc-card:hover::before {
  transform: scaleX(1);
}

.svc-card .svc-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 1.25rem;
}

.svc-card .svc-icon svg {
  width: 100%;
  height: 100%;
  stroke: var(--accent);
  stroke-width: 1.5;
  fill: none;
}

.svc-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.svc-card p {
  font-size: 0.9rem;
  color: var(--text-dim);
  line-height: 1.6;
}

/* === ABOUT / SOBRE === */
#sobre .sobre-grid {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 4rem;
  align-items: start;
}

@media (max-width: 900px) {
  #sobre .sobre-grid {
    grid-template-columns: 1fr;
  }
}

.sobre-text h2 {
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  margin-top: 0.5rem;
  margin-bottom: 1.5rem;
}

.sobre-text p {
  margin-bottom: 1rem;
  color: var(--text-dim);
  line-height: 1.7;
}

.sobre-text p:not(.dim) {
  color: var(--text);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.stat {
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.stat .stat-num {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 4vw, 3.5rem);
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.stat .stat-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* === CONTACT === */
#contacto .contacto-inner {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

#contacto h2 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

#contacto p {
  color: var(--text-dim);
  margin-bottom: 2rem;
}

.contact-form {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* --- Two-column row (nombre + email) --- */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 600px) {
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
}

.form-field {
  display: flex;
  flex-direction: column;
}

/* --- Honeypot: invisible to humans, visible to bots --- */
.hp-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

/* --- Status message (success / error) --- */
.form-status {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  min-height: 1.4em;
  margin-top: 0.25rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth);
}

.form-status:not(:empty) {
  opacity: 1;
  transform: translateY(0);
}

.form-status--ok {
  color: var(--accent);
}

.form-status--err {
  color: #f87171;
}

/* --- Button loading state --- */
.contact-form button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.contact-form input,
.contact-form textarea {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all 0.3s;
}

.contact-form input:focus,
.contact-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.contact-form textarea {
  resize: vertical;
  min-height: 120px;
}

.contact-form button {
  align-self: flex-start;
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.85rem 2rem;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 4px;
  transition: all 0.3s var(--ease-smooth);
  cursor: pointer;
  background: transparent;
}

.contact-form button:hover {
  background: var(--accent);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.2);
}

/* === FOOTER === */
footer#footer {
  border-top: 1px solid var(--border);
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

#footer .footer-partner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.85rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

#footer .footer-partner-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

#footer .footer-partner-link {
  display: inline-flex;
  align-items: center;
  transition: opacity 0.2s, transform 0.2s;
}

#footer .footer-partner-link img {
  display: block;
  height: 42px;
  width: auto;
  object-fit: contain;
}

#footer .footer-partner-link:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

#footer .footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#footer .footer-brand {
  display: inline-flex;
  align-items: center;
}

.footer-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

#footer .footer-copy {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

#footer .footer-social {
  display: flex;
  gap: 1rem;
}

#footer .footer-social a {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  transition: color 0.2s;
}

#footer .footer-social a:hover {
  color: var(--accent);
}

@media (max-width: 600px) {
  #footer .footer-inner {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  #footer .footer-partner {
    flex-wrap: wrap;
    text-align: center;
  }

  #footer .footer-partner-link img {
    height: 36px;
  }
}

/* === SCROLL PROGRESS === */
#scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  z-index: 9999;
  transition: width 0.1s linear;
}

/* === CURSOR DOT === */
#cursor-dot {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.3s;
}

@media (hover: none) {
  #cursor-dot {
    display: none;
  }
}

/* === GRAIN OVERLAY === */
#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px;
}

/* === REVEAL ANIMATIONS (scroll-triggered) === */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease-smooth), transform 0.6s var(--ease-smooth);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal:nth-child(2) {
  transition-delay: 0.1s;
}

.reveal:nth-child(3) {
  transition-delay: 0.2s;
}

.reveal:nth-child(4) {
  transition-delay: 0.3s;
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  #hero-canvas {
    display: none;
  }
}

/* === PRINT (minimal) === */
@media print {
  body {
    background: white;
    color: black;
  }

  .chapter {
    padding: 1rem;
  }

  header.nav,
  #grain,
  #cursor-dot,
  #scroll-progress {
    display: none;
  }
}
