/* ============================================================
   Trackworth Website — Custom Styles
   Beyond Tailwind: animations, dark mode, custom components
   ============================================================ */

/* ---- Dark Mode Detection ---- */
@media (prefers-color-scheme: dark) {
    html:not(.light) {
        color-scheme: dark;
    }
    html:not(.light) body {
        @apply dark;
    }
}

/* Auto-apply dark class based on system preference */
@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* ---- Smooth Scrolling ---- */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
}

/* ---- Custom Selection Color ---- */
::selection {
    background-color: rgba(45, 209, 117, 0.2);
    color: inherit;
}

/* ---- Focus Styles ---- */
:focus-visible {
    outline: 2px solid #2DD175;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---- Animations ---- */
@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in-down {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fade-in 0.8s ease-out both;
}

.animate-fade-in-up {
    animation: fade-in-up 0.8s ease-out both;
}

.animate-fade-in-down {
    animation: fade-in-down 0.6s ease-out both;
}

/* Animation delays */
.animation-delay-100 {
    animation-delay: 100ms;
}
.animation-delay-200 {
    animation-delay: 200ms;
}
.animation-delay-300 {
    animation-delay: 300ms;
}
.animation-delay-400 {
    animation-delay: 400ms;
}
.animation-delay-500 {
    animation-delay: 500ms;
}

/* ---- Scroll Reveal ---- */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered reveal for grid children */
.reveal:nth-child(2) { transition-delay: 80ms; }
.reveal:nth-child(3) { transition-delay: 160ms; }
.reveal:nth-child(4) { transition-delay: 240ms; }
.reveal:nth-child(5) { transition-delay: 320ms; }
.reveal:nth-child(6) { transition-delay: 400ms; }

/* ---- Pricing Toggle ---- */
.pricing-toggle-btn {
    color: rgba(27, 40, 56, 0.5);
    cursor: pointer;
}

.pricing-toggle-btn.active {
    background-color: white;
    color: #1B2838;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
    .pricing-toggle-btn {
        color: rgba(255, 255, 255, 0.4);
    }

    .pricing-toggle-btn.active {
        background-color: rgba(255, 255, 255, 0.1);
        color: white;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
}

/* ---- Feature Cards Hover Effect ---- */
.feature-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(45, 209, 117, 0.06),
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.feature-card:hover::before {
    opacity: 1;
}

/* ---- Pricing Card Hover ---- */
.pricing-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pricing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
    .pricing-card:hover {
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    }
}

/* ---- Bank Card Hover ---- */
.bank-card {
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.bank-card:hover {
    transform: translateY(-2px);
}

/* ---- Navbar scroll state ---- */
.navbar-scrolled {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .navbar-scrolled {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
}

/* ---- Mobile Menu Animation ---- */
#mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out;
    opacity: 0;
}

#mobile-menu.open {
    max-height: 400px;
    opacity: 1;
}

/* ---- Gradient Text Fallback ---- */
@supports not (background-clip: text) {
    .bg-clip-text {
        color: #2DD175;
    }
}

/* ---- Custom Scrollbar ---- */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 8px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background-color: rgba(27, 40, 56, 0.15);
        border-radius: 4px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: rgba(27, 40, 56, 0.25);
    }

    @media (prefers-color-scheme: dark) {
        ::-webkit-scrollbar-thumb {
            background-color: rgba(255, 255, 255, 0.1);
        }

        ::-webkit-scrollbar-thumb:hover {
            background-color: rgba(255, 255, 255, 0.2);
        }
    }
}

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

    .reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .animate-fade-in,
    .animate-fade-in-up,
    .animate-fade-in-down {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .animate-bounce,
    .animate-pulse {
        animation: none;
    }

    .pricing-card,
    .feature-card,
    .bank-card {
        transition: none;
    }
}

/* ---- Print Styles ---- */
@media print {
    nav, .animate-bounce, #mobile-menu-btn {
        display: none;
    }

    body {
        color: black;
        background: white;
    }

    .reveal {
        opacity: 1;
        transform: none;
    }
}
