/* =========================================================
   SMARTWEB — motion layer
   GSAP owns scroll motion; CSS keeps small ambient signals and
   complete fallbacks for unavailable or reduced motion.
   ========================================================= */

@keyframes signal-travel {
  0% { left: 0%; opacity: 0; }
  8%, 46% { opacity: 1; }
  50% { left: 100%; opacity: 0; }
  50.01%, 100% { left: 0%; opacity: 0; }
}

@keyframes marker-pulse {
  0% { transform: scale(1); opacity: 0.5; }
  100% { transform: scale(1.8); opacity: 0; }
}

@keyframes tech-status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@keyframes tech-node-pulse {
  0% { r: 9; opacity: 0.9; }
  100% { r: 22; opacity: 0; }
}

@keyframes logo-dot-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.6); }
  100% { transform: scale(1); }
}

@keyframes cta-sweep {
  0% { transform: translateX(-140%) skewX(-15deg); opacity: 0; }
  4% { opacity: 0.5; }
  12%, 100% { transform: translateX(220%) skewX(-15deg); opacity: 0; }
}

/* A 2 px brand-colour reading progress line. */
.scroll-progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 999;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, #EC8A2C, #27283C);
  box-shadow: 0 0 10px rgba(236, 138, 44, 0.32);
}

/* Content is visible by default. It is hidden only after GSAP is confirmed. */
.reveal {
  opacity: 1;
  transform: none;
}

.gsap-motion .reveal {
  opacity: 0;
  transform: translateY(24px);
}

.gsap-motion .reveal.visible {
  opacity: 1;
  transform: none;
}

.tech-network line,
.tech-network path {
  vector-effect: non-scaling-stroke;
}

.project-image {
  backface-visibility: hidden;
  transform-style: preserve-3d;
}

.btn,
.btn-arrow,
.project-image,
.process-line-fill {
  will-change: transform;
}

/* Slightly richer signal in the sticky header. */
.header-signal .pulse::after {
  content: '';
  position: absolute;
  inset: -5px;
  border: 1px solid rgba(236, 138, 44, 0.45);
  border-radius: 50%;
  animation: marker-pulse 1.8s ease-out infinite;
}

/* ---------- Full-site dark mode (0 = light, 1 = dark) ---------- */
html.dark-mode {
  --white: #11131D;
  --off-white: #0D0F17;
  --soft-section: #181B27;
  --text-primary: #F3F4F7;
  --text-secondary: rgba(243, 244, 247, 0.66);
  --border: #2B2F3E;
  --navy: #090B12;
  --blue-dark: #090B12;
  --blue-soft: #202432;
  --orange: #EC8A2C;
  --accent-text: #EC8A2C;
  background: #11131D;
}

