/*
   EXPERT WEB TOOLS
*/

/* --- 1. Font Definitions (Self-Hosted) --- */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    src: url('/fonts/inter-v20-latin-regular.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Montserrat';
    font-style: normal;
    font-weight: 700;
    src: url('/fonts/montserrat-v31-latin-700.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Orbitron';
    font-style: normal;
    font-weight: 700;
    src: url('/fonts/orbitron-v35-latin-700.woff2') format('woff2');
    font-display: swap;
}
@font-face {
    font-family: 'Roboto Mono';
    font-style: normal;
    font-weight: 400;
    src: url('/fonts/roboto-mono-v31-latin-regular.woff2') format('woff2');
    font-display: swap;
}
@font-face { font-family: 'Lora'; src: url('/fonts/lora-v37-latin-regular.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Lato'; src: url('/fonts/lato-v25-latin-regular.woff2') format('woff2'); font-display: swap; }

/* --- 2. Variables & Reset --- */
:root {
    --bg-dark: #0a0a0f;
    --card-bg: rgba(25, 25, 35, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary-accent: #3b82f6;
    --secondary-accent: #8b5cf6;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-tech: 'Orbitron', sans-serif;
    --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);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
}

.background-glow {
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at center, rgba(59, 130, 246, 0.08) 0%, rgba(10, 10, 15, 0) 50%);
    z-index: -1;
    pointer-events: none;
}

/* --- 3. Web Header --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    padding-top: calc(1.5rem + var(--safe-top));
    max-width: 1400px;
    margin: 0 auto;
}

.logo {
    font-family: var(--font-tech);
    font-size: 1.5rem;
    letter-spacing: 1px;
    color: var(--text-main);
}
.logo span { color: var(--primary-accent); }

.main-header nav {
    display: flex;
    gap: 25px;
}
.main-header nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.3s ease;
    white-space: nowrap;
}
.main-header nav a:hover  { color: var(--text-main); }
.main-header nav a:focus-visible { outline: 2px solid var(--primary-accent); border-radius: 3px; }

/* --- 4. PWA App Header --- */
.app-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.75rem 1rem;
    padding-top: calc(0.75rem + var(--safe-top));
    align-items: center;
    gap: 12px;
}
.app-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-tech);
    font-size: 1rem;
    color: var(--text-main);
    white-space: nowrap;
    flex-shrink: 0;
}
.app-logo i { color: var(--primary-accent); }
.app-logo span { color: var(--primary-accent); }
.app-search-wrap {
    position: relative;
    flex: 1;
}
.app-search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.85rem;
    pointer-events: none;
}
.app-search-wrap input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.07);
    color: #fff;
    font-size: 0.9rem;
    font-family: var(--font-body);
    outline: none;
    transition: border-color 0.2s;
}
.app-search-wrap input:focus { border-color: var(--primary-accent); }

/* --- 5. Hero Section --- */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    max-width: 800px;
    margin: 0 auto;
}
.hero h1 {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 6vw, 3.5rem);
    line-height: 1.1;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero .highlight {
    background: linear-gradient(to right, var(--primary-accent), var(--secondary-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero p {
    color: var(--text-muted);
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
}
.hero-sub {
    color: var(--text-muted);
    font-size: 1rem;
    margin-top: -1.5rem;
    margin-bottom: 2.5rem;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto 2rem auto;
}
.search-icon {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-container input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    border-radius: 50px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    font-family: var(--font-body);
}
.search-container input:focus {
    border-color: var(--primary-accent);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2);
}

.tags {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}
.tag {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.85rem;
    white-space: nowrap;
}
.tag:hover, .tag.active {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-color: var(--primary-accent);
}
.tag:focus-visible { outline: 2px solid var(--primary-accent); }

/* --- 6. Tools Grid --- */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 5% 4rem 5%;
}

.category-section {
    margin-bottom: 4rem;
    width: 100%;
}
.section-title {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--card-border);
}
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.tool-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    text-decoration: none;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.tool-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
.tool-card:focus-visible {
    outline: 2px solid var(--primary-accent);
    border-radius: 16px;
}
.icon-box {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    color: var(--text-main);
    transition: background 0.3s;
    flex-shrink: 0;
}
.ai-glow {
    color: var(--secondary-accent);
    background: rgba(139, 92, 246, 0.1);
}
.tool-card:hover .icon-box { background: var(--primary-accent); color: white; }
.tool-card:hover .ai-glow  { background: var(--secondary-accent); }
.tool-card h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}
.tool-card p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.hidden { display: none !important; }

