/* ---------- CSS Variables (Theme Control) ---------- */
:root {
    --ai-primary: #0071bb;
    --ai-gradient-start: #004371;
    --ai-gradient-mid: #005a96;
    --ai-gradient-end: #0071bb;
}

/* ---------- Section Container ---------- */
.ai-stats-section {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, var(--ai-gradient-start) 0%, var(--ai-gradient-mid) 40%, var(--ai-gradient-end) 100%);
    padding: 5rem 0;
    isolation: isolate;
}

/* subtle noise overlay */
.ai-stats-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.45;
    pointer-events: none;
    z-index: 3;
}

/* ---------- Canvas Background ---------- */
.ai-canvas-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: block;
    pointer-events: none;
}

/* ---------- Content Layer ---------- */
.ai-stats-content {
    position: relative;
    z-index: 5;
}

/* ---------- Section Header ---------- */
.ai-stats-header {
    text-align: center;
    margin-bottom: 3.5rem;
}

.ai-stats-header h2 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
    margin: 0 0 0.75rem;
}

.ai-stats-header h2 .ai-glow-text {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
}

.ai-stats-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.95rem;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ---------- Stats Grid ---------- */
.ai-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    max-width: 1140px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ---------- Stat Card (Light / Subtle) ---------- */
.ai-stat-card {
    position: relative;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 2rem 1.25rem;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow: hidden;
    cursor: default;
    /* Only animate composited properties (transform + opacity) */
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform, opacity;
    /* hidden for scroll reveal */
    opacity: 0;
    transform: translateY(40px) scale(0.97);
}

/* Composited shadow hover overlay — avoids non-composited box-shadow transition */
.ai-stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    pointer-events: none;
    z-index: 0;
}
.ai-stat-card:hover::after {
    opacity: 1;
}

.ai-stat-card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.7s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.7s cubic-bezier(0.23, 1, 0.32, 1);
}

.ai-stat-card.pop {
    transform: scale(1.04);
}

/* subtle top highlight */
.ai-stat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 40%);
    pointer-events: none;
}

/* Hover */
.ai-stat-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

.ai-stat-card.tilt-active {
    transition: none;
}

/* ---------- Orbit Ring (SVG, hover only) ---------- */
.ai-orbit-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translate(-50%, -50%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s;
}

.ai-stat-card:hover .ai-orbit-ring {
    opacity: 1;
}

.orbit-circle {
    fill: none;
    stroke: rgba(255, 255, 255, 0.25);
    stroke-width: 0.6;
    stroke-dasharray: 4 8;
    opacity: 0.35;
    animation: orbitSpin 10s linear infinite;
    transform-origin: center;
    will-change: transform;
}

.orbit-dot {
    fill: rgba(255, 255, 255, 0.5);
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.25));
    animation: orbitSpin 5s linear infinite;
    transform-origin: 70px 70px;
    will-change: transform;
}

.orbit-dot:nth-child(3) { animation-delay: -1.7s; }
.orbit-dot:nth-child(4) { animation-delay: -3.3s; }

@keyframes orbitSpin {
    to { transform: rotate(360deg); }
}

/* ---------- Hover Particles ---------- */
.ai-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.ai-particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 50%;
    opacity: 0;
}

.ai-stat-card:hover .ai-particle {
    animation: pEmit 1.5s ease-out infinite;
}

.ai-stat-card:hover .ai-particle:nth-child(1) { animation-delay: 0s; top: 50%; left: 50%; }
.ai-stat-card:hover .ai-particle:nth-child(2) { animation-delay: 0.25s; top: 50%; left: 50%; }
.ai-stat-card:hover .ai-particle:nth-child(3) { animation-delay: 0.5s; top: 50%; left: 50%; }
.ai-stat-card:hover .ai-particle:nth-child(4) { animation-delay: 0.75s; top: 50%; left: 50%; }
.ai-stat-card:hover .ai-particle:nth-child(5) { animation-delay: 1.0s; top: 50%; left: 50%; }
.ai-stat-card:hover .ai-particle:nth-child(6) { animation-delay: 1.25s; top: 50%; left: 50%; }