.dark-mode body { background: var(--white); color: var(--text-primary); }
.dark-mode .site-header.scrolled {
  background: rgba(13, 15, 23, 0.9);
  border-bottom-color: rgba(248, 249, 250, 0.09);
  box-shadow: 0 12px 32px -22px rgba(0, 0, 0, 0.8);
}
.dark-mode .header-signal,
.dark-mode .smart-signal { background: rgba(248, 249, 250, 0.12); }
.dark-mode .hero-grid-bg { opacity: 0.34; }
.dark-mode .nav-links { background-color: var(--white); }
.dark-mode .menu-toggle span { background: var(--text-primary); }
.dark-mode .it-card,
.dark-mode .why-card,
.dark-mode .partner-item,
.dark-mode .team-card,
.dark-mode .contact-form,
.dark-mode .it-badges span {
  border-color: var(--border);
}
.dark-mode .field input,
.dark-mode .field select,
.dark-mode .field textarea {
  background: #141722;
  color: var(--text-primary);
  border-color: var(--border);
}
.dark-mode .field input::placeholder,
.dark-mode .field textarea::placeholder { color: rgba(243, 244, 247, 0.4); }
.dark-mode .field select option { background: #141722; color: var(--text-primary); }
.dark-mode .project-view-tag {
  background: rgba(17, 19, 29, 0.92);
  color: var(--text-primary);
  border-color: var(--border);
}
.dark-mode .form-status.success { color: #F1B36F; }
.dark-mode .skip-link,
.dark-mode .btn-primary:hover,
.dark-mode .btn-secondary,
.dark-mode .nav-links a.nav-cta:hover,
.dark-mode .tech-status-card strong,
.dark-mode .consult-card h2,
.dark-mode .cta-section,
.dark-mode .cta-inner h2,
.dark-mode .footer-brand .logo { color: #F8F9FA; }
.dark-mode .smartweb-marker { border-color: #F8F9FA; }
.dark-mode .binary-cluster,
.dark-mode .binary-field { color: #E7EAEE; }
.dark-mode .binary-toggle {
  background: rgba(248, 249, 250, 0.94);
  color: rgba(39, 40, 60, 0.72);
  box-shadow: 0 12px 30px -14px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(39, 40, 60, 0.08) inset;
}
.dark-mode .binary-toggle:not(.is-active) .binary-toggle-code span:first-child,
.dark-mode .binary-toggle.is-active .binary-toggle-code span:last-child { color: var(--navy); }
.dark-mode .binary-toggle-tooltip { background: #F8F9FA; color: #27283C; }

::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.38s; }

/* ---------- Interactive 0/1 digital signal ---------- */
@keyframes binary-twinkle {
  0%, 18%, 100% { opacity: 0.2; text-shadow: none; }
  24%, 34% { opacity: 0.95; text-shadow: 0 0 9px rgba(236, 138, 44, 0.55); }
  42% { opacity: 0.35; }
}

@keyframes security-data-flow {
  to { stroke-dashoffset: -44; }
}

.security-wave {
  stroke-dasharray: 9 13;
  animation: security-data-flow 3.2s linear infinite;
}
.security-wave-delay { animation-delay: -1.4s; }

@keyframes binary-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6) rotate(0deg);
  }
  18% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--binary-x)), calc(-50% + var(--binary-y))) scale(1.05) rotate(var(--binary-rotation));
  }
}

@keyframes binary-cluster-flash {
  0%, 100% { filter: none; }
  45% { filter: drop-shadow(0 0 14px rgba(236, 138, 44, 0.5)); }
}

@keyframes binary-field-breathe {
  0%, 100% { opacity: 0.055; }
  50% { opacity: 0.09; }
}

.binary-host { isolation: isolate; }

.binary-cluster {
  position: absolute;
  z-index: 0;
  width: 204px;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.9;
  letter-spacing: 0.19em;
  opacity: 0.14;
  pointer-events: none;
  user-select: none;
  transition: opacity 0.45s var(--ease), transform 0.6s var(--ease-out), filter 0.45s var(--ease);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 24%, #000 76%, transparent);
}

.binary-cluster--right { right: clamp(14px, 3vw, 46px); text-align: right; }
.binary-cluster--left { left: clamp(14px, 3vw, 46px); text-align: left; }
.binary-cluster--pos-0 { top: 13%; transform: rotate(2deg); }
.binary-cluster--pos-1 { top: 62%; transform: rotate(-3deg); }
.binary-cluster--pos-2 { top: 24%; transform: rotate(-2deg); }
.binary-cluster--pos-3 { top: 72%; transform: rotate(3deg); }

.binary-row { white-space: pre; }
.binary-bit {
  display: inline-block;
  animation: binary-twinkle 5.2s ease-in-out var(--binary-delay) infinite;
}
.binary-bit--accent { color: var(--blue); }

.binary-mode .binary-cluster {
  opacity: 0.28;
  transform: translateY(-3px) scale(1.025);
  filter: drop-shadow(0 0 8px rgba(236, 138, 44, 0.18));
}
.binary-mode .binary-bit { animation-duration: 2.2s; }
.binary-cluster--pulse { animation: binary-cluster-flash 0.9s var(--ease-out); }