/* --- 7. About & FAQ Sections --- */
.about-section, .faq-section {
    max-width: 900px;
    margin: 4rem auto 0 auto;
    padding: 3rem;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.about-section h2, .faq-section h2 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    text-align: center;
}
.about-section p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.8;
    margin-bottom: 1rem;
}
.about-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin-top: 2.5rem;
}
.about-feature {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.about-feature strong {
    color: var(--primary-accent);
    font-size: 1.05rem;
    font-family: var(--font-heading);
    display: flex;
    align-items: center;
    gap: 8px;
}
.about-feature span {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}
.faq-section { margin-top: 2rem; }
.faq-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--card-border);
}
.faq-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }
.faq-item h3 {
    font-family: var(--font-heading);
    color: var(--text-main);
    font-size: 1.15rem;
    margin-bottom: 0.5rem;
}
.faq-item p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* --- 8. Footer & Social --- */
.social-share {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.social-share span {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
}
.social-share a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--card-border);
    border-radius: 20px;
    transition: all 0.3s;
}
.social-share a:hover {
    color: #fff;
    border-color: var(--primary-accent);
    background: rgba(59, 130, 246, 0.1);
}

footer {
    text-align: center;
    padding: 3rem 0;
    padding-bottom: calc(3rem + var(--safe-bottom));
    border-top: 1px solid var(--card-border);
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
footer a       { color: #fff; text-decoration: none; }
footer a:hover { color: var(--primary-accent); }

.footer-trust-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem 1.5rem;
    margin-bottom: 1.25rem;
}
.footer-trust-nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.88rem;
    transition: color 0.2s;
}
.footer-trust-nav a:hover { color: var(--primary-accent); }

.footer-contact {
    font-style: normal;
    margin-top: 0.75rem;
    font-size: 0.85rem;
}
.footer-contact a {
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 1px;
    transition: color 0.2s, border-color 0.2s;
}
.footer-contact a:hover {
    color: var(--primary-accent);
    border-color: var(--primary-accent);
}

/* --- 9. PWA Bottom Nav --- */
.app-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(10, 10, 15, 0.97);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border);
    padding: 8px 0;
    padding-bottom: calc(8px + var(--safe-bottom));
}
.app-bottom-nav { flex-direction: row; justify-content: space-around; align-items: center; }
.app-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: var(--font-body);
    cursor: pointer;
    padding: 6px 16px;
    border-radius: 10px;
    transition: color 0.2s, background 0.2s;
    min-width: 60px;
    -webkit-tap-highlight-color: transparent;
}
.app-nav-btn i { font-size: 1.3rem; }
.app-nav-btn.active {
    color: var(--primary-accent);
    background: rgba(59, 130, 246, 0.1);
}
.app-nav-btn:active { background: rgba(255,255,255,0.07); }

