/* =============================================================================
 * arc-feedback-fixes.css
 * -----------------------------------------------------------------------------
 * Consolidated CSS additions from the Blackhat review of the ARC Portal.
 * Each block is annotated with the finding ID it addresses so changes can be
 * audited or rolled back individually.
 *
 * Loaded AFTER main.css so any value set here wins specificity ties without
 * changing main.css. No selector here removes or overrides existing
 * Bootstrap behaviour.
 * =============================================================================
 */

/* -----------------------------------------------------------------------------
 * S2-1: Fixed-top header crashes into section headings and badges on scroll.
 *
 * main.css already sets `scroll-margin-top: 90px` on `<section>` (and 76px at
 * the mobile breakpoint), but that only covers section anchors. Anchored
 * navigation to anything ELSE (accordion category headers, individual
 * result-item cards, in-page :target hashes) still landed under the dark
 * navbar.  Setting `scroll-padding-top` on <html> applies a viewport-level
 * offset to ALL native anchored scrolling, including hash navigation,
 * scrollIntoView() calls, and the accordion's expand-to-view behaviour.
 * The `:target` rule covers direct anchor links, and the per-card rule
 * covers programmatic focus.
 * --------------------------------------------------------------------------- */
:root {
    /* Single source of truth for header height: match main.css line 967/975. */
    --arc-header-height: 90px;
}

@media (max-width: 1199px) {
    :root {
        --arc-header-height: 76px;
    }
}

html {
    scroll-padding-top: var(--arc-header-height);
}

:target {
    scroll-margin-top: var(--arc-header-height);
}

#arc-scan-results .accordion-button,
#arc-scan-results .accordion-item,
#arc-scan-results .result-item {
    scroll-margin-top: var(--arc-header-height);
}

/* -----------------------------------------------------------------------------
 * S2-2: Pass / Fail / Unavailable cards looked identical apart from a small
 * pill in the top-right corner that lived behind the fixed header at most
 * scroll positions. A 114-item report where only failures matter to action
 * needs the failures to look like failures.
 *
 * The result-item template in resultsAccordion.js now adds a status class
 * (`result-item-pass` / `result-item-failure` / `result-item-error`) and
 * the status badge is rendered next to the title rather than right-anchored.
 * These rules give each card:
 *   - a coloured 6px left stripe (the at-a-glance signal)
 *   - a subtle background tint
 *   - the badge with an icon ahead of it
 * The visual treatment matches Bootstrap's bg-*-subtle palette so it sits
 * comfortably alongside existing components.
 * --------------------------------------------------------------------------- */
#arc-scan-results .result-item {
    border-left: 6px solid var(--bs-secondary, #6c757d);
    transition: background-color .15s ease;
}

#arc-scan-results .result-item-pass {
    border-left-color: var(--bs-success, #198754);
    background-color: var(--bs-success-bg-subtle, #d1e7dd);
}

#arc-scan-results .result-item-failure {
    border-left-color: var(--bs-danger, #dc3545);
    background-color: var(--bs-danger-bg-subtle, #f8d7da);
}

#arc-scan-results .result-item-error {
    border-left-color: var(--bs-warning, #ffc107);
    background-color: var(--bs-warning-bg-subtle, #fff3cd);
}

/* The status badge moves into the title row; bump it up so it visually
 * matches the title weight and is never clipped by the fixed header.
 * The Bootstrap-Icons glyph in front of the label gives a non-colour
 * status cue (check, cross or question mark), important for accessibility (colour-blindness)
 * and for the print/PDF path where bg-*-subtle may not render. */
#arc-scan-results .result-item .arc-status-pill {
    font-size: .85em;
    font-weight: 600;
    padding: .35em .6em;
    display: inline-flex;
    align-items: center;
    gap: .35em;
    line-height: 1;
}

#arc-scan-results .result-item .arc-status-pill i {
    font-size: 1em;
    line-height: 1;
}

/* -----------------------------------------------------------------------------
 * S2-4: Mobile header broken at <768px: wordmark wraps, "Buy a Key" wraps
 * one word per line, and the hamburger toggle is squeezed by the wrapped
 * neighbours. The HTML now exposes a short-form wordmark inside a span that
 * is shown only at narrow viewports, and the toggle is no longer nested
 * inside <nav> (so the parent flex row gives it room). These rules make
 * sure the CTA stays on one line and the toggle is visible/styled at the
 * mobile breakpoint.
 *
 * NOTE: Bootstrap's `d-xl-none` on the toggle hides it at >=1200px; the
 * desktop nav menu takes over there. We do NOT change that breakpoint.
 * --------------------------------------------------------------------------- */
@media (max-width: 1199px) {
    /* The toggle now sits in the header's main flex row (sibling of CTA),
     * not inside <nav>. Give it a comfortable click target and ensure it
     * does not collapse to zero-width when squeezed. */
    .header .mobile-nav-toggle {
        flex: 0 0 auto;
        margin-right: .5rem;
        padding: .25rem .5rem;
        font-size: 1.6rem;
    }

    /* CTA: keep the label on one line. Falls back to a smaller padding so
     * the row continues to fit even when the wordmark is at full width. */
    .header .cta-btn {
        white-space: nowrap;
        flex: 0 0 auto;
    }
}

@media (max-width: 575px) {
    .header .cta-btn {
        padding: .35rem .75rem;
        font-size: .85rem;
    }
    /* At 375px the wordmark plus the CTA overflowed the row. */
    .header .logo { min-width: 0; }
    .header .logo h1.sitename { font-size: clamp(1.05rem, 5.2vw, 1.6rem); }
}

/* The short-form wordmark is hidden at >=576px; the long form takes over. */
.header .sitename-short { display: inline; }
.header .sitename-long  { display: none; }

@media (min-width: 576px) {
    .header .sitename-short { display: none; }
    .header .sitename-long  { display: inline; }
}

/* -----------------------------------------------------------------------------
 * S3-2 / S3-3: TXT-list annotations.
 *
 * The TXT records list (renderDNS.js) now annotates entries with provenance
 * badges: known verification tokens get a label, an empty DKIM `p=` tag
 * surfaces a "DKIM key revoked" warning, and unrecognised tokens are
 * flagged for review. These rules style the annotation chips compactly so
 * they sit in the existing TXT row without disrupting the column layout.
 * --------------------------------------------------------------------------- */
#dns-txt-list .arc-txt-tag {
    display: inline-block;
    margin-left: .5rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .02em;
    padding: .15em .4em;
    border-radius: .25rem;
    vertical-align: baseline;
    line-height: 1.2;
}

