/* ============================================================
   ElectroJeni — Premium UI Stylesheet
   ============================================================ */

/* ── Base ── */
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; overflow-x: hidden; }

/* ── Typography ── */
.heading-display { letter-spacing: -0.025em; }
.heading-section { letter-spacing: -0.015em; }

/* ── Line Clamp ── */
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Hero Background Pattern ── */
.hero-pattern {
    background-image:
        radial-gradient(circle at 20% 50%, rgba(249,115,22,0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(234,88,12,0.12) 0%, transparent 50%),
        radial-gradient(circle at 60% 80%, rgba(251,146,60,0.1) 0%, transparent 50%);
}
.hero-grid {
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
}

/* ── Card Hover Effects ── */
.card-hover {
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1),
                box-shadow 0.25s cubic-bezier(0.4,0,0.2,1),
                border-color 0.25s ease;
}
.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px -8px rgba(0,0,0,0.12), 0 4px 12px -4px rgba(0,0,0,0.06);
}

/* ── Category Card Glow ── */
.cat-card {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
}
.cat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--cat-color, #f97316);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.35s cubic-bezier(0.4,0,0.2,1);
}
.cat-card:hover::before { transform: scaleX(1); }
.cat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px -8px rgba(0,0,0,0.1);
}

/* ── Tool Card Image ── */
.tool-img-wrap {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #fff7ed 0%, #f1f5f9 100%);
}
.tool-img-wrap img {
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.3s ease;
}
.group:hover .tool-img-wrap img {
    transform: scale(1.08);
}
.tool-img-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.06) 0%, transparent 40%);
    pointer-events: none;
}

/* ── Button Shine Effect ── */
.btn-shine {
    position: relative;
    overflow: hidden;
}
.btn-shine::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: linear-gradient(
        to right,
        transparent 0%,
        rgba(255,255,255,0.15) 50%,
        transparent 100%
    );
    transform: rotate(30deg) translateX(-100%);
    transition: transform 0.6s ease;
}
.btn-shine:hover::after {
    transform: rotate(30deg) translateX(100%);
}

/* ── Badge Pulse ── */
.badge-pulse {
    animation: badgePulse 2s ease-in-out infinite;
}
@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ── Search Dropdown ── */
#searchResults, #mobileSearchResults, #catSearchResults, #catPageSearchResults, #allToolsSearchResults {
    animation: searchSlide 0.2s cubic-bezier(0.4,0,0.2,1);
}
@keyframes searchSlide {
    from { opacity: 0; transform: translateY(-8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Navbar Glass Effect ── */
.nav-glass {
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    background: rgba(255,255,255,0.88);
}

/* ── Navbar Button Protection ──
   Prevents inline tool CSS from leaking into navbar icons/buttons */
nav[role="navigation"] button,
nav[role="navigation"] a {
    background-color: transparent !important;
    border-radius: 0.75rem !important;
}
nav[role="navigation"] #mobileSearchBtn,
nav[role="navigation"] #mobileMenuBtn {
    background-color: transparent !important;
    background-image: none !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0.5rem !important;
    border-radius: 0.75rem !important;
}
nav[role="navigation"] #mobileSearchBtn:hover,
nav[role="navigation"] #mobileMenuBtn:hover {
    background-color: #f3f4f6 !important;
}
nav[role="navigation"] #mobileSearchBtn svg,
nav[role="navigation"] #mobileMenuBtn svg {
    color: #4b5563 !important;
    fill: none !important;
    width: 1.25rem !important;
    height: 1.25rem !important;
    background: transparent !important;
}

/* ── Stats Counter ── */
.stat-number {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Section Divider ── */
.section-divider {
    position: relative;
}
.section-divider::before {
    content: '';
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 60px; height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, #f97316, #ea580c);
}

/* ── Feature Card Glow ── */
.feature-card {
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.08);
}
.feature-card:hover {
    border-color: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    transform: translateY(-2px);
}

/* ── Iframe — Mobile Responsive Fix ── */
iframe {
    border: 0;
    display: block;
}

/* ── Tool Window (Browser-like frame) ── */
.tool-window {
    border-radius: 1rem;
    overflow: clip;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 24px -4px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.04);
    background: #fff;
}

.tool-window-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(to bottom, #f9fafb, #f3f4f6);
    border-bottom: 1px solid #e5e7eb;
}