/* --- 10. PWA Standalone Mode Overrides --- */
@media (display-mode: standalone) {
    .main-header, #web-hero, #web-about, #web-faq, #web-footer { display: none !important; }

    .app-header     { display: flex; }
    .app-bottom-nav { display: flex; }

    main {
        padding: 1rem 0.75rem;
        padding-bottom: calc(80px + var(--safe-bottom));
    }

    .category-section { display: none; margin-bottom: 0; }
    .category-section.app-tab-active { display: block; }

    .section-title { font-size: 1.1rem; margin-bottom: 1rem; }

    .tools-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr) !important;
        grid-auto-rows: 96px !important;
        gap: 10px !important;
    }

    .tool-card {
        padding: 8px 4px !important;
        align-items: center !important;
        text-align: center !important;
        border-radius: 14px !important;
        justify-content: center !important;
        overflow: hidden !important;
        min-height: unset !important;
    }
    .tool-card:hover { transform: none; }
    .tool-card:active { transform: scale(0.95); background: rgba(59, 130, 246, 0.1); }

    .icon-box {
        margin: 0 auto 6px auto !important;
        width: 42px !important;
        height: 42px !important;
        font-size: 1.2rem !important;
        border-radius: 12px !important;
        flex-shrink: 0 !important;
    }

    .tool-card h3 {
        font-size: 0.68rem !important;
        font-family: var(--font-body) !important;
        font-weight: 600 !important;
        margin-bottom: 0 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        width: 100% !important;
        display: block !important;
    }
    .tool-card p { display: none !important; }
}

/* --- 11. Tablet & Narrow Desktop --- */
@media (max-width: 900px) {
    .main-header nav { gap: 15px; }
}

/* --- 12. Mobile Web (portrait) --- */
@media (max-width: 768px) {
    .main-header {
        padding: 1rem 4%;
        padding-top: calc(1rem + var(--safe-top));
    }
    .main-header nav {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 12px;
        padding-bottom: 2px;
        justify-content: flex-start;
        width: 100%;
    }
    .main-header nav::-webkit-scrollbar { display: none; }

    .hero { padding: 2rem 0.5rem; }
    .hero-sub { display: none; }

    .search-container input {
        padding: 12px 20px 12px 45px;
        font-size: 0.95rem;
    }

    .tags {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        padding-bottom: 4px;
        scrollbar-width: none;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .tags::-webkit-scrollbar { display: none; }

    main { padding: 0 4% 3rem 4%; }

    .tools-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr) !important;
        grid-auto-rows: 96px !important;
        gap: 10px !important;
    }

    .tool-card {
        padding: 8px 4px !important;
        align-items: center !important;
        text-align: center !important;
        border-radius: 12px !important;
        justify-content: center !important;
        overflow: hidden !important;
        min-height: unset !important;
    }

    .icon-box {
        margin: 0 auto 6px auto !important;
        width: 42px !important;
        height: 42px !important;
        font-size: 1.2rem !important;
        border-radius: 12px !important;
        flex-shrink: 0 !important;
    }

    /* Single line, ellipsis as absolute last resort safety net */
    .tool-card h3 {
        font-size: 0.68rem !important;
        font-family: var(--font-body) !important;
        font-weight: 600 !important;
        margin-bottom: 0 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        width: 100% !important;
        display: block !important;
    }
    .tool-card p { display: none !important; }

    .about-section, .faq-section {
        padding: 1.5rem;
        margin-top: 3rem;
    }
    .about-section h2, .faq-section h2 { font-size: 1.4rem; }

    .footer-trust-nav { gap: 0.4rem 1rem; }
    .footer-contact { margin-top: 0.6rem; }
}

/* --- 13. Very small screens (Galaxy Fold, 320px) --- */
@media (max-width: 360px) {
    .tools-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        grid-auto-rows: 90px !important;
    }
    .icon-box { width: 38px !important; height: 38px !important; font-size: 1rem !important; }
    .tool-card h3 { font-size: 0.62rem !important; }
}

/* --- 14. Portrait mobile hero tighten (≤ 480px) --- */
@media (max-width: 480px) {
    .hero p    { font-size: 1rem;  margin-bottom: 1.5rem; }
    .hero-sub  { font-size: 0.9rem; margin-bottom: 1.5rem; }
}

/* --- 15. Skip link (accessibility) --- */
.sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* --- 16. Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}