/* Asforin Global UI Utilities - Mobile-First Responsive Design */

:root {
    --primary: #13c8ec;
    --primary-hover: #0ea5c3;
    --background-dark: #020617;
    --surface-dark: #0f172a;
    --slate-900: #0f172a;
    --slate-800: #1e293b;

    /* Responsive Spacing System - Mobile First */
    --spacing-xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --spacing-sm: clamp(0.5rem, 1vw, 0.75rem);
    --spacing-md: clamp(0.75rem, 1.5vw, 1rem);
    --spacing-lg: clamp(1rem, 2vw, 1.5rem);
    --spacing-xl: clamp(1.5rem, 3vw, 2rem);
    --spacing-2xl: clamp(2rem, 4vw, 3rem);

    /* Touch Target Minimum */
    --touch-target: 44px;

    /* Responsive Font Sizes */
    --font-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
    --font-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
    --font-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
    --font-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
    --font-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
    --font-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
    --font-3xl: clamp(1.875rem, 1.5rem + 1.875vw, 2.5rem);
    --font-4xl: clamp(2.25rem, 1.75rem + 2.5vw, 3rem);
    --font-5xl: clamp(2.5rem, 2rem + 2.5vw, 3.5rem);
}

html {
    scroll-behavior: smooth;
    /* Prevent horizontal scroll on mobile */
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar - Mobile Optimized */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}


.dark body {
    background-color: var(--background-dark);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(19, 200, 236, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(124, 58, 237, 0.08) 0%, transparent 50%);
    background-attachment: fixed;
}

/* Glassmorphism - Mobile Optimized */
.glass-panel {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    contain: content;
    padding: clamp(1rem, 2vw, 1.5rem);
}

.glass-card {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    padding: clamp(1rem, 2vw, 1.5rem);
}