.tool-window-dots {
    display: flex;
    gap: 6px;
}
.tool-window-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e5e7eb;
}
.tool-window-dots span:nth-child(1) { background: #fca5a5; }
.tool-window-dots span:nth-child(2) { background: #fcd34d; }
.tool-window-dots span:nth-child(3) { background: #6ee7b7; }

.tool-window-title {
    flex: 1;
    text-align: center;
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tool-window-expand {
    color: #9ca3af;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}
.tool-window-expand:hover {
    color: #f97316;
    background: rgba(249,115,22,0.08);
}

/* ── Tool Iframe Container ── */
.tool-iframe-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #fff;
    --tool-embed-height: 600px;
}

.tool-iframe {
    width: 100%;
    height: var(--tool-embed-height);
    min-height: 400px;
    max-height: 2000px;
    border: 0;
    display: block;
    background: #fff;
}

/* ── Mobile: Full-width iframe, no scaling ── */
@media (max-width: 640px) {
    .tool-window {
        border-radius: 0.75rem;
        width: 100%;
        max-width: 100%;
        margin-left: 0;
        margin-right: 0;
        border: 1px solid #e5e7eb;
    }
    .tool-window-bar {
        padding: 9px 12px;
    }
    .tool-window-title {
        font-size: 10px;
    }
    .tool-iframe {
        min-height: 350px;
    }
}

/* ── Tablet ── */
@media (min-width: 641px) and (max-width: 1024px) {
    .tool-iframe {
        min-height: 500px;
    }
}

/* ── Desktop ── */
@media (min-width: 1025px) {
    .tool-iframe {
        min-height: 550px;
    }
}

/* ── Inline Tool Container ── */
.tool-inline-container {
    width: 100%;
    /* CSS containment: prevents tool styles from leaking to parent page */
    contain: style;
}

.tool-inline-content {
    width: 100%;
    min-height: 200px;
    /* Isolate stacking context and styles */
    isolation: isolate;
}

/* Inline tool form elements — responsive defaults */
.tool-inline-content input[type="text"],
.tool-inline-content input[type="number"],
.tool-inline-content input[type="email"],
.tool-inline-content input[type="url"],
.tool-inline-content select,
.tool-inline-content textarea {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.tool-inline-content input:focus,
.tool-inline-content select:focus,
.tool-inline-content textarea:focus {
    outline: none;
    border-color: #f97316;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.tool-inline-content button {
    cursor: pointer;
    transition: all 0.2s;
}

.tool-inline-content table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.tool-inline-content table th,
.tool-inline-content table td {
    padding: 0.625rem 0.75rem;
    border: 1px solid #e5e7eb;
    text-align: left;
    font-size: 0.8125rem;
    word-break: break-word;
}

.tool-inline-content table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.tool-inline-content table tr:hover td {
    background: #f9fafb;
}

/* Responsive table wrapper for inline tools */
.tool-inline-content .table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    .tool-inline-content {
        padding: 1rem !important;
    }

    .tool-inline-content table {
        font-size: 0.75rem;
    }

    .tool-inline-content table th,
    .tool-inline-content table td {
        padding: 0.5rem;
    }
}

/* ── AdSense ── */
.adsbygoogle { display: block; margin: 0 auto; }

/* ── Focus Visible ── */
*:focus-visible {
    outline: 2px solid #f97316;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Prose (Pages & Blog) ── */
.prose h2 { font-size: 1.25rem; font-weight: 700; margin-top: 2rem; margin-bottom: 0.75rem; }
.prose h3 { font-size: 1.1rem; font-weight: 600; margin-top: 1.5rem; margin-bottom: 0.5rem; }
.prose p { margin-bottom: 1rem; line-height: 1.8; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.prose li { margin-bottom: 0.25rem; }
.prose a { color: #f97316; text-decoration: underline; }
.prose a:hover { color: #ea580c; }
.prose img { max-width: 100%; height: auto; border-radius: 0.75rem; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── All-Tools Horizontal Card Image — fixed size ── */
.tool-card-image {
    height: 160px;
    overflow: hidden;
    background: linear-gradient(135deg, #fff7ed 0%, #f1f5f9 100%);
}
.tool-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
}
.group:hover .tool-card-image img {
    transform: scale(1.08);
}

@media (min-width: 640px) {
    /* On sm+ the image is a fixed-width side column — enforce a consistent height */
    .tool-card-horizontal .tool-card-image {
        height: 140px;
    }
}

/* ── Mobile Responsive Fixes ── */
@media (max-width: 640px) {
    .hero-title { font-size: 1.75rem !important; line-height: 1.2 !important; }
    .hero-sub { font-size: 0.95rem !important; }

    /* Category page horizontal cards — stack on mobile */
    .tool-card-horizontal {
        flex-direction: column !important;
    }
    .tool-card-horizontal .tool-card-image {
        width: 100% !important;
        height: 180px !important;
    }
}

/* ── Print ── */
@media print {
    nav, footer, .adsbygoogle, #searchWrap, #mobileSearchWrap, .ad-slot { display: none !important; }
    main { padding: 0 !important; }
}
