:root {
  --ap-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ap-ease-soft: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ap-shadow-sm: 0 1px 0 rgba(8, 22, 44, 0.04), 0 16px 34px -28px rgba(8, 22, 44, 0.45);
  --ap-shadow-md: 0 1px 0 rgba(8, 22, 44, 0.04), 0 22px 54px -34px rgba(8, 22, 44, 0.55);
  --ap-shadow-lg: 0 1px 0 rgba(8, 22, 44, 0.04), 0 28px 74px -38px rgba(8, 22, 44, 0.6);
  --ap-ring: 0 0 0 3px hsl(var(--ring) / 0.18), 0 0 0 1px hsl(var(--ring) / 0.6);
}

html {
  scroll-behavior: smooth;
}

body {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Anchor offsets for fixed header */
section[id] {
  scroll-margin-top: 6.5rem;
}

/* Accessible, consistent focus ring */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--ap-ring);
}

/* Refinement: eyebrow headings */
.section-eyebrow {
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.section-eyebrow::after {
  content: "";
  display: block;
  margin-top: 0.55rem;
  height: 1px;
  width: 56px;
  background: linear-gradient(
    90deg,
    hsl(var(--brand) / 0.75),
    hsl(var(--ring) / 0.25),
    transparent
  );
}

/* Card system */
.section-shell,
.enterprise-card {
  --rx: 0deg;
  --ry: 0deg;
  --ap-tilt: translate3d(0, 0, 0);
  position: relative;
  border-radius: calc(var(--radius) + 0.35rem);
  border: 1px solid hsl(var(--border) / 0.7);
  background: linear-gradient(
    180deg,
    hsl(var(--surface) / 0.94),
    hsl(var(--surface) / 1)
  );
  box-shadow: var(--ap-shadow-sm);
  transition:
    transform 280ms var(--ap-ease-out),
    box-shadow 260ms var(--ap-ease-out),
    border-color 260ms var(--ap-ease-out),
    background-color 260ms var(--ap-ease-out);
  transform: var(--ap-tilt);
  will-change: transform;
  transform-origin: center;
}

.section-shell::before,
.enterprise-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle at 12% 10%,
    hsl(var(--brand) / 0.14),
    transparent 52%
  );
  transition: opacity 280ms var(--ap-ease-out);
}

.section-shell:hover,
.enterprise-card:hover {
  box-shadow: var(--ap-shadow-md);
  border-color: hsl(var(--brand) / 0.28);
}

.section-shell:hover::before,
.enterprise-card:hover::before {
  opacity: 1;
}

/* Enterprise cards benefit from a clearer edge and hover accent */
.enterprise-card {
  padding: 1.75rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 18px),
    linear-gradient(180deg, hsl(var(--surface) / 0.96), hsl(var(--surface) / 1));
}

.section-shell::after {
  content: "";
  position: absolute;
  inset: 1px 1px auto 1px;
  height: 1px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.75),
    transparent
  );
  opacity: 0.6;
  pointer-events: none;
}

.enterprise-card::after {
  content: "";
  position: absolute;
  left: 0;
  top: 14px;
  bottom: 14px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    hsl(var(--brand) / 0.9),
    hsl(var(--ring) / 0.4),
    transparent
  );
  opacity: 0;
  transform: translateX(-1px);
  transition: opacity 280ms var(--ap-ease-out);
}

.enterprise-card:hover::after {
  opacity: 1;
}

#services article.section-shell:hover {
  transform: var(--ap-tilt) translate3d(0, -6px, 0);
}

#process article.section-shell:hover {
  transform: var(--ap-tilt) translate3d(0, -4px, 0);
}

.enterprise-card:hover {
  transform: var(--ap-tilt) translate3d(0, -4px, 0);
}

/* Card icon micro-interactions */
.section-shell span[class*="bg-brand-soft"],
.enterprise-card span[class*="bg-brand-soft"] {
  transition: transform 260ms var(--ap-ease-out), box-shadow 260ms var(--ap-ease-out);
  will-change: transform;
}

.section-shell:hover span[class*="bg-brand-soft"],
.enterprise-card:hover span[class*="bg-brand-soft"] {
  transform: translate3d(0, -2px, 0) scale(1.02);
  box-shadow: 0 18px 36px -30px rgba(8, 22, 44, 0.6);
}

/* CTA polish: a touch more depth on hover without becoming flashy */
a[class*="bg-primary"],
a[class*="bg-primary-foreground"] {
  box-shadow: 0 12px 24px -24px rgba(8, 22, 44, 0.65);
}

a[class*="bg-primary"]:hover,
a[class*="bg-primary-foreground"]:hover {
  box-shadow: 0 22px 50px -34px rgba(8, 22, 44, 0.75);
}

/* Buttons: subtle polish for all primary-ish CTAs */
a[class*="bg-primary"],
a[class*="bg-primary-foreground"],
a[class*="border-primary"] {
  will-change: transform;
}

a[class*="bg-primary"]:active,
a[class*="bg-primary-foreground"]:active,
a[class*="border-primary"]:active {
  transform: translateY(0);
}

/* Header: scroll progress bar (injected by enhancements JS) */
.ap-scroll-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: linear-gradient(
    90deg,
    transparent,
    hsl(var(--brand) / 0.9),
    hsl(var(--ring) / 0.65),
    transparent
  );
  opacity: 0.85;
  pointer-events: none;
}

