/* ================================================================
   TOWSWIFT — 3D ENHANCEMENT LAYER
   Loaded after styles.css. Adds depth, glare, tilt, cursor glow,
   3D reveal animations and tactile button physics across the site
   without touching the base design system or PHP logic.
   ================================================================ */

/* ──────────── CURSOR GLOW (subtle desktop accent) ──────────── */
#cursor-ring,
#cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%, -50%);
    will-change: transform;
}

#cursor-dot {
    width: 7px;
    height: 7px;
    background: rgba(0, 212, 255, 0.9);
    box-shadow: 0 0 10px 2px rgba(0, 212, 255, 0.45);
    transition: opacity 0.2s ease, background 0.3s ease;
}

#cursor-ring {
    width: 24px;
    height: 24px;
    border: 1px solid rgba(0, 212, 255, 0.35);
    background: radial-gradient(circle, rgba(0, 212, 255, 0.08), transparent 70%);
    transition: width 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                border-color 0.3s ease, opacity 0.2s ease;
}

#cursor-ring.cursor-hover {
    width: 34px;
    height: 34px;
    border-color: rgba(255, 45, 149, 0.35);
    background: radial-gradient(circle, rgba(255, 45, 149, 0.08), transparent 70%);
}

#cursor-ring.cursor-press { width: 18px; height: 18px; }

body.has-custom-cursor,
body.has-custom-cursor a,
body.has-custom-cursor button,
body.has-custom-cursor .btn,
body.has-custom-cursor input,
body.has-custom-cursor textarea,
body.has-custom-cursor select {
    cursor: none;
}

@media (max-width: 900px), (pointer: coarse) {
    #cursor-ring, #cursor-dot { display: none !important; }
}

/* ──────────── GLOBAL DEPTH / PERSPECTIVE ──────────── */
.services-grid,
.service-categories,
.additional-grid,
.stats-grid,
.reviews-container {
    perspective: 1600px;
}

.category-card, .service-card, .additional-card, .stat-card,
.review-card, .about-image, .hero-quote-card {
    transform-style: preserve-3d;
    will-change: transform;
}

/* ──────────── CARD GLARE (JS sets --mx / --my on mousemove) ──────────── */
.card-glare {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
    opacity: 0;
    border-radius: inherit;
    background: radial-gradient(
        480px circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.16),
        rgba(255, 255, 255, 0.03) 35%,
        transparent 60%
    );
    transition: opacity 0.35s ease;
    mix-blend-mode: overlay;
}

.has-glare:hover > .card-glare { opacity: 1; }

[data-theme="light"] .card-glare {
    background: radial-gradient(
        480px circle at var(--mx, 50%) var(--my, 50%),
        rgba(255, 255, 255, 0.55),
        rgba(255, 255, 255, 0.1) 35%,
        transparent 60%
    );
}

/* Extra edge-glow ring that reacts to tilt direction */
.has-glare {
    box-shadow: 0 0 0 1px transparent;
}
.has-glare:hover {
    box-shadow: var(--glow-cyan), 0 30px 60px -20px rgba(0, 0, 0, 0.55);
}

/* ──────────── 3D BUTTON PHYSICS ──────────── */
.btn, .btn-primary, .btn-accent, .btn-outline, .hero-btn, .qb-btn {
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
    transform-origin: center;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.btn-primary, .btn-accent, .qb-primary {
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.35) inset,
        0 -3px 0 rgba(0, 0, 0, 0.18) inset,
        0 10px 24px -8px rgba(0, 212, 255, 0.55);
}

.btn-primary:hover, .btn-accent:hover {
    transform: translateY(-4px);
}

.btn-primary:active, .btn-accent:active, .btn:active, .btn-outline:active {
    transform: translateY(1px) !important;
    transition: transform 0.08s ease;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2) inset,
        0 4px 10px -4px rgba(0, 212, 255, 0.4);
}

.review-page-link,
.review-page-link:hover,
.review-page-link:active,
.review-page-link:focus {
    transform: none !important;
    scale: 1 !important;
    width: max-content;
    min-width: 0;
    transition: color .2s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease !important;
}

/* Glossy shine sweep on hover */
.btn::after, .btn-primary::after, .btn-accent::after, .hero-btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 40%;
    height: 100%;
    background: linear-gradient(115deg, transparent, rgba(255, 255, 255, 0.45), transparent);
    transform: skewX(-20deg);
    z-index: 2;
    pointer-events: none;
    transition: left 0.65s ease;
}

.btn:hover::after, .btn-primary:hover::after, .btn-accent:hover::after, .hero-btn:hover::after {
    left: 130%;
}

/* Ripple element injected on click */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
    transform: scale(0);
    pointer-events: none;
    z-index: 1;
    animation: rippleAnim 0.7s ease-out forwards;
}

@keyframes rippleAnim {
    to { transform: scale(2.6); opacity: 0; }
}

