/* ============================================
   Biky - Custom Stylesheet (GSAP + Mobile)
   Optimized — FOUC prevention, GSAP ScrollReveal,
   responsive, reduced-motion, touch-aware
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    --primary: #2DD4BF;
    --primary-dark: #0D9488;
    --secondary: #F472B6;
    --accent: #FBBF24;
    --dark: #1A1A2E;
    --muted: #6B7280;
    --bg: #FAFAFA;
    --white: #FFFFFF;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-fast: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 350ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* ============================================
   GSAP FOUC PREVENTION
   Elements with [data-gsap] are hidden by CSS
   until GSAP ScrollTrigger animates them in.
   No flash of unstyled content — ever.
   ============================================ */
[data-gsap] {
    opacity: 0;
}

[data-gsap="fade-up"],
[data-gsap="fade-down"] {
    transform: translateY(40px);
}

[data-gsap="fade-right"] {
    transform: translateX(-160px);
}

[data-gsap="fade-left"] {
    transform: translateX(160px);
}

[data-gsap="zoom-in"] {
    transform: scale(0.92);
}

/* Ensure GSAP-revealed elements are visible after animation */
[data-gsap].gsap-revealed {
    opacity: 1;
    transform: none;
}

/* ---------- Base & Prevent Overflow ---------- */
html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
}

/* ---------- Selection ---------- */
::selection {
    background-color: var(--primary);
    color: var(--white);
}

/* ---------- Focus Styles ---------- */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ---------- Gradient Text ---------- */
.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ---------- Buttons ---------- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(45, 212, 191, 0.3);
    font-weight: 600;
    will-change: transform;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(45, 212, 191, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-outline {
    border: 2px solid var(--dark);
    color: var(--dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    font-weight: 600;
    will-change: transform;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary-dark);
    background: rgba(45, 212, 191, 0.05);
    transform: translateY(-2px);
}

/* ---------- Navbar Scroll Effect ---------- */
#navbar.scrolled {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 30px rgba(26, 26, 46, 0.06);
}

.nav-link {
    position: relative;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: width var(--transition-smooth);
}

.nav-link:hover::after,
.nav-link.active::after {
    width: 100%;
}

/* ---------- Product Card ---------- */
.product-card {
    border: 1px solid transparent;
    transition: box-shadow var(--transition-smooth), border-color var(--transition-smooth);
    will-change: transform;
    transform-style: preserve-3d;
    perspective: 800px;
}

/* Hover-only for desktop; mobile handled via GSAP */
@media (hover: hover) and (pointer: fine) {
    .product-card:hover {
        border-color: rgba(45, 212, 191, 0.15);
        box-shadow: var(--shadow-xl);
    }
}

/* ---------- FAQ Accordion ---------- */
.faq-item .faq-icon {
    transition: transform var(--transition-smooth);
}

.faq-item.active .faq-icon {
    transform: rotate(45deg);
    background-color: var(--primary);
}

.faq-item.active .faq-icon svg {
    color: var(--white);
}

/* ---------- Toast Notification ---------- */
#toast.show {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

#toast.success #toast-icon {
    background-color: rgba(45, 212, 191, 0.15);
    color: var(--primary-dark);
}

#toast.error #toast-icon {
    background-color: rgba(239, 68, 68, 0.15);
    color: #EF4444;
}

/* ---------- Mobile Menu ---------- */
#mobile-menu {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

#mobile-menu-btn.open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

#mobile-menu-btn.open span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

#mobile-menu-btn.open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
    width: 24px;
}

/* ---------- Testimonials Carousel ---------- */
.testimonial-slide {
    will-change: transform;
}

.testimonial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #E5E7EB;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 10px;
    min-height: 10px;
}

.testimonial-dot.active {
    background: var(--primary);
    width: 28px;
    border-radius: 5px;
}

/* ---------- Form Validation Styles ---------- */
.input-error {
    border-color: #EF4444 !important;
    background-color: #FEF2F2 !important;
}

.error-message {
    color: #EF4444;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: none;
}

.error-message.visible {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* ---------- Scroll-to-Top Button ---------- */
.scroll-top-btn {
    position: fixed;
    bottom: calc(24px + var(--safe-bottom));
    right: calc(24px + var(--safe-right));
    z-index: 90;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--dark);
    color: var(--white);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(26, 26, 46, 0.3);
    transition: background var(--transition-fast);
}

