/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ===== Custom Properties ===== */
:root {
  /* Brand */
  --cardinal-red: #8B1A2B;
  --cardinal-red-light: #A52A3A;
  --cardinal-red-glow: rgba(139, 26, 43, 0.3);
  --cyber-blue: #2E86C1;
  --cyber-blue-light: #3498DB;
  --cyber-blue-glow: rgba(46, 134, 193, 0.4);
  --cyber-cyan: #00D4FF;
  --cyber-cyan-glow: rgba(0, 212, 255, 0.15);

  /* Surfaces - Light */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F3F4F6;
  --bg-card: #FFFFFF;
  --text-primary: #1A1A2E;
  --text-secondary: #6B7280;
  --border-color: #E5E7EB;
  --header-bg: rgba(255, 255, 255, 0.92);

  /* Circuit */
  --circuit-stroke: rgba(46, 134, 193, 0.08);
  --circuit-pulse: rgba(0, 212, 255, 0.6);

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Transitions */
  --theme-transition: 0.4s ease;
}

[data-theme="dark"] {
  --bg-primary: #0D1117;
  --bg-secondary: #161B22;
  --bg-card: #1C2129;
  --text-primary: #E6EDF3;
  --text-secondary: #8B949E;
  --border-color: #30363D;
  --header-bg: rgba(13, 17, 23, 0.92);
  --circuit-stroke: rgba(0, 212, 255, 0.06);
  --circuit-pulse: rgba(0, 212, 255, 0.8);
  --cardinal-red-glow: rgba(165, 42, 58, 0.4);
  --cyber-blue-glow: rgba(46, 134, 193, 0.5);
}

/* ===== Typography ===== */
html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  line-height: 1.6;
  transition: background-color var(--theme-transition), color var(--theme-transition);
  overflow-x: hidden;
}

h1, h2, h3 {
  line-height: 1.2;
  font-weight: 700;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
}

h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
  margin-bottom: 1.5rem;
}

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

p {
  color: var(--text-secondary);
  transition: color var(--theme-transition);
}

a {
  color: var(--cyber-blue);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--cyber-blue-light);
}

/* ===== Layout ===== */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  padding: 5rem 0;
}

/* ===== Circuit Background ===== */
.circuit-bg {
  position: absolute;
  inset: 0;
  min-height: 100%;
  z-index: -2;
  background-image: url("/circuit-bg.svg");
  background-size: 200px 200px;
  opacity: 0.3;
  pointer-events: none;
  transition: opacity var(--theme-transition);
  animation: bg-fade 30s ease-out forwards;
}

[data-theme="dark"] .circuit-bg {
  opacity: 0.18;
  animation: bg-fade-dark 30s ease-out forwards;
}

.circuit-pulses {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  min-height: 100%;
  pointer-events: none;
  animation: pulse-layer-fade 40s ease-out forwards;
}

/* Fade the static pattern from visible to nearly invisible over 30s */
@keyframes bg-fade {
  0%   { opacity: 0.3; }
  40%  { opacity: 0.2; }
  100% { opacity: 0.05; }
}

@keyframes bg-fade-dark {
  0%   { opacity: 0.18; }
  40%  { opacity: 0.12; }
  100% { opacity: 0.03; }
}

/* Fade the pulse lines out over 40s */
@keyframes pulse-layer-fade {
  0%   { opacity: 1; }
  50%  { opacity: 0.6; }
  100% { opacity: 0.1; }
}

/* Trail: reveals the full path but fades out behind the head */
@keyframes trail-reveal {
  0% {
    stroke-dashoffset: 1200;
    opacity: 0;
  }
  3% {
    opacity: 0.35;
  }
  60% {
    opacity: 0.15;
  }
  85% {
    stroke-dashoffset: 0;
    opacity: 0.06;
  }
  100% {
    stroke-dashoffset: 0;
    opacity: 0;
  }
}

/* Head: bright dot that races along the path */
@keyframes head-move {
  0% {
    stroke-dashoffset: 1201;
    opacity: 0;
  }
  3% {
    opacity: 1;
  }
  85% {
    opacity: 1;
    stroke-dashoffset: 1;
  }
  100% {
    stroke-dashoffset: 1;
    opacity: 0;
  }
}

