/* ================= FOOTER ================= */
footer {
    border-top: 1px solid var(--border);
    padding: 72px 32px 32px;
    background: var(--surface);
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.6fr repeat(4, 1fr);
    gap: 36px;
    padding-bottom: 48px;
}
.footer-brand p {
    color: var(--text-secondary);
    font-size: 13.5px;
    margin-top: 14px;
    line-height: 1.6;
    max-width: 240px;
}
.footer-col h4 {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.footer-col ul li { margin-bottom: 11px; }
.footer-col ul li a {
    font-size: 13.5px;
    color: var(--text-secondary);
    transition: color .2s var(--ease);
}
.footer-col ul li a:hover { color: var(--primary); }
.footer-bottom {
    border-top: 1px solid var(--border);
    padding-top: 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
.footer-bottom p { font-size: 13px; color: var(--text-secondary); }
.social-icons { display: flex; gap: 10px; }
.social-icons a {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all .2s var(--ease);
}
.social-icons a:hover {
    color: #fff;
    background: linear-gradient(120deg, var(--primary), var(--accent));
    border-color: transparent;
}
.social-icons svg { width: 16px; height: 16px; }

@media (max-width: 900px) {
    .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
    .footer-grid { grid-template-columns: 1fr; }
}

/* ================= MOBILE STICKY SEARCH ================= */
.mobile-search-btn {
    display: none;
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    background: linear-gradient(120deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 14.5px;
    padding: 15px 26px;
    border-radius: 999px;
    box-shadow: var(--shadow-glow);
    align-items: center;
    gap: 9px;
}
.mobile-search-btn svg { width: 18px; height: 18px; }

@media (max-width: 640px) {
    .mobile-search-btn { display: flex; }
    body { padding-bottom: 88px; }
}

/* ================= COMMAND PALETTE ================= */
.cmdk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(4px);
    z-index: 300;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
}
.cmdk-overlay.open { display: flex; }
.cmdk-box {
    width: min(560px, 92vw);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: rise .25s var(--ease) both;
}
.cmdk-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.cmdk-input-row svg { width: 18px; height: 18px; color: var(--text-secondary); }
.cmdk-input-row input {
    flex: 1;
    border: none;
    background: none;
    font-size: 16px;
    color: var(--text);
}
.cmdk-results { max-height: 320px; overflow-y: auto; padding: 8px; }
.cmdk-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 11px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}
.cmdk-item:hover { background: var(--bg); }
.cmdk-item span.d {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12.5px;
    margin-left: auto;
}

/* ================= REVEAL ANIMATION ================= */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.reveal.in { opacity: 1; transform: translateY(0); }

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================= HERO SECTION ================= */
.hero {
    padding: 96px 32px 120px;
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(60% 50% at 18% 0%, rgba(37,99,235,.10), transparent 60%),
        radial-gradient(50% 45% at 85% 10%, rgba(124,58,237,.10), transparent 60%);
}
.hero-shapes { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(2px);
    opacity: .55;
    animation: float 14s ease-in-out infinite;
}
.shape.s1 {
    width: 280px; height: 280px;
    top: -60px; left: -80px;
    background: linear-gradient(135deg, rgba(37,99,235,.20), rgba(124,58,237,.05));
    animation-delay: 0s;
}
.shape.s2 {
    width: 180px; height: 180px;
    top: 120px; right: 6%;
    background: linear-gradient(135deg, rgba(124,58,237,.18), rgba(37,99,235,.05));
    animation-delay: 2s;
}
.shape.s3 {
    width: 120px; height: 120px;
    bottom: 0; left: 12%;
    background: linear-gradient(135deg, rgba(16,185,129,.15), rgba(37,99,235,.05));
    animation-delay: 4s;
}
@keyframes float {
    0%, 100% { transform: translateY(0) translateX(0); }
    50% { transform: translateY(-26px) translateX(14px); }
}
.hero-inner { position: relative; z-index: 1; max-width: 820px; margin: 0 auto; text-align: center; }
.hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
    animation: rise .7s var(--ease) both;
}
.dot-pulse {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    position: relative;
}
.dot-pulse::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: var(--success);
    opacity: .4;
    animation: pulse 1.8s ease-out infinite;
}
@keyframes pulse {
    0% { transform: scale(1); opacity: .4; }
    100% { transform: scale(2.4); opacity: 0; }
}
.hero h1 {
    font-size: clamp(28px, 6vw, 48px);
    font-weight: 800;
    letter-spacing: -0.035em;
    line-height: 1.1;
    animation: rise .8s .05s var(--ease) both;
}
.hero h1 .grad {
    background: linear-gradient(100deg, var(--primary), var(--accent) 70%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero p.sub {
    margin-top: 16px;
    font-size: 15px;
    color: var(--text-secondary);
    font-weight: 500;
    animation: rise .8s .12s var(--ease) both;
}
.hero p.sub .sep { margin: 0 8px; color: var(--border); }
.hero-search {
    margin: 32px auto 0;
    max-width: 500px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 16px;
    box-shadow: var(--shadow-lg);
    animation: rise .8s .2s var(--ease) both;
    transition: box-shadow .25s var(--ease), border-color .25s var(--ease);
}
.hero-search:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg), 0 0 0 5px rgba(37,99,235,.14);
}
.hero-search svg { width: 20px; height: 20px; color: var(--text-secondary); flex: 0 0 auto; }
.hero-search input {
    flex: 1;
    border: none;
    background: none;
    font-size: 14px;
    color: var(--text);
}
.hero-search input::placeholder { color: var(--text-secondary); }
.hero-search button {
    background: linear-gradient(120deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow-glow);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
    flex: 0 0 auto;
    display: none;
}
.hero-search button:hover { transform: translateY(-1px) scale(1.02); }
.popular-searches {
    margin-top: 26px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    animation: rise .8s .28s var(--ease) both;
}
.popular-searches span.label {
    font-size: 13.5px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-right: 2px;
}
.chip {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 8px 15px;
    border-radius: 999px;
    transition: all .2s var(--ease);
}
.chip:hover {
    color: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* ================= SECTION HEADS ================= */
.section-head {
    max-width: 640px;
    margin: 0 auto 52px;
    text-align: center;
}
.section-head .eyebrow {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 12px;
}
.section-head h2 {
    font-size: clamp(26px, 3.4vw, 38px);
    font-weight: 800;
    letter-spacing: -0.025em;
}
.section-head p {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 16px;
}
section.pad { padding: 96px 32px; }

/* ================= CATEGORIES GRID ================= */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.cat-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
    overflow: hidden;
    isolation: isolate;
}
.cat-card::before {
    content: '';
    position: absolute;
    inset: 0;
    padding: 1px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity .3s var(--ease);
    z-index: -1;
}
.cat-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
.cat-card:hover::before { opacity: 1; }
.cat-icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    background: linear-gradient(135deg, rgba(37,99,235,.10), rgba(124,58,237,.10));
    margin-bottom: 18px;
    transition: transform .3s var(--ease);
}
.cat-card:hover .cat-icon { transform: scale(1.08) rotate(-4deg); }
.cat-card h3 { font-size: 16.5px; font-weight: 700; margin-bottom: 4px; }
.cat-card p { font-size: 13.5px; color: var(--text-secondary); }

