:root {
  color-scheme: light;
}

/* ============ Background mesh (Stripe-style) ============ */
.mesh-bg {
  position: absolute;
  inset: -20% -10% 0 -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(40% 50% at 15% 18%, rgba(79, 70, 229, 0.22), transparent 70%),
    radial-gradient(38% 48% at 82% 8%, rgba(225, 52, 47, 0.18), transparent 72%),
    radial-gradient(45% 55% at 70% 78%, rgba(124, 58, 237, 0.16), transparent 70%),
    radial-gradient(35% 45% at 25% 88%, rgba(6, 182, 212, 0.12), transparent 72%);
  filter: blur(10px) saturate(1.05);
  animation: mesh-drift 24s ease-in-out infinite;
  opacity: 0.55;
}

.grid-glow {
  background-image: radial-gradient(circle at 10% 20%, rgba(59, 63, 148, 0.18), transparent 50%),
    radial-gradient(circle at 80% 0%, rgba(225, 52, 47, 0.18), transparent 55%),
    linear-gradient(135deg, rgba(11, 31, 58, 0.08) 0%, rgba(11, 31, 58, 0) 60%);
  animation: grid-shift 20s ease-in-out infinite alternate;
}

@keyframes grid-shift {
  0% { opacity: 0.8; }
  100% { opacity: 1; }
}

.bg-grid {
  background-image:
    linear-gradient(to right, rgba(11, 31, 58, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(11, 31, 58, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse 80% 60% at 50% 40%, #000 30%, transparent 75%);
}

.divider {
  clip-path: polygon(0 0, 100% 6%, 100% 100%, 0 94%);
}

/* ============ Noise ============ */
.noise {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  animation: noise-pulse 8s ease-in-out infinite;
}

@keyframes noise-pulse {
  0%, 100% { opacity: 0.18; }
  50% { opacity: 0.1; }
}

/* ============ Tech cards ============ */
.tech-card {
  position: relative;
  overflow: hidden;
  transition: transform 0.45s ease, box-shadow 0.45s ease;
}
.tech-card::before {
  content: "";
  position: absolute;
  inset: -120% 60% auto -120%;
  height: 240%;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.8) 45%, transparent 60%);
  transform: translateX(-40%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.tech-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(59, 63, 148, 0.18), transparent 55%);
  opacity: 0;
  transition: opacity 0.4s ease;
}
.tech-card:hover::after { opacity: 1; }
.tech-card:hover::before { opacity: 1; animation: tech-sheen 1.2s ease forwards; }
.tech-card:hover { transform: translateY(-4px); box-shadow: 0 22px 50px -30px rgba(59, 63, 148, 0.45); }
.tech-logo {
  animation: tech-float 6s ease-in-out infinite;
  filter: drop-shadow(0 10px 24px rgba(11, 31, 58, 0.12));
}
.tech-card:nth-child(2) .tech-logo { animation-delay: 0.4s; }
.tech-card:nth-child(3) .tech-logo { animation-delay: 0.8s; }
.tech-card:nth-child(4) .tech-logo { animation-delay: 1.2s; }
@keyframes tech-float { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-8px) scale(1.02); } }
@keyframes tech-sheen { 0% { transform: translateX(-40%); } 100% { transform: translateX(140%); } }