.binary-field {
  position: absolute;
  left: -4%;
  z-index: 0;
  width: 108%;
  overflow: hidden;
  color: var(--text-primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.61rem;
  font-weight: 650;
  line-height: 2.05;
  letter-spacing: 0.22em;
  pointer-events: none;
  user-select: none;
  animation: binary-field-breathe 9s ease-in-out infinite;
  transition: opacity 0.45s var(--ease), filter 0.45s var(--ease);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}

.binary-field--high { top: 8%; }
.binary-field--low { bottom: 9%; }
.binary-field-row { white-space: nowrap; }
.binary-field-row--0 { transform: translateX(-3%); }
.binary-field-row--1 { transform: translateX(8%); }
.binary-field-row--2 { transform: translateX(-11%); }

.binary-mode .binary-field {
  opacity: 0.15;
  filter: drop-shadow(0 0 7px rgba(236, 138, 44, 0.12));
  animation: none;
}

.binary-toggle {
  position: fixed;
  top: 102px;
  right: 16px;
  bottom: auto;
  z-index: 120;
  width: 56px;
  height: 30px;
  padding: 3px;
  border: 1px solid rgba(236, 138, 44, 0.5);
  border-radius: 999px;
  background: rgba(39, 40, 60, 0.94);
  box-shadow: 0 12px 30px -14px rgba(39, 40, 60, 0.7), 0 0 0 1px rgba(248, 249, 250, 0.06) inset;
  color: rgba(248, 249, 250, 0.66);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.3s var(--ease), box-shadow 0.3s var(--ease), transform 0.3s var(--ease-out);
}

.binary-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 15px 34px -14px rgba(39, 40, 60, 0.78), 0 0 16px rgba(236, 138, 44, 0.18);
}

.binary-toggle-code {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 100%;
  height: 100%;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.62rem;
  font-weight: 800;
}

.binary-toggle-code span { transition: color 0.3s var(--ease); }
.binary-toggle.is-active .binary-toggle-code span:last-child { color: var(--white); }
.binary-toggle:not(.is-active) .binary-toggle-code span:first-child { color: var(--white); }

.binary-toggle-knob {
  position: absolute;
  z-index: 1;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(248, 249, 250, 0.11);
  box-shadow: 0 0 0 1px rgba(248, 249, 250, 0.08) inset;
  transition: transform 0.38s var(--ease-out), background 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.binary-toggle.is-active .binary-toggle-knob {
  transform: translateX(28px);
  background: var(--blue);
  box-shadow: 0 0 15px rgba(236, 138, 44, 0.5);
}

.binary-toggle-tooltip {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  bottom: auto;
  width: max-content;
  padding: 6px 9px;
  border-radius: 6px;
  background: var(--navy);
  color: var(--white);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  transform: translateY(4px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease-out);
}

.binary-toggle:hover .binary-toggle-tooltip,
.binary-toggle:focus-visible .binary-toggle-tooltip {
  opacity: 1;
  transform: translateY(0);
}

.binary-particle {
  position: fixed;
  z-index: 121;
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 800;
  pointer-events: none;
  animation: binary-burst 0.78s var(--ease-out) var(--binary-burst-delay) forwards;
}

@media (max-width: 900px) {
  .gsap-motion .reveal { transform: translateY(14px); }
  .scroll-progress { height: 2px; }
  .smart-signal-corner { display: none; }
  .binary-cluster { width: 168px; font-size: 0.58rem; opacity: 0.1; }
  .binary-mode .binary-cluster { opacity: 0.2; }
  .binary-field { left: -38%; width: 176%; font-size: 0.5rem; line-height: 1.9; letter-spacing: 0.17em; }
  .binary-field-row:nth-child(n+5) { display: none; }
  .binary-mode .binary-field { opacity: 0.11; }
  .binary-toggle { top: auto; right: 14px; bottom: max(16px, env(safe-area-inset-bottom)); width: 52px; height: 28px; }
  .binary-toggle-knob { width: 20px; height: 20px; }
  .binary-toggle.is-active .binary-toggle-knob { transform: translateX(26px); }
}

@media (max-width: 430px) {
  .binary-cluster { width: 138px; font-size: 0.52rem; opacity: 0.07; }
  .binary-mode .binary-cluster { opacity: 0.14; }
  .binary-field { left: -70%; width: 240%; opacity: 0.05; }
  .binary-mode .binary-field { opacity: 0.075; }
  .binary-toggle-tooltip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ecosystem-connections circle { display: none; }
  .ecosystem-core::before,
  .ecosystem-core-pulse { animation: none !important; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .scroll-progress { display: none !important; }
  .hero-glow { display: none; }
  .binary-bit,
  .binary-field,
  .binary-cluster--pulse,
  .binary-particle { animation: none !important; }
  .binary-cluster,
  .binary-mode .binary-cluster { opacity: 0.12; transform: none; filter: none; }
  .binary-field,
  .binary-mode .binary-field { opacity: 0.07; filter: none; }
  .reveal,
  .gsap-motion .reveal,
  .process-step {
    opacity: 1 !important;
    transform: none !important;
  }
  .process-line-fill {
    width: 100% !important;
    transform: none !important;
  }
}