@media (max-width: 960px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .cat-grid { grid-template-columns: 1fr 1fr; } }

/* ================= TOOLS GRID ================= */
.tools-toolbar {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 44px;
    flex-wrap: wrap;
}
.tab-btn {
    font-size: 14px;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 999px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    background: var(--surface);
    transition: all .2s var(--ease);
}
.tab-btn.active, .tab-btn:hover {
    color: #fff;
    background: linear-gradient(120deg, var(--primary), var(--accent));
    border-color: transparent;
}
.tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
}
.tool-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.tool-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.tool-top { display: flex; align-items: flex-start; justify-content: space-between; }
.tool-icon {
    width: 46px; height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    background: linear-gradient(135deg, rgba(37,99,235,.12), rgba(124,58,237,.12));
}
.badge {
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .03em;
    text-transform: uppercase;
    padding: 4px 9px;
    border-radius: 999px;
}
.badge.popular { background: rgba(245,158,11,.14); color: #B45309; }
html.dark .badge.popular { color: #FBBF24; }
.fav-btn {
    width: 30px; height: 30px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all .2s var(--ease);
}
.fav-btn svg { width: 16px; height: 16px; }
.fav-btn:hover { color: var(--warning); background: rgba(245,158,11,.10); }
.fav-btn.active { color: var(--warning); }
.fav-btn.active svg { fill: var(--warning); }
.tool-card h3 { font-size: 16px; font-weight: 700; }
.tool-card p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.5; flex: 1; }
.open-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary);
    background: rgba(37,99,235,.08);
    padding: 10px 16px;
    border-radius: 11px;
    transition: all .2s var(--ease);
    align-self: flex-start;
}
.open-btn:hover {
    background: var(--primary);
    color: #fff;
    gap: 9px;
}
.open-btn svg { width: 13px; height: 13px; transition: transform .2s var(--ease); }

@media (max-width: 1080px) { .tools-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .tools-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .tools-grid { grid-template-columns: 1fr 1fr; } }

.view-all-wrap { text-align: center; margin-top: 44px; }
.btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text);
    border: 1.5px solid var(--border);
    padding: 13px 26px;
    border-radius: 999px;
    transition: all .2s var(--ease);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
}

/* ================= WHY CHOOSE US ================= */
.why-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.why-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px 26px;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.why-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }
.why-icon {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    margin-bottom: 18px;
    box-shadow: var(--shadow-glow);
}
.why-icon svg { width: 23px; height: 23px; }
.why-card h3 { font-size: 16.5px; font-weight: 700; margin-bottom: 7px; }
.why-card p { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }

@media (max-width: 860px) { .why-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .why-grid { grid-template-columns: 1fr; } }

/* ================= STATS ================= */
.stats-band {
    background: linear-gradient(120deg, var(--primary), var(--accent));
    border-radius: 28px;
    padding: 64px 40px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    text-align: center;
    box-shadow: var(--shadow-glow);
}
.stat h3 {
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.02em;
}
.stat p { color: rgba(255,255,255,.82); font-size: 14px; font-weight: 600; margin-top: 6px; }

@media (max-width: 760px) { .stats-band { grid-template-columns: 1fr 1fr; } }

/* ================= CORE WEB VITALS OPTIMIZATIONS ================= */

/* Reduce layout shift */
img, video {
    max-width: 100%;
    height: auto;
    aspect-ratio: attr(width) / attr(height);
}

/* Preload critical fonts */
@font-display: swap;

/* Ensure touch targets are at least 44px for mobile */
@media (max-width: 768px) {
    a, button, input, select, textarea {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Make buttons easier to tap on mobile */
    .btn, button, [role="button"] {
        padding: 12px 20px;
        touch-action: manipulation;
    }
    
    /* Improve form inputs on mobile */
    input[type="text"],
    input[type="email"],
    input[type="search"],
    input[type="password"],
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }
}

/* Reduce motion for users who prefer it */
@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;
    }
}

/* ================= RESPONSIVE TYPOGRAPHY ================= */

html {
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
}

/* Fluid typography */
h1 { font-size: clamp(1.75rem, 4vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.5rem); }

/* ================= MOBILE NAVIGATION IMPROVEMENTS ================= */

@media (max-width: 768px) {
    /* Ensure header stays accessible */
    header {
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    /* Improve mobile menu accessibility */
    nav ul {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    
    nav ul li {
        border-bottom: 1px solid var(--border-color);
    }
    
    nav ul li a {
        padding: 16px 20px;
        display: block;
    }
}

/* ================= MOBILE CARD OPTIMIZATIONS ================= */

@media (max-width: 480px) {
    /* Cards take full width on very small screens */
    .tool-card,
    .cat-card,
    .blog-card {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Reduce padding on cards */
    .tool-card,
    .cat-card {
        padding: 20px 16px;
    }
    
    /* Stack card actions vertically */
    .tool-card .open-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ================= MOBILE HERO OPTIMIZATIONS ================= */

@media (max-width: 640px) {
    .hero {
        padding: 60px 20px 80px;
    }
    
    .hero-search {
        flex-direction: column;
        border-radius: 16px;
        padding: 12px;
    }
    
    .hero-search input {
        width: 100%;
        margin-bottom: 12px;
    }
    
    .hero-search button {
        width: 100%;
        display: block;
    }
    
    /* Stack popular searches */
    .popular-searches {
        flex-direction: column;
        align-items: stretch;
    }
    
    .chip {
        text-align: center;
        padding: 10px 16px;
    }
}

/* ================= MOBILE GRID ADJUSTMENTS ================= */

/* 2-column grids on tablets */
@media (max-width: 960px) and (min-width: 769px) {
    .cat-grid,
    .tools-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Single column on very small screens for better readability */
@media (max-width: 400px) {
    .cat-grid,
    .tools-grid,
    .why-grid,
    .stats-band {
        grid-template-columns: 1fr;
    }
}

/* ================= ACCESSIBILITY ENHANCEMENTS ================= */

/* Focus visible styles */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: currentColor;
    }
}

/* ================= PRINT STYLES ================= */

@media print {
    header,
    footer,
    .mobile-search-btn,
    .theme-toggle,
    .no-print {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
    
    a[href^="http"]::after {
        content: " (" attr(href) ")";
    }
}

/* ================= SECTION SPACING FOR MOBILE ================= */

@media (max-width: 768px) {
    section {
        padding: 48px 20px;
    }
    
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }
}

@media (max-width: 480px) {
    section {
        padding: 32px 16px;
    }
}

/* ================= LOADING STATES ================= */

/* Skeleton loading animation */
@keyframes shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: 200px 0; }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--card-background) 0px,
        var(--border-color) 40px,
        var(--card-background) 80px
    );
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite linear;
    border-radius: 8px;
}

/* ================= CONTENT VISIBLE SAFELY ================= */

/* Ensure content is visible within viewport */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }
}

/* Prevent horizontal overflow */
body {
    overflow-x: hidden;
}

img, video, iframe, pre, table {
    max-width: 100%;
}

/* ================= SCROLL IMPROVEMENTS ================= */

html {
    scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-text);
}

/* ================= DARK MODE SCROLLBAR ================= */

html.dark ::-webkit-scrollbar-track {
    background: #1A202C;
}

html.dark ::-webkit-scrollbar-thumb {
    background: #4A5568;
}

html.dark ::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

