/* ═══════════════════════════════════════════════
   ROOT VARIABLES & RESET
   ═══════════════════════════════════════════════ */

:root {
    --primary-blue: #0060f0;
    --primary-orange: #f58320;
    --dark-blue-text: #1d3557;
    --light-text: #ffffff;
    --body-bg: #f7f8fa;
    --body-text: #4a4a4a;
    --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    --card-radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    margin: 0;
    background-color: var(--body-bg);
    color: var(--body-text);
    line-height: 1.6;
    min-height: 100vh;
}

.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;
}

/* ═══════════════════════════════════════════════
   HERO SECTION
   ═══════════════════════════════════════════════ */

.hero-section {
    background: linear-gradient(90deg, #000, #000, #000);
    color: var(--light-text);
    padding: 30px 20px 60px 20px;
    text-align: center;
}

.hero-section h1 {
    font-family: 'Poppins', sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0 0 10px 0;
}

.hero-section p {
    font-family: 'Inter', sans-serif;
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 30px;
}

/* ═══════════════════════════════════════════════
   NAVIGATION
   ═══════════════════════════════════════════════ */

.hero-nav {
    max-width: 900px;
    margin: 0 auto 30px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.nav-logo a {
    font-family: 'Poppins', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--light-text);
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-logo a:hover { opacity: 1; }

.logo-icon {
    flex-shrink: 0;
}

.nav-links { display: flex; }

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}
.nav-menu li { margin-left: 25px; }
.nav-menu a {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--light-text);
    text-decoration: none;
    font-size: 1rem;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}
.nav-menu a:hover { opacity: 1; }

/* Burger Menu */
.burger-menu {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
}
.burger-menu span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--light-text);
    margin: 5px 0;
    transition: all 0.3s ease-in-out;
}

/* ═══════════════════════════════════════════════
   SEARCH FORM (inside Hero)
   ═══════════════════════════════════════════════ */

#searchForm {
    display: flex;
    justify-content: center;
    max-width: 600px;
    margin: 0 auto;
}

.search-input-wrap {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 16px;
    pointer-events: none;
}

#searchForm input[type="text"] {
    width: 100%;
    padding: 15px 20px 15px 44px;
    border: none;
    border-radius: 6px 0 0 6px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    color: #333;
    outline: none;
}
#searchForm input[type="text"]::placeholder { color: #aaa; }

#searchForm input[type="submit"] {
    padding: 15px 25px;
    background-color: var(--primary-orange);
    color: var(--light-text);
    border: none;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: background-color 0.2s ease;
}
#searchForm input[type="submit"]:hover { background-color: #e07010; }

/* ═══════════════════════════════════════════════
   HERO FEATURE PILLS
   ═══════════════════════════════════════════════ */

