:root {
  --ink: #050505;
  --deep-purple: #1a0b2e;
  --cyan: #00f2ff;
  --purple: #8e44ad;
  --cream: #f4f1ea;
  --glass: rgba(255, 255, 255, 0.04);
  --glass-strong: rgba(8, 8, 12, 0.72);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.16);
  --transition: cubic-bezier(0.16, 1, 0.3, 1);
  --content-max: 1120px;
}

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

html,
body {
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: 'DM Sans', sans-serif;
  overflow-x: hidden;
  line-height: 1.7;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  text-rendering: optimizeLegibility;
  font-size: 16px;
}

img,
canvas {
  max-width: 100%;
}

a,
button {
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(0, 242, 255, 0.2);
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb { background: rgba(142, 68, 173, 0.9); border-radius: 999px; }

/* Typography */
h1,
h2,
h3 {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0.04em;
  line-height: 0.98;
  text-wrap: balance;
}

h2 {
  font-size: clamp(2.1rem, 4.5vw, 4.3rem);
  max-width: 12ch;
}

h3 {
  font-size: clamp(1.35rem, 2vw, 1.75rem);
}

p {
  max-width: 64ch;
  color: rgba(244, 241, 234, 0.84);
  text-wrap: pretty;
}

.logo-font {
  font-family: 'Cinzel', serif;
  letter-spacing: 0.14em;
}

/* Background Layers */
#bgWrap {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#bgCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#postFrameBackdrop {
  position: fixed;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background:
    radial-gradient(circle at 25% 20%, rgba(0, 242, 255, 0.08) 0%, transparent 35%),
    radial-gradient(circle at 75% 25%, rgba(142, 68, 173, 0.14) 0%, transparent 36%),
    radial-gradient(circle at 50% 50%, #1a0b2e 0%, #050505 100%);
  pointer-events: none;
}

.noise-overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  opacity: 0.035;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

#overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

#heroContent {
  text-align: center;
  max-width: min(90vw, 820px);
  padding: clamp(1.4rem, 3vw, 2.25rem);
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.38), rgba(5, 5, 5, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 28px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

#heroContent h1 {
  font-size: clamp(2.5rem, 7vw, 5.3rem);
  line-height: 0.95;
  margin-bottom: 1.2rem;
  color: #fff;
  text-shadow: 0 0 30px rgba(142, 68, 173, 0.22);
}

#heroContent p {
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  max-width: 42rem;
  margin: 0 auto 2.2rem;
  opacity: 0.92;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.8;
}

.cta-group {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.cta-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3.25rem;
  padding: 1rem 1.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--cream);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 0.72rem;
  line-height: 1.2;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  transition: transform 0.35s var(--transition), border-color 0.35s var(--transition), box-shadow 0.35s var(--transition), background 0.35s var(--transition);
}

.cta-pill.primary {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
  box-shadow: 0 10px 30px rgba(142, 68, 173, 0.24);
}

.cta-pill:hover,
.cta-pill:focus-visible {
  transform: translateY(-3px);
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(0, 242, 255, 0.18);
  outline: none;
}

/* Nav */
nav {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  width: min(94vw, 1120px);
  padding: 0.9rem 1.2rem;
  background: rgba(5, 5, 5, 0.68);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  backdrop-filter: blur(18px);
  transition: transform 0.6s var(--transition), opacity 0.6s var(--transition), background 0.4s var(--transition);
}

nav.nav-hidden { transform: translate(-50%, -180%); opacity: 0; }

.nav-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: clamp(0.8rem, 1.6vw, 1.5rem);
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a,
.mobile-menu-panel a {
  color: var(--cream);
  text-decoration: none;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  opacity: 0.72;
  transition: color 0.3s ease, opacity 0.3s ease, text-shadow 0.3s ease;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.mobile-menu-panel a:hover,
.mobile-menu-panel a:focus-visible {
  opacity: 1;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan);
  outline: none;
}