/* ============ Reveal on scroll ============ */
/* Hidden only when JS + motion are available (html.js set inline in <head>). */
.js .reveal {
  opacity: 0;
  transform: translateY(24px);
}
.reveal {
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.js .reveal.reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* ============ Gradient text ============ */
.text-gradient {
  background: linear-gradient(110deg, #3b3f94 0%, #7c3aed 45%, #e1342f 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ============ Hairline card border (gradient) ============ */
.card-hairline {
  position: relative;
  background: #fff;
  border-radius: 1rem;
}
.card-hairline::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(11, 31, 58, 0.14), rgba(11, 31, 58, 0.04));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  pointer-events: none;
}

/* ============ Magnetic button base ============ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: linear-gradient(180deg, #4a4fa8 0%, #3b3f94 100%);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.875rem;
  box-shadow: 0 1px 2px rgba(11,31,58,0.08), 0 8px 24px -10px rgba(59,63,148,0.5);
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.btn-primary:hover {
  transform: translateY(-2px);
  background: linear-gradient(180deg, #5b5fb5 0%, #4a4fa8 100%);
  box-shadow: 0 1px 2px rgba(11,31,58,0.1), 0 14px 32px -10px rgba(59,63,148,0.6);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.6);
  color: #0a1a33;
  padding: 0.75rem 1.5rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid rgba(11,31,58,0.14);
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.btn-ghost:hover {
  transform: translateY(-2px);
  border-color: rgba(11,31,58,0.4);
  background: rgba(255,255,255,0.9);
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============ Checkmark bullet (colored via currentColor) ============ */
.check {
  display: inline-block;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 2px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ============ Reduced motion ============ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}

/* ============ Product portfolio ============ */
.portfolio-section {
  padding: 84px 0 96px;
  border-top: 1px solid rgba(10, 26, 51, 0.06);
  background: #fff;
}
.portfolio-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.portfolio-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 44px; }
.portfolio-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.09), 0 6px 20px -12px rgba(10, 26, 51, 0.15);
  --product-accent: #aa2537;
  transition: box-shadow 200ms ease;
}
.portfolio-card:hover { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12), 0 16px 32px -16px rgba(10, 26, 51, 0.2); }
.portfolio-school { --product-accent: #16786c; }
.portfolio-accounting { --product-accent: #4652a1; }
.portfolio-inner { display: flex; flex-direction: column; height: 100%; }
.portfolio-visual { position: relative; border-bottom: 1px solid rgba(10, 26, 51, 0.06); background: #f6f7fb; }
.portfolio-visual img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; }
.portfolio-copy { padding: 28px; display: flex; flex-direction: column; flex: 1; }
.portfolio-category { color: var(--product-accent); font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; }
.portfolio-copy h3 { margin-top: 8px; font-size: 30px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.15; }
.portfolio-heading { margin-top: 12px; font-size: 16px; font-weight: 500; line-height: 1.5; }
.portfolio-description { margin-top: 12px; font-size: 14px; line-height: 1.75; color: #5b6b82; }
.portfolio-features { display: flex; flex-wrap: wrap; gap: 6px; margin: 20px 0 0; }
.portfolio-features li { padding: 5px 8px; border-radius: 5px; font-size: 11px; line-height: 1.5; color: #47566c; background: #f3f5f8; }
/* Wrap-mode SpotlightCard preserves the card's equal-height content. */
.portfolio-card > .card-spotlight { height: 100%; }

/* ============ Navigation and interaction polish ============ */
html { scroll-padding-top: 100px; }
:focus-visible { outline: 3px solid #6368c4; outline-offset: 5px; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 100; padding: 12px 20px; border-radius: 8px; color: #fff; background: #3b3f94; }
.skip-link:not(:focus) { clip-path: inset(50%); width: 1px; height: 1px; padding: 0; overflow: hidden; white-space: nowrap; }
.skip-link:focus { top: 12px; }
.btn-primary:active, .btn-ghost:active { transform: scale(0.96); }
#header { transition-property: background-color, border-color, box-shadow; }
.tech-logo { animation: none; }
.reveal { will-change: auto; }
@media (max-width: 1023px) {
  .portfolio-grid { grid-template-columns: 1fr; gap: 28px; }
  .portfolio-inner { display: grid; grid-template-columns: 1fr 1fr; }
  .portfolio-visual { display: flex; align-items: center; border-bottom: 0; border-right: 1px solid rgba(10, 26, 51, 0.06); }
  .portfolio-intro { align-items: flex-start; flex-direction: column; gap: 16px; }
}
@media (max-width: 639px) {
  #header nav .btn-primary { display: none; }
  .portfolio-section { padding: 60px 0 64px; }
  .portfolio-grid { margin-top: 28px; }
  .portfolio-inner { display: flex; }
  .portfolio-visual { border-right: 0; border-bottom: 1px solid rgba(10, 26, 51, 0.06); }
  .portfolio-copy { padding: 24px; }
  .portfolio-copy h3 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .js .reveal { opacity: 1; transform: none; }
  .tech-card:hover, .btn-primary:hover, .btn-primary:active, .btn-ghost:hover, .btn-ghost:active { transform: none; }
}

/* Compact layouts keep the same content, with room for readable text. */
h1, h2, .portfolio-heading { text-wrap: balance; }
.portfolio-accounting { --product-accent: #2152e8; }
#mobile-menu {
  max-height: calc(100svh - 72px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
@media (min-width: 640px) and (max-width: 1023px) {
  #process .process-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  #technology .technology-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
  #technology .tech-card { flex: 0 0 calc((100% - 24px) / 3); min-width: 0; }
  .portfolio-visual { overflow: hidden; }
  .portfolio-visual img { flex: 0 0 100%; }
}
@media (max-width: 767px) {
  .hero-section, footer > .mx-auto { padding-inline: 20px; }
  main > section:not(.hero-section):not(.portfolio-section) { padding-block: 64px; }
  main > section > .mx-auto, #services { padding-inline: 20px; }
  main > section > .mx-auto > .mt-12, #services > .mt-12 { margin-top: 32px; }
  .education-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .education-grid > div { padding: 16px; }
  .education-grid > div:last-child { grid-column: 1 / -1; width: calc((100% - 12px) / 2); justify-self: center; }
  #studio .group > img { height: 224px; }
  #studio .group > .absolute:last-child { left: 20px; right: 20px; bottom: 20px; }
  .footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
  .footer-brand, .footer-connect { grid-column: 1 / -1; }
  .footer-grid > div:not(.footer-brand) { gap: 0; }
  .footer-grid > div:not(.footer-brand) > p { margin-bottom: 8px; }
  .footer-grid > div:not(.footer-brand) > a { display: flex; align-items: center; min-height: 44px; }
  .footer-connect { flex-direction: row; flex-wrap: wrap; column-gap: 24px !important; }
  .footer-connect > p { flex-basis: 100%; }
}
@media (max-width: 639px) {
  .hero-section { padding-bottom: 56px; }
  .hero-layout { gap: 32px; }
  .hero-visual .shadow-glow-strong { box-shadow: 0 12px 32px -18px rgba(59, 63, 148, 0.3); }
  .hero-visual .tracking-eyebrow, .hero-section > .hero-layout > div > .tracking-eyebrow { letter-spacing: 0.15em; font-size: 11px; }
  .hero-stages > div { padding: 12px; }
  .hero-stages > div > p:last-child { font-size: 14px; line-height: 1.5; text-wrap: balance; }
  .client-strip { margin-top: 48px; padding-top: 28px; }
  .client-strip > [data-island='logo-loop'] { gap: 24px 16px; }
  .portfolio-section { padding-block: 56px; }
  .portfolio-grid { gap: 24px; }
  .portfolio-copy { padding: 24px; }
  .portfolio-features li { font-size: 12px; }
  #process .process-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-top: 28px; }
  .process-content { display: grid; grid-template-columns: 36px minmax(0, 1fr); column-gap: 14px; row-gap: 4px; padding: 20px; }
  .process-content > div { grid-row: 1 / 3; margin: 0; }
  .process-content > p:last-child { margin: 0; }
  #technology .tech-card { flex-basis: calc((100% - 12px) / 2); }
  #services [data-island='spotlight-card'] .p-7, #ai-adoption [data-island='spotlight-card'] .p-7 { padding: 24px; }
  #contact .max-w-md { max-width: none; padding: 24px; }
  #contact [data-island='star-border'], #contact .btn-primary, #contact .star-border-container, #contact .inner-content { width: 100%; }
  footer { padding-block: 48px; }
}