.hero-features {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.hero-feature {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

/* ═══════════════════════════════════════════════
   MAIN CONTAINER (overlaps hero)
   ═══════════════════════════════════════════════ */

.container {
    max-width: 900px;
    margin: -30px auto 30px auto;
    padding: 0 20px;
    position: relative;
    z-index: 10;
}

/* ═══════════════════════════════════════════════
   LOADER
   ═══════════════════════════════════════════════ */

.loader {
    background: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 30px;
    text-align: center;
    margin-bottom: 20px;
}

.loader-icon {
    margin-bottom: 12px;
    animation: pulse-icon 1.5s ease-in-out infinite;
}

@keyframes pulse-icon {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
}

.loader-status {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark-blue-text);
    margin-bottom: 12px;
    font-family: 'JetBrains Mono', monospace;
}

.loader-track {
    height: 8px;
    background: #e8ecf1;
    border-radius: 4px;
    overflow: hidden;
    max-width: 400px;
    margin: 0 auto;
}

.loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #0052d4, #4364f7);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ═══════════════════════════════════════════════
   ERROR MESSAGE
   ═══════════════════════════════════════════════ */

.error-msg {
    background-color: #ffebee;
    border: 1px solid #c62828;
    color: #c62828;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    text-align: center;
}

/* ═══════════════════════════════════════════════
   STATS ROW
   ═══════════════════════════════════════════════ */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-item {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 20px;
    text-align: center;
}

.stat-icon {
    margin-bottom: 8px;
}

.stat-num {
    font-family: 'Poppins', sans-serif;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--primary-blue);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-lbl {
    font-size: 0.85rem;
    color: #555;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ═══════════════════════════════════════════════
   COPY BUTTON
   ═══════════════════════════════════════════════ */

.copy-wrap {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 10px;
}

.copy-btn {
    background: #fff;
    border: 1.5px solid #e0e0e0;
    padding: 8px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--dark-blue-text);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.copy-btn:hover {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
}
.copy-btn.copied {
    background: var(--primary-blue);
    color: #fff;
    border-color: var(--primary-blue);
}

/* ═══════════════════════════════════════════════
   CORRELATION TABLE (White Card)
   ═══════════════════════════════════════════════ */

.table-card {
    background: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    margin-bottom: 25px;
}

.tbl-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 14px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--dark-blue-text);
    background: #f7f8fa;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}
thead th:first-child { padding-left: 24px; min-width: 180px; }
thead th:last-child { padding-right: 24px; }

.th-top { color: #065f46; }
.th-mid { color: #1e40af; }
.th-low { color: #92400e; }
.th-deind { color: #991b1b; }

tbody tr {
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7f8fa; }

tbody td {
    padding: 12px 16px;
    font-size: 0.88rem;
    color: #444;
    white-space: nowrap;
    vertical-align: middle;
}
tbody td:first-child {
    padding-left: 24px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--dark-blue-text);
}
tbody td:last-child { padding-right: 24px; }

/* Value badges */
.v {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}
.v-above {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}
.v-below {
    background: #fee2e2;
    color: #991b1b;
}
.v-inband {
    color: #bbb;
    font-weight: 400;
}
.v-nodata {
    color: #ddd;
    font-style: italic;
    font-weight: 400;
}

/* Highlighted row — strong correlation */
tbody tr.hl td {
    background: linear-gradient(90deg, #0052d4, #4364f7);
    color: #fff;
}
tbody tr.hl td:first-child { color: #fff; }
tbody tr.hl .v {
    background: rgba(255,255,255,0.2);
    color: #fff;
}
tbody tr.hl:hover td {
    background: linear-gradient(90deg, #003fa3, #3555d4);
}

/* ═══════════════════════════════════════════════
   RESULTS BREAKDOWN SECTION
   ═══════════════════════════════════════════════ */

.results-section { margin-bottom: 25px; }

.results-section .table-header {
    background: #ffffff;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    box-shadow: var(--card-shadow);
    padding: 18px 24px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.table-header-text { flex: 1; }

.table-header h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-blue-text);
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.table-header p {
    font-size: 0.82rem;
    color: #888;
    font-family: 'Inter', sans-serif;
}

/* Result cards grid */
.r-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0;
    background: #fff;
    border-radius: 0 0 var(--card-radius) var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.r-card {
    background: #fff;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    border-right: 1px solid #f0f0f0;
    transition: background 0.15s;
}
.r-card:hover { background: #f7f8fa; }

.r-pos {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: #888;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

.r-tier {
    font-size: 0.65rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    padding: 3px 10px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}
.r-tier-TOP { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.r-tier-MID { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.r-tier-LOW { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.r-tier-DEIND { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.r-title {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--dark-blue-text);
    line-height: 1.45;
    margin-bottom: 4px;
    font-family: 'Inter', sans-serif;
}

.r-url {
    font-size: 0.72rem;
    color: #999;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 8px;
    font-family: 'Inter', sans-serif;
}

.r-tags { display: flex; gap: 6px; flex-wrap: wrap; }

.r-tag {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
}
.r-tag-emq { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.r-tag-url { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.r-tag-h1 { background: #ede9fe; color: #5b21b6; border: 1px solid #c4b5fd; }
.r-tag-meta { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.r-tag-h2 { background: #ccfbf1; color: #115e59; border: 1px solid #99f6e4; }
.r-tag-h3 { background: #e0e7ff; color: #3730a3; border: 1px solid #a5b4fc; }
.r-tag-p { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.r-tag-body { background: #fff7ed; color: #9a3412; border: 1px solid #fdba74; }
.r-tag-https { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.r-tag-nohttp { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ═══════════════════════════════════════════════
   HOW TO READ SECTION
   ═══════════════════════════════════════════════ */

.how-to-read {
    background: #ffffff;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    padding: 28px 32px;
    margin-top: 25px;
}

.how-to-read h2 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--dark-blue-text);
    margin-bottom: 12px;
}

.how-to-read h3 {
    font-family: 'Poppins', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    color: #333;
    margin-top: 20px;
    margin-bottom: 8px;
}

.how-to-read p {
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--body-text);
    margin-bottom: 10px;
}

.how-to-read ul {
    padding-left: 20px;
    margin-top: 8px;
    margin-bottom: 12px;
}

.how-to-read li {
    font-family: 'Inter', sans-serif;
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--body-text);
    margin-bottom: 8px;
}

.how-to-read li strong {
    color: var(--dark-blue-text);
    font-weight: 700;
}

/* ═══════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════ */

.site-footer {
    padding: 25px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer-container {
    max-width: 900px;
    margin: 0 auto;
}

.site-footer p {
    font-family: 'Inter', sans-serif;
    margin: 0;
    font-size: 0.9rem;
    color: #888;
}

/* ═══════════════════════════════════════════════
   MOBILE RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 768px) {
    .hero-section h1 { font-size: 2rem; }

    .burger-menu { display: block; }

    .nav-links {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        width: 100%;
        background: #fff;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        border-radius: 6px;
        z-index: 1000;
    }

    .nav-links.nav-active { display: block; }

    .nav-menu {
        flex-direction: column;
        width: 100%;
    }
    .nav-menu li { margin: 0; width: 100%; }
    .nav-menu a {
        color: var(--dark-blue-text);
        padding: 15px 20px;
        display: block;
        width: 100%;
        box-sizing: border-box;
        border-bottom: 1px solid #f0f0f0;
    }
    .nav-menu li:last-child a { border-bottom: none; }
    .nav-menu a:hover {
        color: var(--primary-blue);
        background: #f7f8fa;
    }

    /* Burger animation */
    .burger-menu.nav-active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
    .burger-menu.nav-active span:nth-child(2) { opacity: 0; }
    .burger-menu.nav-active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

    .nav-logo a { flex-shrink: 0; }

    .container { padding: 0 12px; }

    #searchForm { flex-direction: column; }
    #searchForm input[type="text"] { border-radius: 6px; margin-bottom: 8px; }
    #searchForm input[type="submit"] { border-radius: 6px; width: 100%; }

    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-num { font-size: 1.6rem; }

    thead th, tbody td { padding: 8px 10px; }
    thead th:first-child, tbody td:first-child { padding-left: 14px; }

    .r-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════
   FACTOR NAME TOOLTIPS
   ═══════════════════════════════════════════════ */

.factor-name {
    position: relative;
    cursor: help;
    border-bottom: 1px dashed #aaa;
    padding-bottom: 1px;
}

.factor-name::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #1d3557;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    padding: 8px 12px;
    border-radius: 6px;
    white-space: normal;
    width: 240px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    z-index: 100;
    pointer-events: none;
}

.factor-name::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 16px;
    border: 5px solid transparent;
    border-top-color: #1d3557;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 101;
    pointer-events: none;
}

.factor-name:hover::after,
.factor-name:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ═══════════════════════════════════════════════
   SKELETON LOADING PLACEHOLDERS
   ═══════════════════════════════════════════════ */

@keyframes skel-shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skel {
    background: linear-gradient(90deg, #e8ecf1 25%, #f3f5f8 50%, #e8ecf1 75%);
    background-size: 800px 100%;
    animation: skel-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

.skel-item { opacity: 0.7; }
.skel-icon { width: 20px; height: 20px; border-radius: 50%; margin: 0 auto 8px; }
.skel-num { width: 50px; height: 28px; margin: 0 auto 6px; }
.skel-lbl { width: 90px; height: 12px; margin: 0 auto; }

.skel-table-card {
    padding: 0;
    overflow: hidden;
}

.skel-table-header {
    display: flex;
    gap: 12px;
    padding: 14px 24px;
    background: #f7f8fa;
    border-bottom: 2px solid #e0e0e0;
}
.skel-th { width: 160px; height: 14px; }
.skel-th-sm { width: 60px; height: 14px; }

.skel-table-row {
    display: flex;
    gap: 12px;
    padding: 12px 24px;
    border-bottom: 1px solid #f0f0f0;
}
.skel-cell-name { width: 160px; height: 14px; }
.skel-cell { width: 80px; height: 14px; }

.skel-results-header {
    background: #fff;
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    box-shadow: var(--card-shadow);
    padding: 18px 24px;
    margin-top: 25px;
}
.skel-heading { width: 200px; height: 18px; margin-bottom: 6px; }
.skel-subtext { width: 120px; height: 12px; }

.skel-r-card { opacity: 0.7; }
.skel-badge { width: 50px; height: 18px; margin-bottom: 8px; border-radius: 4px; }
.skel-title { width: 90%; height: 14px; margin-bottom: 6px; }
.skel-url { width: 70%; height: 10px; margin-bottom: 10px; }
.skel-tags-row { display: flex; gap: 6px; }
.skel-tag { width: 50px; height: 18px; border-radius: 4px; }

/* ═══════════════════════════════════════════════
   PRINT STYLESHEET
   ═══════════════════════════════════════════════ */

@media print {
    * { color-adjust: exact; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    body { background: #fff; color: #000; font-size: 11pt; }

    .hero-section {
        background: #1d3557 !important;
        padding: 20px;
        -webkit-print-color-adjust: exact;
    }

    #searchForm,
    .hero-features,
    .burger-menu,
    .nav-links,
    .copy-wrap,
    .loader,
    .how-to-read { display: none !important; }

    .hero-section h1 { font-size: 1.4rem; margin-bottom: 4px; }
    .hero-section p { font-size: 0.9rem; margin-bottom: 0; }

    .container {
        margin-top: 0;
        padding: 0;
        max-width: 100%;
    }

    .stats {
        display: flex;
        gap: 20px;
        margin-bottom: 15px;
    }
    .stat-item {
        box-shadow: none;
        border: 1px solid #ccc;
        padding: 10px;
    }
    .stat-icon { display: none; }

    .table-card {
        box-shadow: none;
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    thead th {
        background: #f0f0f0 !important;
        -webkit-print-color-adjust: exact;
    }

    tbody tr.hl td {
        background: #1d3557 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
    }
    tbody tr.hl .v {
        color: #fff !important;
    }

    .v-above { background: #d1fae5 !important; color: #065f46 !important; }
    .v-below { background: #fee2e2 !important; color: #991b1b !important; }

    .results-section .table-header {
        box-shadow: none;
        border: 1px solid #ccc;
        border-bottom: none;
    }

    .r-grid {
        box-shadow: none;
        border: 1px solid #ccc;
        border-top: none;
        grid-template-columns: 1fr 1fr;
    }
    .r-card {
        border-color: #ddd;
        break-inside: avoid;
    }

    .r-tag {
        -webkit-print-color-adjust: exact;
    }

    .site-footer {
        margin-top: 15px;
        padding: 10px;
    }

    .factor-name::after,
    .factor-name::before { display: none !important; }
    .factor-name { border-bottom: none; cursor: default; }
}