.nav-logo-img {
  height: 22px;
  width: auto;
  filter: brightness(0) invert(1);
}

.mobile-menu-button {
  display: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--cream);
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
  cursor: pointer;
}

.mobile-menu-button span {
  width: 16px;
  height: 1.5px;
  background: currentColor;
  display: block;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.mobile-menu-button.is-open span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.mobile-menu-button.is-open span:nth-child(2) { opacity: 0; }
.mobile-menu-button.is-open span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

.mobile-menu-panel {
  position: fixed;
  top: 4.8rem;
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  width: min(94vw, 480px);
  z-index: 119;
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.mobile-menu-panel a {
  padding: 0.95rem 1rem;
  border-radius: 16px;
  background: transparent;
}

.mobile-menu-panel.is-open {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* Page Sections */
#pageRoot {
  position: relative;
  z-index: 20;
  pointer-events: auto;
  background: transparent !important;
}

section {
  min-height: 100vh;
  padding: clamp(6rem, 14vh, 9rem) clamp(1.2rem, 5vw, 4.8rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.9s var(--transition), transform 0.9s var(--transition);
  scroll-margin-top: 6rem;
}

section > div {
  width: min(100%, var(--content-max));
  margin-inline: auto;
}

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

#sistema,
#servicios {
  height: auto !important;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 3rem;
}

.card {
  background: linear-gradient(180deg, rgba(247,240,249,0), rgba(255,255,255,0));
  border: 1px solid var(--border);
  padding: clamp(1.5rem, 3vw, 5rem);
  position: relative;
  overflow: hidden;
  transition: transform 0.5s var(--transition), border-color 0.5s var(--transition), background 0.5s var(--transition), box-shadow 0.5s var(--transition);
  border-radius: 22px;
  min-height: 100%;
}

.card:hover {
  background: linear-gradient(180deg, rgba(126,65,182,0.40), rgba(93,38,148,0.30));
  border-color: rgba(0, 255, 255, 0.95);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 0 12px rgba(0, 255, 255, 0.50),
    0 0 24px rgba(0, 255, 255, 0.22),
    0 22px 48px rgba(36, 10, 58, 0.24);
}

.card h3 {
  margin-bottom: 0.9rem;
  color: #fff;
}

.card p {
  font-size: 1rem;
  opacity: 1;
  font-weight: 400;
  line-height: 1.75;
  max-width: 34ch;
}

.card-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  margin-bottom: 1.2rem;
  display: block;
  color: var(--cyan);
}

/* Infraestructura de crecimiento */
#servicios .card {
  background: linear-gradient(180deg, rgba(126, 65, 182, 0.18), rgba(93, 38, 148, 0.12));
  border: 1px solid rgba(190, 155, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 18px 40px rgba(36, 10, 58, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#servicios .card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top left, rgba(196, 168, 255, 0.14), transparent 55%);
  pointer-events: none;
}

#servicios .card > * {
  position: relative;
  z-index: 1;
}

#servicios .card:hover {
  background: linear-gradient(180deg, rgba(126, 65, 182, 0.24), rgba(93, 38, 148, 0.16));
  border-color: rgba(206, 177, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 22px 48px rgba(36, 10, 58, 0.24);
}

#servicios .card p {
  opacity: 0.50;
}

/* Specific Section UI */
.chat-mockup {
  max-width: 470px;
  width: 100%;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 1.5rem;
  margin-top: 1rem;
  justify-self: end;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.chat-bubble {
  padding: 0.95rem 1.2rem;
  border-radius: 18px;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  max-width: 85%;
}

.bubble-bot { background: var(--purple); color: white; align-self: flex-start; }
.bubble-user { background: rgba(255,255,255,0.1); color: white; align-self: flex-end; margin-left: auto; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.2rem;
  margin-top: 2.2rem;
}

.stat-item {
  padding: 1.2rem 1rem;
  border-radius: 20px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.stat-item h4 {
  font-size: clamp(2rem, 5vw, 3rem);
  font-family: 'Cinzel', serif;
  color: var(--cyan);
  line-height: 1;
  margin-bottom: 0.4rem;
}

.stat-item span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  opacity: 0.72;
}

footer {
  width: 100%;
}

/* Cursor */
#cursorDot {
  position: fixed;
  width: 6px;
  height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  pointer-events: none;
  z-index: 10000;
  mix-blend-mode: difference;
  transform: translate(-50%, -50%);
  transition: transform 0.1s;
  box-shadow: 0 0 15px var(--cyan);
}

