/*
 * cve_mobile_v3.css — Stitch-Mobil-Redesign der CVE-Seiten (09.11.2026).
 *
 * Vorlage: Stitch-Entwürfe „Mobile CVE Browser & Filter" (Auflistung) und
 * „Mobiles CVE Dossier" (Detail), Projekt „tsecurity.de: myDraft CMS Template".
 * Umgesetzt mit den ECHTEN Tokens der Seite (die Entwürfe laden Tailwind/
 * Google Fonts/Material Symbols von CDNs — CSP-blockiert, daher nur Layout-
 * Vorlage).
 *
 * Verträge:
 *  - Geladen NUR bei tsec_cve_v3_enabled() (cve.php), als blockierendes Sheet
 *    mit media="(max-width: 767.98px)" — Desktop bleibt unberührt.
 *  - Jede Regel ist auf body.cve-v3 gescoped und steht zusätzlich in
 *    @media (max-width: 767.98px) (Defense-in-Depth, falls das Sheet je ohne
 *    Media-Attribut geladen wird).
 *  - Tokens: lokale --v3-* binden an die Tokens aus cve_standalone.css
 *    (--surface-*, --border-glass, --cyan, --sev-*), die selbst an
 *    default.css (--color-*/--threat-*) hängen und hell/dunkel umschalten.
 *    /cve lädt design_tokens.css bewusst nicht (ML-4) — keine --ts-*-Tokens.
 *  - Hell-Modus ausschließlich über html[data-bs-theme="light"].
 *  - !important-Overrides gegen Bootstrap-Utilities stehen in @layer bootstrap
 *    (geschichtete Importants schlagen ungeschichtete — W4/LH1-Lektion).
 */