.glass-card:hover,
.glass-card:focus-within {
    background: rgba(15, 23, 42, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 10px 40px -10px rgba(19, 200, 236, 0.2);
}

/* Enhanced hover on desktop only */
@media (min-width: 1024px) {
    .glass-card:hover {
        transform: translateY(-4px);
    }
}

/* Active state for mobile touch */
.glass-card:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

.glass-header {
    background: rgba(2, 6, 23, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Reduce backdrop blur on mobile for performance */
@media (max-width: 767px) {
    .glass-header {
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

/* Ambient Background Blobs - Mobile Optimized */
.ambient-blob {
    position: absolute;
    border-radius: 50%;
    z-index: 0;
    opacity: 0.12;
    animation: drift 30s infinite alternate linear;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

/* Hide blobs on very small screens for performance */
@media (max-width: 480px) {
    .ambient-blob {
        display: none;
    }
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: clamp(300px, 50vw, 600px);
    height: clamp(300px, 50vw, 600px);
    animation-duration: 25s;
}

.blob-2 {
    top: 20%;
    right: -10%;
    width: clamp(350px, 60vw, 700px);
    height: clamp(350px, 60vw, 700px);
    animation-duration: 30s;
    animation-delay: -5s;
}

.blob-3 {
    bottom: -10%;
    left: 20%;
    width: clamp(250px, 40vw, 500px);
    height: clamp(250px, 40vw, 500px);
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }

    33% {
        transform: translate3d(10%, 15%, 0) scale(1.2) rotate(10deg);
    }

    66% {
        transform: translate3d(-10%, 10%, 0) scale(0.9) rotate(-10deg);
    }

    100% {
        transform: translate3d(0, 0, 0) scale(1) rotate(0deg);
    }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    .ambient-blob {
        animation: none;
        opacity: 0.08;
    }
}

.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}

.dark .bg-mesh {
    opacity: 1;
}

/* Grid & Textures */
.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(19, 200, 236, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(19, 200, 236, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: radial-gradient(circle at center, black, transparent 80%);
    -webkit-mask-image: radial-gradient(circle at center, black, transparent 80%);
    pointer-events: none;
    z-index: 1;
}

.grain-filter {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.03;
    pointer-events: none;
    z-index: 2;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}

/* Viz Lines */
.viz-line {
    position: absolute;
    background: linear-gradient(90deg, transparent, rgba(19, 200, 236, 0.2), transparent);
    height: 1px;
    width: 100%;
    z-index: 1;
    animation: scan 10s infinite linear;
    will-change: transform;
}

@keyframes scan {
    0% {
        transform: translate3d(0, -100%, 0);
        opacity: 0;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        transform: translate3d(0, 200%, 0);
        opacity: 0;
    }
}

/* Animations - Mobile Optimized */
.float-animation {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

/* Reduce float on mobile */
@media (max-width: 767px) {
    @keyframes float {

        0%,
        100% {
            transform: translateY(0);
        }

        50% {
            transform: translateY(-10px);
        }
    }
}

.animate-pulse-slow {
    animation: pulse-slow 4s ease-in-out infinite;
}

@keyframes pulse-slow {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Disable animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {

    .float-animation,
    .animate-pulse-slow {
        animation: none;
    }
}

.shadow-glow {
    box-shadow: 0 0 20px rgba(19, 200, 236, 0.15);
}

.shadow-glow-hover {
    box-shadow: 0 0 30px rgba(19, 200, 236, 0.3);
}

/* Search Overlay - Mobile Optimized */
.search-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(2, 6, 23, 0.98);
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding: var(--spacing-md);
}

.search-overlay.active {
    display: block;
    opacity: 1;
}

.search-container {
    max-width: 600px;
    margin: clamp(5vh, 10vh, 10vh) auto;
    padding: 0 clamp(1rem, 3vw, 1.25rem);
}

.search-input-wrapper {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: clamp(1rem, 2vw, 1.5rem);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 2vw, 1rem);
    min-height: var(--touch-target);
}

.search-input-wrapper input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    outline: none;
}

.search-input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Touch-friendly close button */
.search-input-wrapper button {
    min-width: var(--touch-target);
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-results {
    margin-top: clamp(1rem, 3vw, 2rem);
    max-height: 60vh;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 2vw, 1rem);
    padding: clamp(0.75rem, 2vw, 1rem);
    border-radius: clamp(0.75rem, 2vw, 1rem);
    transition: background 0.2s;
    cursor: pointer;
    min-height: var(--touch-target);
}

.search-result-item:hover,
.search-result-item:focus {
    background: rgba(19, 200, 236, 0.1);
}

.search-result-item:active {
    background: rgba(19, 200, 236, 0.15);
}

/* Breadcrumbs */
.breadcrumb-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2rem;
}

.breadcrumb-item:hover {
    color: var(--primary);
}

.breadcrumb-separator {
    color: rgba(255, 255, 255, 0.1);
}

/* Scroll Progress Bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: var(--primary);
    width: 0%;
    z-index: 101;
    transition: width 0.1s;
    box-shadow: 0 0 10px var(--primary);
}

/* ========================================
   MOBILE-FIRST UTILITY CLASSES
   ======================================== */

/* Touch-Friendly Buttons */
.btn-touch {
    min-height: var(--touch-target);
    min-width: var(--touch-target);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 3vw, 2rem);
    font-size: var(--font-base);
    border-radius: clamp(0.75rem, 2vw, 1rem);
    transition: all 0.2s ease;
}

.btn-touch:active {
    transform: scale(0.98);
}

/* Responsive Container Padding */
.container-responsive {
    padding-left: clamp(1rem, 4vw, 1.5rem);
    padding-right: clamp(1rem, 4vw, 1.5rem);
}

/* Form Input Mobile Optimization */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
    min-height: var(--touch-target);
    font-size: 16px;
    /* Prevents zoom on iOS */
    -webkit-appearance: none;
    appearance: none;
}

/* Prevent zoom on input focus for iOS */
@media screen and (max-width: 767px) {

    input[type="text"]:focus,
    input[type="email"]:focus,
    input[type="password"]:focus,
    input[type="tel"]:focus,
    input[type="url"]:focus,
    input[type="search"]:focus,
    textarea:focus,
    select:focus {
        font-size: 16px;
    }
}

/* Responsive Typography Utilities */
.text-responsive-xs {
    font-size: var(--font-xs);
}

.text-responsive-sm {
    font-size: var(--font-sm);
}

.text-responsive-base {
    font-size: var(--font-base);
}

.text-responsive-lg {
    font-size: var(--font-lg);
}

.text-responsive-xl {
    font-size: var(--font-xl);
}

.text-responsive-2xl {
    font-size: var(--font-2xl);
}

.text-responsive-3xl {
    font-size: var(--font-3xl);
}

.text-responsive-4xl {
    font-size: var(--font-4xl);
}

.text-responsive-5xl {
    font-size: var(--font-5xl);
}

/* Responsive Spacing Utilities */
.gap-responsive {
    gap: var(--spacing-md);
}

.gap-responsive-lg {
    gap: var(--spacing-lg);
}

.p-responsive {
    padding: var(--spacing-md);
}

.p-responsive-lg {
    padding: var(--spacing-lg);
}

.m-responsive {
    margin: var(--spacing-md);
}

.m-responsive-lg {
    margin: var(--spacing-lg);
}

/* Mobile-Specific Helpers */
.mobile-only {
    display: block;
}

.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }

    .desktop-only {
        display: block;
    }
}

/* Safe Area Insets for Mobile Devices */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }

    .glass-header {
        padding-left: max(1.5rem, env(safe-area-inset-left));
        padding-right: max(1.5rem, env(safe-area-inset-right));
    }
}

/* Improved Focus Styles for Accessibility */
*:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Better Image Handling */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive Video Embeds */
.video-responsive {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive object,
.video-responsive embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Performance Optimization */
.will-change-transform {
    will-change: transform;
}

.gpu-accelerated {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Reduce Motion for All Animations */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}