html { height: 100%; }
body { min-height: 100%; margin: 0; background: #050505 !important; }
#bgWrap { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; min-height: 100vh !important; z-index: 0 !important; overflow: hidden !important; pointer-events: none !important; margin: 0 !important; padding: 0 !important; box-sizing: border-box !important; }
#bgCanvas { position: absolute !important; inset: 0 !important; width: 100% !important; height: 100% !important; display: block !important; margin: 0 !important; padding: 0 !important; box-sizing: border-box !important; }
#bgWrap, #bgCanvas, #bgWrap * { filter: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
#overlay { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; filter: none !important; }
#postFrameBackdrop { position: fixed !important; inset: 0 !important; z-index: 1 !important; pointer-events: none !important; margin: 0 !important; padding: 0 !important; box-sizing: border-box !important; }

/* Tablet */
@media (max-width: 1024px) {
  nav {
    width: min(95vw, 980px);
  }

  section {
    padding-top: 7.2rem;
    padding-bottom: 6rem;
  }

  .content-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile */
@media (max-width: 820px) {
  html,
  body {
    line-height: 1.75;
  }

  nav {
    top: 0.75rem;
    padding: 0.75rem 0.85rem;
    border-radius: 22px;
  }

  .nav-links {
    display: none;
  }

  .mobile-menu-button {
    display: inline-flex;
  }

  #overlay {
    align-items: flex-end;
    padding-bottom: 8vh;
  }

  #heroContent {
    max-width: 100%;
    border-radius: 24px;
    padding: 1.35rem 1.15rem;
  }

  #heroContent h1 {
    font-size: clamp(2.2rem, 12vw, 3.45rem);
    letter-spacing: 0.02em;
  }

  #heroContent p {
    font-size: 1rem;
    line-height: 1.72;
    margin-bottom: 1.5rem;
  }

  .cta-group {
    width: 100%;
    flex-direction: column;
  }

  .cta-pill {
    width: 100%;
    min-width: 0;
    padding-inline: 1rem;
  }

  h2 {
    font-size: clamp(2rem, 10vw, 3rem);
    max-width: 14ch;
    letter-spacing: 0.02em;
  }

  section {
    min-height: auto;
    padding: 6.5rem 1rem 4.5rem;
    justify-content: flex-start;
  }

  section > div {
    width: 100%;
  }

  .content-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .card {
    border-radius: 20px;
    padding: 1.4rem 1.15rem;
  }

  .card p {
    max-width: none;
    font-size: 0.98rem;
  }

  .chat-mockup {
    max-width: 100%;
    padding: 1.1rem;
    border-radius: 22px;
  }

  .chat-bubble {
    max-width: 92%;
    font-size: 0.92rem;
  }

  .card-label {
    font-size: 0.68rem;
    letter-spacing: 0.24em;
    margin-bottom: 0.95rem;
  }

  #contact {
    min-height: auto !important;
  }

  #contact footer {
    margin-top: 4rem !important;
    padding-top: 2rem !important;
  }

  #contact footer > div {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem !important;
  }

  #contact footer > div > div {
    flex-direction: column;
    gap: 0.9rem !important;
  }

  #sistema,
  #servicios {
    min-height: auto;
  }

  #cursorDot {
    display: none !important;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 15px;
  }

  #heroContent {
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
  }

  .mobile-menu-panel {
    top: 4.5rem;
    width: calc(100vw - 1rem);
  }

  .stat-item {
    padding: 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