#dns-txt-list .arc-txt-tag-known {
    background: var(--bs-info-bg-subtle, #cff4fc);
    color: var(--bs-info-text-emphasis, #055160);
}

#dns-txt-list .arc-txt-tag-unknown {
    background: var(--bs-secondary-bg-subtle, #e2e3e5);
    color: var(--bs-secondary-text-emphasis, #41464b);
}

#dns-txt-list .arc-txt-tag-warning {
    background: var(--bs-warning-bg-subtle, #fff3cd);
    color: var(--bs-warning-text-emphasis, #664d03);
}

#dns-txt-list .arc-txt-tag-revoked {
    background: var(--bs-danger-bg-subtle, #f8d7da);
    color: var(--bs-danger-text-emphasis, #58151c);
}

/* -----------------------------------------------------------------------------
 * S4-6: Mobile graph viewport.
 *
 * The Network Graph handles pan, drag and pinch-zoom itself (pointer events in
 * renderDNS.js), so the browser must not claim those gestures for page
 * scrolling or zooming.
 * --------------------------------------------------------------------------- */
#graph-stage-wrap {
    touch-action: none;
}

/* -----------------------------------------------------------------------------
 * S2-3: Static-export fallback.
 *
 * When a saved/exported HTML report is opened from file://, ES modules do
 * not load and module-driven buttons (#toggle-table-view, #open-graph-panel,
 * #download-csv, #download-full-pdf) silently no-op. The HTML now contains
 * a non-module guard script that adds `.arc-disabled-static` to those
 * buttons after a 1.2s timeout if the app never reported ready. This rule
 * gives the disabled state a visible "this is dimmed for a reason" look
 * with a tooltip-friendly cursor.
 * --------------------------------------------------------------------------- */
.arc-disabled-static {
    opacity: .55 !important;
    pointer-events: none !important;
    cursor: not-allowed !important;
}

/* -----------------------------------------------------------------------------
 * Results page: score overview, category cards, findings, flags.
 * Hierarchy: overall score, then category bars, then findings (Failures
 * first). Pass cards are kept quiet so failures stand out.
 * --------------------------------------------------------------------------- */
.arc-break { overflow-wrap: anywhere; word-break: break-word; }

.arc-results-logo { max-width: 250px; }

.arc-score-card .arc-score { min-width: 11rem; }
.arc-score-value { font-size: 3rem; font-weight: 700; line-height: 1.05; }

.arc-stack { height: 10px; background-color: var(--bs-secondary-bg, #e9ecef); }
.arc-dot {
    display: inline-block;
    width: .65rem;
    height: .65rem;
    border-radius: 50%;
    margin-right: .35rem;
    vertical-align: baseline;
}
.arc-reason-list li { margin: .15rem 0; }

#arc-scan-results .result-item-pass {
    background-color: var(--bs-body-bg, #fff);
}
#arc-scan-results .result-item .card-body,
#arc-scan-results .accordion-body,
#arc-scan-results .card,
#arc-scan-results td { min-width: 0; }
#arc-scan-results .arc-check-name { overflow-wrap: anywhere; }
#arc-scan-results .arc-desc-cell { overflow-wrap: anywhere; min-width: 12rem; }
#arc-scan-results .accordion-button { flex-wrap: wrap; }

/* Specific Results / Remediation blocks: keep every line, wrap long
 * unbroken tokens, scroll instead of growing without bound. */
.arc-pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-height: 360px;
    overflow: auto;
    max-width: 100%;
}
.arc-pre-prose { font-family: var(--bs-body-font-family, sans-serif); }
.arc-pre-prose code { font-family: inherit; font-size: inherit; color: inherit; }

/* "<---" sentinel rendering: the flagged value is highlighted and the
 * sentinel becomes a labelled marker (shape plus colour). */
.arc-flagged {
    background-color: var(--bs-danger-bg-subtle, #f8d7da);
    color: var(--bs-danger-text-emphasis, #58151c);
    font-weight: 700;
    border-radius: 2px;
}
.arc-flag {
    display: inline-block;
    margin-left: .25rem;
    padding: 0 .4em;
    border-radius: .25rem;
    background-color: var(--bs-danger, #dc3545);
    color: #fff;
    font-family: var(--bs-body-font-family, sans-serif);
    font-size: .8em;
    font-weight: 600;
    white-space: normal;
}
/* CSS-drawn left-pointing triangle (no glyph, so no emoji rendering). */
.arc-flag-icon {
    display: inline-block;
    width: 0;
    height: 0;
    margin-right: .35em;
    vertical-align: middle;
    border-top: .3em solid transparent;
    border-bottom: .3em solid transparent;
    border-right: .45em solid currentColor;
}

.arc-findings-table th { white-space: nowrap; }
#arc-scan-results .arc-findings-table .arc-check-name { min-width: 11rem; overflow-wrap: break-word; }
/* The detail row spans the (horizontally scrollable) table; keep its
 * content pinned to the visible width so it never runs off-screen. */
.arc-findings-table .detail-row > td > div {
    position: sticky;
    left: 0;
    max-width: calc(100vw - 4.5rem);
}
.arc-findings-table .arc-sort-btn:focus-visible { outline: 2px solid var(--accent-color, #0d6efd); outline-offset: 2px; }

@media (max-width: 575px) {
    .arc-results-header { flex-direction: column-reverse; align-items: flex-start !important; }
    .arc-results-logo { max-width: 160px; }
    .arc-score-value { font-size: 2.4rem; }
    #arc-scan-results .filter-bar { justify-content: flex-start !important; }
    #filter-status-toggle { max-width: none; }
}

/* Printing the results page directly: drop chrome, show everything. */
@media print {
    #header, #footer, .scroll-top, #preloader, .page-title,
    #arc-scan-results .filter-bar, #arc-scan-results .arc-copy-btn,
    #arc-scan-results #toggle-table-view, #arc-scan-results #toggle-expand-all,
    #arc-scan-results .btn { display: none !important; }
    #arc-scan-results .collapse:not(.show) { display: block !important; }
    #arc-scan-results .arc-pre { max-height: none; overflow: visible; }
    #arc-scan-results .result-item { break-inside: avoid; }
    [data-aos] { opacity: 1 !important; transform: none !important; }
}

/* Results page entrance animations (assets/js/app/results/revealAnimations.js).
   The classes are added by script only, so the page is complete without it. */
.arc-reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity .5s ease, transform .5s ease;
    transition-delay: var(--arc-reveal-delay, 0ms);
}
.arc-reveal.is-in { opacity: 1; transform: none; }
.arc-stack.arc-fill .progress-bar { transition: width .6s ease; }
@media (prefers-reduced-motion: reduce) {
    .arc-reveal { opacity: 1; transform: none; transition: none; }
    .arc-stack.arc-fill .progress-bar { transition: none; }
}
@media print {
    .arc-reveal { opacity: 1 !important; transform: none !important; }
}

/* Finding description: labelled parts and linked sources (findingText.js) */
.arc-desc { display: grid; grid-template-columns: max-content 1fr; column-gap: .9rem; row-gap: .3rem; color: var(--bs-secondary-color, #6c757d); }
.arc-desc dt { font-weight: 600; color: var(--bs-emphasis-color, #1e3a5f); white-space: nowrap; }
.arc-desc dd { margin: 0; }
.arc-desc .arc-sources { list-style: none; padding: 0; margin: 0; }
.arc-desc .arc-sources li { margin: 0 0 .15rem; }
.arc-desc .arc-sources a { text-decoration: none; overflow-wrap: anywhere; }
.arc-desc .arc-sources a:hover { text-decoration: underline; }
@media (max-width: 575.98px) { .arc-desc { grid-template-columns: 1fr; } .arc-desc dd { margin-bottom: .25rem; } }