@keyframes pEmit {
    0%   { transform: translate(0,0) scale(1); opacity: 0.7; }
    100% { transform: translate(var(--px,30px), var(--py,-40px)) scale(0); opacity: 0; }
}

.ai-particle:nth-child(1) { --px: -35px; --py: -50px; }
.ai-particle:nth-child(2) { --px: 40px; --py: -30px; }
.ai-particle:nth-child(3) { --px: -25px; --py: 45px; }
.ai-particle:nth-child(4) { --px: 50px; --py: 25px; }
.ai-particle:nth-child(5) { --px: -45px; --py: 10px; }
.ai-particle:nth-child(6) { --px: 20px; --py: -55px; }

/* ---------- Stat Icon ---------- */
.ai-stat-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.1rem;
    /* Only animate composited properties */
    transition: transform 0.3s;
}

.ai-stat-card:hover .ai-stat-icon {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.9);
    transform: scale(1.05);
}

/* ---------- Number ---------- */
.ai-stat-number {
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 800;
    color: #fff;
    margin: 0 0 0.3rem;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    /* text-shadow not compositable — removed to avoid non-composited animation */
}

.ai-stat-card:hover .ai-stat-number {
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

/* ---------- Label ---------- */
.ai-stat-label {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin: 0;
}

.ai-stat-card:hover .ai-stat-label {
    color: rgba(255, 255, 255, 0.75);
}

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
    .ai-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.25rem;
    }
    .ai-stats-section { padding: 3.5rem 0; }
}

@media (max-width: 575px) {
    .ai-stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        max-width: 340px;
    }
    .ai-stats-section { padding: 3rem 0; }
    .ai-stat-card { padding: 1.75rem 1.25rem; }
    .ai-stat-card:hover { transform: none; }
}

/* ---------- Shared Hex Background Section ---------- */
.hex-bg-section {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

/* Noise overlay matching stats section */
.hex-bg-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.45;
    pointer-events: none;
    z-index: 3;
}

.hex-bg-section > .ai-canvas-bg {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: block;
    pointer-events: none;
}

/* Grid card scroll-reveal animation (matches stat cards) */
.hex-bg-section .hex-reveal-card {
    position: relative; /* needed for ::after shadow overlay */
    opacity: 0;
    transform: translateY(30px) scale(0.96);
    /* Only animate composited properties */
    transition: opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1),
                transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: transform, opacity;
}

/* Composited hover shadow via opacity-animated ::after pseudo-element */
.hex-bg-section .hex-reveal-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: -1;
}
.hex-bg-section .hex-reveal-card:hover::after {
    opacity: 1;
}

.hex-bg-section .hex-reveal-card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.hex-bg-section .hex-reveal-card.pop {
    transform: scale(1.06);
}

.hex-bg-section .hex-reveal-card:hover {
    transform: translateY(-3px) scale(1.03);
    /* box-shadow is now handled by ::after pseudo-element for composited animation */
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .ai-stat-card,
    .orbit-circle,
    .orbit-dot,
    .ai-particle {
        animation: none !important;
        transition: none !important;
    }
    .ai-stat-card { opacity: 1; transform: none; }
    /* .ai-canvas-bg { display: none; } */
}

/* ============================================================
   HERO SECTIONS with hex bg (inner pages — not homepage)
   ============================================================ */