.pulse-trail {
  stroke: var(--circuit-pulse);
  stroke-width: 1.5;
  fill: none;
  opacity: 0;
  stroke-dasharray: 1200;
  stroke-dashoffset: 1200;
  animation: trail-reveal 8s ease-out infinite;
  will-change: stroke-dashoffset, opacity;
}

.pulse-head {
  stroke: var(--cyber-cyan);
  stroke-width: 6;
  stroke-linecap: round;
  fill: none;
  opacity: 0;
  stroke-dasharray: 1 1200;
  stroke-dashoffset: 1201;
  filter: drop-shadow(0 0 8px var(--cyber-cyan)) drop-shadow(0 0 18px var(--cyber-cyan));
  animation: head-move 8s ease-out infinite;
  will-change: stroke-dashoffset, opacity;
}

/* ===== Header / Nav ===== */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  transition: background-color var(--theme-transition), border-color var(--theme-transition);
}

nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1.5rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo {
  height: 44px;
  width: auto;
}

.logo-text {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  transition: color var(--theme-transition);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
  align-items: center;
}

nav ul a {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

nav ul a:hover {
  color: var(--text-primary);
}

/* ===== Buttons ===== */
.btn-primary {
  display: inline-block;
  padding: 0.85rem 2rem;
  background: var(--cardinal-red);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  border-radius: 8px;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
  background: var(--cardinal-red-light);
  color: #fff;
  box-shadow: 0 0 20px var(--cardinal-red-glow);
}

.btn-nav {
  padding: 0.5rem 1.25rem;
  background: var(--cardinal-red);
  color: #fff !important;
  border-radius: 6px;
  font-weight: 600;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.btn-nav:hover {
  background: var(--cardinal-red-light);
  box-shadow: 0 0 16px var(--cardinal-red-glow);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 0.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: border-color var(--theme-transition), color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--cyber-blue);
  color: var(--cyber-blue);
  background: var(--cyber-cyan-glow);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 8rem 0 5rem;
}

.hero .container {
  max-width: 800px;
}

.hero h1 {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  transition: color var(--theme-transition);
}

.hero h1 .accent {
  color: var(--cyber-blue);
}

.hero p {
  font-size: 1.2rem;
  max-width: 600px;
  margin: 0 auto 2.5rem;
  line-height: 1.7;
}

/* ===== Services Cards ===== */
.services {
  text-align: center;
}

.services h2 {
  color: var(--text-primary);
  transition: color var(--theme-transition);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 2rem;
  text-align: left;
  transition: background-color var(--theme-transition), border-color var(--theme-transition), box-shadow 0.3s ease, transform 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px var(--cyber-blue-glow);
  border-color: var(--cyber-blue);
}

.card h3 {
  color: var(--cardinal-red);
}

[data-theme="dark"] .card h3 {
  color: var(--cardinal-red-light);
}

.card-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  color: var(--cyber-blue);
}

/* ===== About ===== */
.about {
  text-align: center;
}

.about .container {
  max-width: 750px;
}

.about h2 {
  color: var(--text-primary);
  transition: color var(--theme-transition);
}

.about p {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  line-height: 1.7;
}

.about strong {
  color: var(--text-primary);
  transition: color var(--theme-transition);
}

/* ===== Contact ===== */
.contact {
  text-align: center;
  padding-bottom: 6rem;
}

.contact h2 {
  color: var(--text-primary);
  transition: color var(--theme-transition);
}

.contact p {
  font-size: 1.15rem;
  margin-bottom: 2rem;
}

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  text-align: center;
  transition: border-color var(--theme-transition);
}

footer p {
  font-size: 0.85rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  nav ul {
    display: none;
  }

  .nav-right {
    gap: 1rem;
  }

  .hero {
    padding: 5rem 0 3rem;
  }

  section {
    padding: 3.5rem 0;
  }

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

/* ===== Mobile Nav Toggle ===== */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
}

.mobile-menu-btn svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: flex;
  }

  nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    flex-direction: column;
    padding: 1rem 1.5rem;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
  }

  nav ul.open {
    display: flex;
  }
}
