/* 
    FAK HUB STYLESHEET v4.0 (Performance & SEO Optimized)
    (c) 2025 Faizan Ahmad Khichi
*/

:root {
    /* --- Light Theme (Default) --- */
    --bg-base: #f8f9fa;
    --bg-glass: rgba(255, 255, 255, 0.9); /* More opacity for legibility */
    --bg-card: #ffffff;
    --text-primary: #09090b;
    --text-secondary: #52525b;
    --border-color: #e4e4e7;
    --accent-color: #000000;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --card-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    
    /* Brand Colors */
    --brand-red: #ef4444;
    --brand-yellow: #f59e0b;
    --brand-green: #10b981;
    --brand-purple: #8b5cf6;
    
    --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-bs-theme="dark"] {
    /* --- Dark Theme --- */
    --bg-base: #09090b;
    --bg-glass: rgba(9, 9, 11, 0.9);
    --bg-card: #18181b;
    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --border-color: #27272a;
    --accent-color: #ffffff;
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --card-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.7);
}

/* --- Global Performance Reset --- */
*, *::before, *::after { box-sizing: border-box; }

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-body);
    /* Improve text rendering */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    /* Prevent Pull-to-refresh on mobile (optional, feels more like an app) */
    overscroll-behavior-y: none; 
}

h1, h2, h3, h4, h5, .brand-text { font-family: var(--font-display); letter-spacing: -0.02em; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; display: block; } /* Prevents CLS */

/* --- Animated Background --- */
#bg-animation {
    position: fixed; inset: 0; z-index: -1;
    /* Hardware Accelerated Gradient */
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.08), transparent 70%),
                radial-gradient(circle at 80% 10%, rgba(239, 68, 68, 0.08), transparent 60%);
    pointer-events: none;
    will-change: transform; /* Hint to browser */
}

/* --- Header --- */
.glass-header {
    background: var(--bg-glass);
    backdrop-filter: blur(12px); /* Reduced blur for performance */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 1000;
    padding: 0.7rem 0;
    transition: border-color 0.3s;
}
.brand-logo { border-radius: 10px; }
.brand-text { font-weight: 700; font-size: 1.25rem; background: linear-gradient(90deg, var(--text-primary), var(--text-secondary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.btn-icon-only {
    color: var(--text-primary); border: 1px solid var(--border-color);
    width: 40px; height: 40px; border-radius: 50%; /* 40px min touch target */
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
    background: transparent;
}
.btn-icon-only:hover { background: var(--bg-card); }

/* --- Hero --- */
.text-gradient {
    background: linear-gradient(90deg, var(--brand-purple), var(--brand-red));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    font-weight: 800;
}
.stats-pill {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 30px; font-size: 0.85rem;
    box-shadow: var(--card-shadow);
}
.search-wrapper { position: relative; max-width: 500px; margin: 0 auto; }
.search-icon { position: absolute; left: 1.2rem; top: 50%; transform: translateY(-50%); color: var(--text-secondary); pointer-events: none; }
.search-input {
    width: 100%; padding: 1rem 1rem 1rem 3.2rem;
    border-radius: 16px; border: 1px solid var(--border-color);
    background: var(--bg-card); color: var(--text-primary);
    box-shadow: var(--card-shadow); font-family: var(--font-display);
    transition: border-color 0.2s, box-shadow 0.2s;
    font-size: 16px; /* Prevents auto-zoom on iOS */
}
.search-input:focus { outline: none; border-color: var(--brand-purple); box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15); }

/* --- GRID SYSTEM (Optimized for Mobile) --- */
@media (max-width: 576px) {
    .row.g-2 > [class*="col-"] { padding-right: 4px; padding-left: 4px; }
    .col-4 { width: 33.3333%; }
}

/* --- Tool Cards --- */
.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1rem 0.5rem;
    height: 100%;
    display: flex; flex-direction: column; align-items: center;
    text-align: center; color: var(--text-primary);
    position: relative;
    /* GPU Optimization */
    transform: translateZ(0); 
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), border-color 0.2s;
    cursor: pointer;
}
.tool-card:hover {
    transform: translateY(-4px);
    border-color: var(--brand-purple);
    box-shadow: var(--card-hover);
    z-index: 2;
}
.tool-icon-box {
    width: 48px; height: 48px;
    background: var(--bg-base); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; color: var(--text-primary);
    margin-bottom: 0.6rem;
    overflow: hidden; /* Ensure images don't spill */
}
.tool-title {
    font-size: 0.75rem; font-weight: 600;
    line-height: 1.2; margin-bottom: 0;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.4em; /* Enforce alignment */
}
.tool-badge { 
    font-size: 0.65rem; color: var(--brand-green); 
    margin-top: 4px; font-weight: 700; letter-spacing: 0.5px;
    opacity: 0.8;
}