/* Override gray background with blue gradient */
.section-hero-gray.hex-bg-section {
    background: linear-gradient(135deg, #004371 0%, #005a96 40%, #0071bb 100%);
}

/* Content layer above canvas & noise */
.section-hero-gray.hex-bg-section > .container-site,
.section-blue-gradient.hex-bg-section > .container-site {
    position: relative;
    z-index: 5;
}

/* Text colors — white on blue */
.section-hero-gray.hex-bg-section .section-eyebrow {
    color: rgba(255,255,255,0.7);
}
.section-hero-gray.hex-bg-section .heading-hero,
.section-hero-gray.hex-bg-section .heading-blog-list,
.section-hero-gray.hex-bg-section h1 {
    color: #fff;
}
.section-hero-gray.hex-bg-section .text-secondary {
    color: rgba(255,255,255,0.7) !important;
}
.section-hero-gray.hex-bg-section nav.small a.text-secondary,
.section-hero-gray.hex-bg-section nav.small .text-secondary {
    color: rgba(255,255,255,0.65) !important;
}

/* Filter buttons on blue bg */
.section-hero-gray.hex-bg-section .btn-sm.btn-outline-secondary,
.section-hero-gray.hex-bg-section .btn-sm.btn-primary {
    padding: .4rem 1rem;
    font-size: .875rem;
    line-height: 1.5;
}
.section-hero-gray.hex-bg-section .btn-outline-secondary {
    color: rgba(255,255,255,0.85);
    border-color: rgba(255,255,255,0.35);
    background: transparent;
}
.section-hero-gray.hex-bg-section .btn-outline-secondary:hover,
.section-hero-gray.hex-bg-section .btn-outline-secondary:focus {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.6);
    color: #fff;
}
.section-hero-gray.hex-bg-section .btn-primary {
    background: #fff;
    color: #004371;
    border-color: #fff;
}
.section-hero-gray.hex-bg-section .btn-primary:hover {
    background: rgba(255,255,255,0.9);
}

/* Blog search on blue bg – keep defaults since .blog-search-wrap has white bg */

/* Form controls on blue bg */
.section-hero-gray.hex-bg-section .form-control {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
    color: #fff;
}
.section-hero-gray.hex-bg-section .form-control::placeholder {
    color: rgba(255,255,255,0.5);
}

/* ============================================================
   BLUE-GRADIENT SECTIONS with hex bg (service/blog show pages)
   ============================================================ */
.section-blue-gradient.hex-bg-section {
    background: linear-gradient(135deg, #004371 0%, #005a96 40%, #0071bb 100%) !important;
}

/* ============================================================
   FOOTER with hex bg
   ============================================================ */
.site-footer.hex-bg-section {
    background: linear-gradient(135deg, #004371 0%, #005a96 40%, #0071bb 100%) !important;
}
.site-footer.hex-bg-section > .container-site,
.site-footer.hex-bg-section > .footer-divider {
    position: relative;
    z-index: 5;
}

/* ============================================================
   REUSABLE CTA COMPONENT (hex animated bg)
   ============================================================ */
.cta-hex-section {
    padding: 5rem 0;
}
.cta-hex-section .ai-stats-content {
    position: relative;
    z-index: 5;
}
.cta-hex-inner {
    max-width: 700px;
}
.cta-hex-center {
    margin: 0 auto;
    text-align: center;
}
.cta-hex-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3rem;
    max-width: 100%;
}
.cta-hex-title {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}
.cta-hex-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.05rem;
    line-height: 1.65;
    margin: 0 0 1.75rem;
}
.cta-hex-inline .cta-hex-text {
    margin-bottom: 0;
    max-width: 500px;
}
.cta-hex-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 2rem;
    border-radius: 8px;
    background: #fff;
    color: #004371;
    font-weight: 600;
    font-size: 0.9375rem;
    text-decoration: none;
    transition: all 0.2s ease;
    border: none;
    flex-shrink: 0;
    white-space: nowrap;
}
.cta-hex-btn:hover {
    background: #f0f7ff;
    color: #004371;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}
@media (max-width: 991px) {
    .cta-hex-section { padding: 4rem 0; }
    .cta-hex-inline {
        flex-direction: column;
        text-align: center;
    }
    .cta-hex-inline .cta-hex-text {
        margin-bottom: 1.5rem;
    }
}
@media (max-width: 575px) {
    .cta-hex-section { padding: 3rem 0; }
    .cta-hex-title { font-size: 1.5rem; }
    .cta-hex-text { font-size: 0.95rem; }
}