@media (max-width: 767.98px) {

    /* ---------- Tokens ---------- */
    .cve-v3 {
        --v3-surface: var(--surface-glass, rgba(15, 23, 42, 0.85));
        --v3-surface-low: var(--surface-1, rgba(30, 41, 59, 0.4));
        --v3-surface-strong: var(--surface-2, rgba(30, 41, 59, 0.6));
        --v3-border: var(--border-glass, rgba(255, 255, 255, 0.12));
        --v3-text: var(--color-text, #f8fafc);
        --v3-muted: var(--text-muted, #94a3b8);
        --v3-accent: var(--cyan, #00f0ff);
        --v3-accent-bg: var(--cyan-bg, rgba(0, 240, 255, 0.08));
        --v3-accent-bd: var(--cyan-border, rgba(0, 240, 255, 0.35));
        --v3-radius-xl: 0.75rem;
        --v3-radius-lg: 0.5rem;
        --v3-mono: var(--font-mono, var(--mono-stack, ui-monospace, monospace));
    }
    html[data-bs-theme="light"] .cve-v3 {
        /* Cyan #00f0ff hält auf hellen Flächen keinen Kontrast — Sky-700. */
        --v3-surface: rgba(255, 255, 255, 0.94);
        --v3-surface-low: rgba(241, 245, 249, 0.92);
        --v3-surface-strong: #ffffff;
        --v3-border: rgba(51, 65, 85, 0.24);
        --v3-text: #0f172a;
        --v3-muted: #475569;
        --v3-accent: #0369a1;
        --v3-accent-bg: rgba(3, 105, 161, 0.1);
        --v3-accent-bd: rgba(3, 105, 161, 0.35);
    }

    /* ---------- Kopfleiste: Pills als eine wischbare Zeile ---------- */
    .cve-v3 .cve-nav-actions {
        width: 100%;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        mask-image: linear-gradient(to right, #000 88%, transparent);
    }
    .cve-v3 .cve-nav-actions::-webkit-scrollbar { display: none; }
    .cve-v3 .cve-nav-actions > * { flex: 0 0 auto; }

    /* ---------- Dossier: Glas-Karte (mobil GPU-schonend) ---------- */
    .cve-v3 .cve-dossier {
        /* übersteuert das Inline-Style des Containers (Desktop-Optik) */
        background: var(--v3-surface) !important;
        backdrop-filter: blur(8px);
    }
    .cve-v3 .cve-dossier__head { flex-direction: column; align-items: stretch; }

    /* Score/EPSS/Sighting stehen mobil im Kennzahlen-Raster — die Pills
       entfallen (sonst doppelte Ansage für Screenreader). */
    .cve-v3 .cve-dossier__pill--score,
    .cve-v3 .cve-dossier__pill--epss,
    .cve-v3 .cve-dossier__pill--sighting { display: none; }

    /* Aktionen: horizontal wischbare Leiste (Stitch „Quick Action Toolbar") */
    .cve-v3 .cve-dossier__actions {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }
    .cve-v3 .cve-dossier__actions::-webkit-scrollbar { display: none; }
    .cve-v3 .cve-dossier__actions > * { flex: 0 0 auto; }

    .cve-v3 .cve-dossier__title { font-size: 1.25rem; line-height: 1.3; }
    .cve-v3 .cve-dossier__desc { font-size: 0.9rem !important; }

    /* ---------- Kennzahlen-Raster 2×2 (Stitch „Telemetry & Threat Metrics") ---------- */
    .cve-v3 .cve-v3-metrics {
        display: grid !important; /* hebt das Inline-display:none auf */
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin: 0 0 1rem;
    }
    .cve-v3 .cve-v3-metric {
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
        min-width: 0;
        padding: 0.65rem 0.75rem;
        border-radius: var(--v3-radius-lg);
        background: var(--v3-surface-low);
        border: 1px solid var(--v3-border);
    }
    .cve-v3 .cve-v3-metric__label {
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--v3-muted);
    }
    .cve-v3 .cve-v3-metric__value {
        font-family: var(--v3-mono);
        font-size: 1.6rem;
        font-weight: 700;
        line-height: 1.1;
        color: var(--v3-text);
    }
    .cve-v3 .cve-v3-metric__value small { font-size: 0.78rem; font-weight: 500; color: var(--v3-muted); }
    .cve-v3 .cve-v3-metric__sub { font-size: 0.75rem; font-weight: 700; color: var(--v3-muted); }

    .cve-v3 .cve-v3-metric--sev-critical .cve-v3-metric__value,
    .cve-v3 .cve-v3-metric--sev-critical .cve-v3-metric__sub { color: var(--sev-critical); }
    .cve-v3 .cve-v3-metric--sev-high .cve-v3-metric__value,
    .cve-v3 .cve-v3-metric--sev-high .cve-v3-metric__sub { color: var(--sev-high); }
    .cve-v3 .cve-v3-metric--sev-medium .cve-v3-metric__value,
    .cve-v3 .cve-v3-metric--sev-medium .cve-v3-metric__sub { color: var(--sev-medium); }
    .cve-v3 .cve-v3-metric--sev-low .cve-v3-metric__value,
    .cve-v3 .cve-v3-metric--sev-low .cve-v3-metric__sub { color: var(--sev-low); }
    .cve-v3 .cve-v3-metric--epss .cve-v3-metric__value { color: var(--sev-high); }
    .cve-v3 .cve-v3-metric--kev.is-active { border-color: var(--sev-critical-bd, rgba(239, 68, 68, 0.4)); }
    .cve-v3 .cve-v3-metric--kev.is-active .cve-v3-metric__label { color: var(--sev-critical); }

    .cve-v3 .cve-v3-metric__bar {
        display: block;
        height: 6px;
        margin-top: 0.3rem;
        border-radius: 9999px;
        background: var(--v3-surface-strong);
        overflow: hidden;
    }
    .cve-v3 .cve-v3-metric__bar > span {
        display: block;
        height: 100%;
        border-radius: inherit;
        background: var(--v3-accent);
    }

    /* ---------- Dossier-Abschnitte als einzelne Karten ---------- */
    .cve-v3 .cve-dossier__grid > [class*="col-"] > div:not(:empty) {
        padding: 0.875rem;
        border-radius: var(--v3-radius-xl);
        background: var(--v3-surface-low);
        border: 1px solid var(--v3-border);
    }

    /* CVSS-Vektor-Kacheln */
    .cve-v3 .metric-tile {
        border-radius: var(--v3-radius-lg);
        background: var(--v3-surface-strong);
    }
    .cve-v3 .metric-name { font-size: 0.72rem; letter-spacing: 0.05em; }
    .cve-v3 .metric-value { font-family: var(--v3-mono); }

    /* ---------- Auflistung: Kennzahlen-Kacheln + Ergebnis-Karten ---------- */
    .cve-v3 .intel-tile {
        border-radius: var(--v3-radius-lg);
        background: var(--v3-surface-low);
        border: 1px solid var(--v3-border);
    }
    .cve-v3 .intel-label { font-size: 0.72rem; letter-spacing: 0.05em; text-transform: uppercase; }
    .cve-v3 .intel-value { font-family: var(--v3-mono); }

    .cve-v3 .cve-card {
        border-radius: var(--v3-radius-xl);
        background: var(--v3-surface);
        border: 1px solid var(--v3-border);
    }
    .cve-v3 .cve-card .card-score { font-family: var(--v3-mono); }
    .cve-v3 .cve-card h2.h6 { font-size: 1rem; line-height: 1.35; }
}

/* ---------- Bootstrap-Utility-Overrides (geschichtete !important) ---------- */
@layer bootstrap {
    @media (max-width: 767.98px) {
        .cve-v3 .navbar-cve { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
        .cve-v3 .cve-nav-actions,
        .cve-v3 .cve-dossier__actions { flex-wrap: nowrap !important; }

        .cve-v3 .cve-dossier {
            padding: 1rem !important;
            border-radius: var(--v3-radius-xl) !important;
            border-color: var(--v3-border) !important;
        }
        /* CVE-ID als Hero-Chip (Stitch: surface-strong + Akzent-Mono) */
        .cve-v3 .cve-dossier__badges .bg-cyan {
            background: var(--v3-surface-strong) !important;
            color: var(--v3-accent) !important;
        }
        .cve-v3 .cve-dossier__actions .btn { border-radius: var(--v3-radius-lg) !important; }
        .cve-v3 .cve-dossier__actions [data-cve-compare-open] {
            color: var(--v3-accent) !important;
            background: var(--v3-accent-bg) !important;
            border-color: var(--v3-accent-bd) !important;
        }
        .cve-v3 .cve-card { padding: 1rem !important; }
    }
}