/* Nav active state (set via JS) */
.ap-nav-active {
  color: hsl(var(--foreground));
}

.ap-nav-active::after {
  width: 100% !important;
}

/* Motion: improve reveal/hero entrance without being flashy */
@keyframes ap-fade-up {
  from {
    opacity: 0;
    transform: translate3d(0, 16px, 0);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    filter: blur(0);
  }
}

.animate-in-up {
  animation: ap-fade-up 760ms var(--ap-ease-out) both;
  will-change: transform, opacity, filter;
}

.animate-delay-1 {
  animation-delay: 80ms;
}
.animate-delay-2 {
  animation-delay: 160ms;
}
.animate-delay-3 {
  animation-delay: 240ms;
}
.animate-delay-4 {
  animation-delay: 320ms;
}

.reveal {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  filter: blur(6px);
  transition:
    opacity 700ms var(--ap-ease-out),
    transform 700ms var(--ap-ease-out),
    filter 700ms var(--ap-ease-out);
  will-change: transform, opacity, filter;
}

.reveal.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  filter: blur(0);
}

/* Feature rows: staggered entrance + hover polish */
.section-shell.reveal .space-y-4 > .flex {
  opacity: 0;
  transform: translate3d(-8px, 8px, 0) scale(0.997);
  transition: opacity 560ms var(--ap-ease-out), transform 560ms var(--ap-ease-out), box-shadow 360ms var(--ap-ease-out);
  will-change: transform, opacity;
}

.section-shell.reveal.is-visible .space-y-4 > .flex {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.section-shell.reveal.is-visible .space-y-4 > .flex:nth-child(1) { transition-delay: 120ms; }
.section-shell.reveal.is-visible .space-y-4 > .flex:nth-child(2) { transition-delay: 200ms; }
.section-shell.reveal.is-visible .space-y-4 > .flex:nth-child(3) { transition-delay: 280ms; }

/* Slightly round the inner feature rows and add subtle hover/focus lift */
.section-shell .space-y-4 > .flex {
  border-radius: 0.6rem;
  background: linear-gradient(180deg, hsl(var(--surface) / 0.985), hsl(var(--surface) / 0.995));
  transition: background 220ms var(--ap-ease-out), transform 220ms var(--ap-ease-out), box-shadow 220ms var(--ap-ease-out);
}

.section-shell .space-y-4 > .flex:focus,
.section-shell .space-y-4 > .flex:hover {
  box-shadow: 0 18px 36px -28px rgba(8, 22, 44, 0.36);
  transform: translate3d(0, -2px, 0);
  background: linear-gradient(180deg, hsl(var(--surface) / 1), hsl(var(--surface) / 0.98));
  outline: none;
}

/* Icon glow + micro-interaction */
.section-shell .space-y-4 > .flex span[class*="bg-brand-soft"] {
  position: relative;
  transition: transform 260ms var(--ap-ease-out), box-shadow 260ms var(--ap-ease-out), background 260ms var(--ap-ease-out);
}

.section-shell .space-y-4 > .flex:hover span[class*="bg-brand-soft"] {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 10px 28px -12px rgba(22, 110, 255, 0.12);
  background: radial-gradient(circle at 30% 20%, hsl(var(--brand) / 0.22), hsl(var(--brand) / 0.06));
}

/* icon float animation (applied via JS when revealed) */
@keyframes ap-float {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.ap-icon-float {
  animation-name: ap-float;
  animation-duration: 6s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-delay: 0s;
  will-change: transform;
}

.ap-icon-float:hover { animation-play-state: paused; }

/* Bottom status pills: gentle pop-in and hover */
.section-shell.reveal.is-visible .mt-5.grid > div {
  opacity: 0;
  transform: translateY(8px) scale(0.995);
  transition: opacity 520ms var(--ap-ease-soft), transform 520ms var(--ap-ease-soft);
  will-change: transform, opacity;
}
.section-shell.reveal.is-visible .mt-5.grid > div:nth-child(1) { transition-delay: 200ms; }
.section-shell.reveal.is-visible .mt-5.grid > div:nth-child(2) { transition-delay: 260ms; }
.section-shell.reveal.is-visible .mt-5.grid > div:nth-child(3) { transition-delay: 320ms; }
.section-shell.reveal.is-visible .mt-5.grid > div { opacity: 1; transform: translateY(0) scale(1); }
.section-shell .mt-5.grid > div:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 14px 30px -22px rgba(8,22,44,0.38);
}

/* Decorative shine sweep (subtle) - overrides earlier thin line with a soft moving highlight */
@keyframes ap-shine {
  0% { background-position: -120% 0; opacity: 0; }
  50% { opacity: 0.9; }
  100% { background-position: 220% 0; opacity: 0; }
}
.section-shell::after {
  background-image: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,0.45), rgba(255,255,255,0));
  background-size: 220% 100%;
  animation: ap-shine 2200ms var(--ap-ease-out) 1;
  opacity: 0.28;
}

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

  .animate-in-up,
  .reveal,
  .reveal.is-visible,
  .section-shell,
  .enterprise-card {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    filter: none !important;
  }

  .ap-scroll-progress {
    display: none !important;
  }
}