.fav-icon {
    position: absolute; top: 6px; right: 6px;
    font-size: 0.9rem; color: var(--border-color);
    padding: 6px; z-index: 5; transition: color 0.2s;
}
.fav-icon.active { color: var(--brand-yellow); text-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }

/* --- Skeleton Loader (Shimmer) --- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-card) 25%, var(--border-color) 50%, var(--bg-card) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite linear;
    border: 1px solid var(--border-color);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* --- Music Player (Responsive) --- */
.music-fab {
    position: fixed; bottom: 80px; right: 20px;
    width: 54px; height: 54px;
    background: var(--bg-card); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--card-shadow); cursor: pointer;
    z-index: 1010; transition: transform 0.2s;
    font-size: 1.5rem;
}
.music-fab:hover { color: var(--brand-purple); transform: scale(1.05); }
.music-fab.playing { border-color: var(--brand-green); color: var(--brand-green); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); } 70% { box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }

.music-player-card {
    position: fixed; bottom: 85px; right: 80px;
    width: 300px; background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: 16px;
    box-shadow: var(--card-hover); z-index: 1015; 
    display: none; animation: slideUp 0.3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Music Player override */
@media (max-width: 576px) {
    .music-player-card { right: 50%; transform: translateX(50%); bottom: 90px; width: 90%; }
    @keyframes slideUp { from { opacity: 0; transform: translate(50%, 20px); } to { opacity: 1; transform: translate(50%, 0); } }
}

.player-header { padding: 10px 15px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: var(--bg-base); border-radius: 16px 16px 0 0; }
.progress-area { height: 6px; background: var(--bg-base); border-radius: 3px; cursor: pointer; position: relative; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-purple), var(--brand-red)); width: 0%; transition: width 0.1s linear; }
.btn-ctrl { background: none; border: none; color: var(--text-primary); padding: 0; cursor: pointer; }
.btn-ctrl.big { font-size: 2.5rem; } .btn-ctrl.small { font-size: 1.5rem; color: var(--text-secondary); }

/* Playlist Scrollbar */
.playlist-container { max-height: 180px; overflow-y: auto; background: var(--bg-base); }
.playlist-item { padding: 10px; border-bottom: 1px solid var(--border-color); cursor: pointer; font-size: 0.9rem; }
.playlist-item:hover, .playlist-item.active { background: rgba(139, 92, 246, 0.1); color: var(--brand-purple); }

/* --- Support FAB --- */
.fab-support {
    position: fixed; bottom: 20px; right: 20px;
    width: 54px; height: 54px;
    background: var(--text-primary); color: var(--bg-card);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; cursor: pointer;
    box-shadow: var(--card-shadow); z-index: 1020;
    transition: transform 0.2s;
}
.fab-support:hover { transform: scale(1.1) rotate(10deg); background: var(--brand-purple); }

/* --- Footer (Render Performance) --- */
.site-footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
    padding: 3rem 1rem 2rem;
    margin-top: 4rem; text-align: center;
    /* Don't render until visible */
    content-visibility: auto; 
    contain-intrinsic-size: 1px 300px;
}
.promo-card {
    display: block; max-width: 400px; margin: 0 auto;
    background: linear-gradient(135deg, #0f172a, #334155);
    border-radius: 16px; padding: 1.2rem;
    transition: transform 0.2s; text-decoration: none;
}
.promo-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.footer-links a { color: var(--text-secondary); font-size: 0.9rem; transition: color 0.2s; font-weight: 500; }
.footer-links a:hover { color: var(--brand-purple); }

/* --- Animations --- */
.fade-in-up { animation: fadeUp 0.5s ease-out forwards; opacity: 0; transform: translateY(10px); }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* Desktop Tweaks */
@media (min-width: 768px) {
    .tool-card { padding: 1.5rem; }
    .tool-icon-box { width: 64px; height: 64px; font-size: 2rem; }
    .tool-title { font-size: 1rem; }
    .tool-badge { font-size: 0.75rem; margin-top: 8px; }
}