.scroll-top-btn:hover {
    background: var(--primary-dark);
}

/* ---------- Language Toggle ---------- */
.lang-toggle {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    letter-spacing: 0.025em;
    background: transparent;
    min-width: 44px;
    text-align: center;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.lang-toggle:hover {
    background: rgba(45, 212, 191, 0.05);
}

.lang-toggle:active {
    transform: scale(0.96);
}

/* Chinese text sizing */
:root[lang="zh"] body {
    font-size: calc(1rem * 1.02);
}

:root[lang="zh"] .font-heading {
    font-weight: 600;
}

/* ============================================
   GSAP PREMIUM EFFECTS SUPPORT
   ============================================ */

/* Scramble text cursor effect */
.scramble-stat {
    font-variant-numeric: tabular-nums;
}

/* Deconstruct card — smooth reset */
.deconstruct-card {
    will-change: transform;
}

.deconstruct-card > * {
    transition: none; /* GSAP handles all motion */
}

/* Split text chars */
[data-i18n="hero.titleLine1"] span,
[data-i18n="hero.titleLine2"] span {
    will-change: transform, opacity;
}

/* Scroll-to-top */
.scroll-top-btn {
    will-change: transform, opacity;
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

/* Ultra-small screens (< 380px) */
@media (max-width: 379px) {
    html {
        font-size: 14px;
        scroll-padding-top: 56px;
    }

    #hero h1 {
        font-size: 2rem;
    }

    #hero p {
        font-size: 0.9rem;
    }

    .btn-primary,
    .btn-outline {
        padding: 0.75rem 1.25rem;
        font-size: 0.85rem;
    }

    .product-card {
        padding: 1rem;
    }

    .product-card img {
        height: 5rem;
    }

    #contact form {
        padding: 1rem;
    }

    footer {
        padding: 2.5rem 0;
    }
}

/* Small mobile (380px - 639px) */
@media (min-width: 380px) and (max-width: 639px) {
    html {
        font-size: 15px;
    }

    .product-card img {
        height: 7rem;
    }
}

/* Mobile general (< 768px) */
@media (max-width: 767px) {
    section {
        padding: 3rem 0;
    }

    #hero {
        min-height: 100svh;
    }

    .product-card {
        margin-bottom: 0.5rem;
    }

    .testimonial-slide {
        padding: 0.5rem;
    }

    footer .grid > div {
        margin-bottom: 1rem;
    }

    /* Larger touch targets for mobile */
    .faq-trigger {
        min-height: 56px;
        padding: 1rem;
    }

    .nav-link,
    .mobile-nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    #toast {
        left: 16px;
        right: 16px;
        bottom: calc(16px + var(--safe-bottom));
        border-radius: 16px;
    }
}

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    section {
        padding: 4rem 0;
    }

    .product-card {
        min-height: 380px;
    }

    footer .grid {
        gap: 2rem;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    .product-card {
        min-height: 420px;
    }
}

/* ============================================
   TOUCH-SPECIFIC STYLES
   ============================================ */

/* Remove hover-dependent effects on touch devices */
@media (hover: none) and (pointer: coarse) {
    .product-card:hover {
        transform: none !important;
    }

    .btn-primary:hover {
        transform: none;
    }

    .btn-outline:hover {
        transform: none;
    }

    .nav-link:hover::after {
        width: 0;
    }

    .nav-link:active::after {
        width: 100%;
    }

    /* Bigger tap targets */
    button,
    .btn-primary,
    .btn-outline,
    a[href] {
        min-height: 44px;
    }

    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevent iOS zoom */
    }
}

/* ============================================
   REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }

    .scroll-top-btn {
        display: none;
    }
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: rgba(107, 114, 128, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(107, 114, 128, 0.5);
}


/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    #navbar,
    #mobile-menu-btn,
    #mobile-menu,
    .btn-primary,
    .btn-outline,
    #toast,
    #scroll-top-btn,
    footer .social-icons {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000;
    }

    section {
        page-break-inside: avoid;
        padding: 1rem 0;
    }
}

/* ============================================
   SKELETON LOADING (for future use)
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