/* ──────────── 3D REVEAL ANIMATIONS (upgrades existing classes) ──────────── */
.animated-heading, .reveal-up, .reveal-left, .reveal-right, .reveal-scale {
    transition: opacity 0.9s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.animated-heading {
    transform: perspective(1200px) translateY(40px) rotateX(12deg);
}
.animated-heading.visible {
    transform: perspective(1200px) translateY(0) rotateX(0deg);
}

.reveal-up {
    transform: perspective(1200px) translateY(60px) translateZ(-80px) rotateX(18deg);
}
.reveal-up.visible {
    transform: perspective(1200px) translateY(0) translateZ(0) rotateX(0deg);
}

.reveal-left {
    transform: perspective(1200px) translateX(-70px) rotateY(-22deg);
}
.reveal-left.visible {
    transform: perspective(1200px) translateX(0) rotateY(0deg);
}

.reveal-right {
    transform: perspective(1200px) translateX(70px) rotateY(22deg);
}
.reveal-right.visible {
    transform: perspective(1200px) translateX(0) rotateY(0deg);
}

.reveal-scale {
    transform: perspective(1200px) scale(0.82) translateZ(-120px) rotateX(-10deg);
}
.reveal-scale.visible {
    transform: perspective(1200px) scale(1) translateZ(0) rotateX(0deg);
}

/* ──────────── FLOATING 3D SHAPES (injected via JS, decorative) ──────────── */
.float-orb {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    border-radius: 40% 60% 55% 45% / 50% 40% 60% 50%;
    filter: blur(6px);
    opacity: 0.18;
    animation: orbFloat 12s ease-in-out infinite, orbSpin 26s linear infinite;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.28), rgba(123, 47, 255, 0.18));
    box-shadow: 0 0 24px rgba(0, 212, 255, 0.15);
}

.float-orb.orb-alt {
    background: linear-gradient(135deg, rgba(255, 45, 149, 0.18), rgba(255, 179, 0, 0.15));
    box-shadow: 0 0 24px rgba(255, 45, 149, 0.12);
}

@keyframes orbFloat {
    0%, 100% { transform: translateY(0) translateX(0) scale(1); }
    50% { transform: translateY(-26px) translateX(14px) scale(1.08); }
}

@keyframes orbSpin {
    from { filter: blur(2px) hue-rotate(0deg); }
    to { filter: blur(2px) hue-rotate(40deg); }
}

/* ──────────── IMAGE CINEMATIC TREATMENT ──────────── */
.category-image, .service-img, .about-image img {
    filter: saturate(0.85) contrast(1.05);
    transition: filter 0.6s ease, transform 0.6s ease;
}

.category-card:hover .category-image,
.service-card:hover .service-img,
.about-image:hover img {
    filter: saturate(1.15) contrast(1.1);
}

/* Subtle depth frame around real photos */
.about-image {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.about-image::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

/* ──────────── ICON POP ──────────── */
.stat-icon, .tile-icon, .category-card i, .contact-item > i {
    transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.3s ease;
}

.stat-card:hover .stat-icon,
.additional-card:hover .tile-icon,
.category-card:hover i,
.contact-item:hover > i {
    transform: translateZ(30px) rotateY(14deg) scale(1.12);
    filter: drop-shadow(0 8px 16px rgba(0, 212, 255, 0.35));
}

/* ──────────── SECTION TITLES: LAYERED 3D TEXT ──────────── */
.section-title h2 {
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.06), 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ──────────── WAVE DIVIDERS: MORE DEPTH ──────────── */
.wave-divider svg { filter: drop-shadow(0 -10px 20px rgba(0, 0, 0, 0.25)); }

/* ──────────── SCROLLBAR ──────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--accent-cyan), var(--accent-purple));
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-primary);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--accent-purple), var(--accent-pink)); }

/* ──────────── HERO QUOTE CARD: EXTRA DEPTH ──────────── */
.hero-quote-card {
    box-shadow: var(--shadow-xl), 0 0 80px -20px rgba(0, 212, 255, 0.35);
}

/* ──────────── NAV LOGO POP ──────────── */
.logo-img { transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1); }
.logo:hover .logo-img { transform: perspective(400px) rotateY(18deg) scale(1.08); }

/* ──────────── ACCESSIBILITY / PERFORMANCE FALLBACKS ──────────── */
@media (prefers-reduced-motion: reduce) {
    .card-glare, .float-orb, .btn::after, .btn-primary::after, .btn-accent::after, .hero-btn::after {
        display: none !important;
    }
    .animated-heading, .reveal-up, .reveal-left, .reveal-right, .reveal-scale {
        transform: none !important;
        transition: opacity 0.4s ease !important;
    }
}

@media (max-width: 768px) {
    .float-orb { display: none; }
    .has-glare:hover { box-shadow: none; }
}
