/* Image Forensics tool styles */

:root {
    --fx-stage-bg: #0d1117;
    --fx-stage-border: rgba(255, 255, 255, 0.08);
    --fx-terminal-bg: #0a0f0a;
    --fx-terminal-fg: #7ee787;
    --fx-checker-a: rgba(255, 255, 255, 0.06);
    --fx-checker-b: rgba(255, 255, 255, 0.02);
}

[data-bs-theme="light"] {
    --fx-stage-border: rgba(0, 0, 0, 0.08);
}

/* The dashboard intentionally has its own layout: the tool is a wide,
   multi-pane workspace rather than a short form. */
.forensics-dashboard {
    overflow: hidden;
}

.forensics-heading-icon {
    display: inline-grid;
    width: 2rem;
    height: 2rem;
    place-items: center;
    color: var(--bs-primary);
    background: var(--bs-primary-bg-subtle);
    border-radius: 0.7rem;
}

.forensics-heading-note {
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 999px;
    background: var(--bs-body-bg);
}

#forensics-drop-zone {
    min-height: 220px;
    display: grid;
    place-items: center;
    padding: 2rem;
    border-color: color-mix(in srgb, var(--bs-primary) 35%, var(--bs-border-color));
    background: color-mix(in srgb, var(--bs-primary-bg-subtle) 32%, transparent);
    transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

#forensics-drop-zone:hover,
#forensics-drop-zone.border-primary {
    border-color: var(--bs-primary) !important;
    background: var(--bs-primary-bg-subtle);
}

#forensics-drop-zone:hover {
    transform: translateY(-1px);
}

.forensics-tool-rail {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: var(--bs-body-bg);
}

.forensics-tool-nav {
    padding-top: 1.15rem;
    border-top: 1px solid var(--bs-border-color);
}

.forensics-comparison-stage {
    min-height: clamp(430px, 54vw, 720px);
    height: 100%;
    padding: 0;
    overflow: hidden;
}

.forensics-comparison-stage > #forensics-drop-zone {
    position: absolute;
    inset: 0.75rem;
    z-index: 6;
    min-height: 0;
    padding: 2rem;
    background: color-mix(in srgb, var(--fx-stage-bg) 88%, var(--bs-primary) 12%);
}

.forensics-comparison-stage > #forensics-drop-zone:hover,
.forensics-comparison-stage > #forensics-drop-zone.border-primary {
    background: color-mix(in srgb, var(--fx-stage-bg) 78%, var(--bs-primary) 22%);
}

.forensics-canvas-wrap {
    position: absolute;
    inset: 0.75rem 0.75rem 4.2rem;
    overflow: hidden;
}

.forensics-canvas-wrap > canvas:not(#forensics-magnifier-lens) {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    object-fit: contain;
}

.forensics-comparison-stage > .forensics-empty-state {
    position: absolute;
    inset: 0.75rem 0.75rem 4.2rem;
    min-height: 0;
    z-index: 1;
}

.forensics-comparison-labels {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    left: 1.25rem;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.forensics-comparison-labels span {
    padding: 0.3rem 0.55rem;
    color: #fff;
    background: rgba(13, 17, 23, 0.72);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.forensics-comparison-divider {
    position: absolute;
    top: 0.75rem;
    bottom: 4.2rem;
    left: 50%;
    z-index: 4;
    width: 2px;
    background: var(--bs-primary);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.32);
    pointer-events: none;
}

.forensics-comparison-divider span {
    position: absolute;
    top: 50%;
    left: 50%;
    display: block;
    width: 2rem;
    height: 2rem;
    background: var(--bs-primary);
    border: 3px solid var(--fx-stage-bg);
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.forensics-comparison-divider span::before,
.forensics-comparison-divider span::after {
    position: absolute;
    top: 50%;
    color: #fff;
    font-size: 0.75rem;
    line-height: 1;
    transform: translateY(-50%);
}

.forensics-comparison-divider span::before {
    left: 0.3rem;
    content: "‹";
}

.forensics-comparison-divider span::after {
    right: 0.3rem;
    content: "›";
}

.forensics-comparison-control {
    position: absolute;
    right: 1rem;
    bottom: 0.75rem;
    left: 1rem;
    z-index: 5;
    display: grid;
    grid-template-columns: auto 3.2rem;
    gap: 0.35rem 0.75rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: var(--bs-body-color);
    background: color-mix(in srgb, var(--fx-stage-bg) 88%, transparent);
    border: 1px solid var(--fx-stage-border);
    border-radius: 0.75rem;
    font-size: 0.75rem;
}

.forensics-comparison-control output {
    color: var(--bs-primary);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.forensics-comparison-control input {
    grid-column: 1 / -1;
    width: 100%;
    margin: 0;
}

#forensics-thumb {
    max-height: 150px;
}

#forensics-xmp-content {
    max-height: 240px;
    overflow: auto;
}

#clone-progress {
    height: 6px;
}

/* Canvas stage: deliberately kept as a dark matte in both themes so pixel-level
   analysis output reads consistently regardless of site theme. */
.forensics-stage {
    background-color: var(--fx-stage-bg);
    background-image:
        repeating-conic-gradient(var(--fx-checker-a) 0% 25%, var(--fx-checker-b) 0% 50%);
    background-size: 20px 20px;
    border: 1px solid var(--fx-stage-border);
    border-radius: var(--bs-border-radius-lg, 0.75rem);
    padding: 0.75rem;
    min-height: 320px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.forensics-stage canvas {
    max-width: 100%;
    width: 100%;
    max-height: 440px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.forensics-empty-state {
    display: flex;
    min-height: 270px;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--bs-body-secondary);
    text-align: center;
}

.forensics-empty-state i {
    margin-bottom: 0.5rem;
    color: var(--bs-primary);
    font-size: 2rem;
    opacity: 0.75;
}

.forensics-empty-state span {
    color: var(--bs-body-color);
    font-weight: 700;
}

.forensics-empty-state small {
    font-size: 0.78rem;
}

.forensics-control + .forensics-control {
    margin-top: 1rem;
}

.forensics-control .form-label {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.35rem;
}

.forensics-control output {
    min-width: 2.8rem;
    color: var(--bs-primary);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* 160px must match LENS_CSS in forensics-ui.js; JS positions it via transform. */
#forensics-magnifier-lens {
    top: 0;
    left: 0;
    width: 160px;
    height: 160px;
    border: 2px solid var(--bs-primary);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* While the magnifier tab is active: track touches instead of scrolling. */
#forensics-canvas-output.fx-magnify-active {
    touch-action: none;
    cursor: crosshair;
}

/* Overlay shown on the output stage while an async analysis (ELA) is
   pending; created and d-none-toggled by forensics-pipeline.js. */
.fx-spinner-overlay {
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(13, 17, 23, 0.45);
    border-radius: var(--bs-border-radius-lg, 0.75rem);
    z-index: 5;
}

.forensics-placeholder i {
    opacity: 0.6;
}

#forensics-strings-terminal {
    font-family: var(--font-body, monospace), monospace;
    font-size: 0.8rem;
    max-height: 320px;
    overflow: auto;
    background-color: var(--fx-terminal-bg);
    color: var(--fx-terminal-fg);
    border-radius: var(--bs-border-radius, 0.5rem);
    padding: 0.75rem 1rem;
    white-space: pre-wrap;
    word-break: break-all;
}

#forensicsTabs {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    width: 100%;
    padding: 0.35rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    background: var(--bs-body-bg);
    margin-bottom: 0 !important;
}

#forensicsTabs .nav-item {
    flex: 0 0 auto;
}

#forensicsTabs .nav-link {
    width: 100%;
    white-space: normal;
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    text-align: left;
}

.forensics-analysis-settings {
    padding: 0.25rem;
}

.forensics-analysis-title {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.forensics-analysis-title > i {
    padding-top: 0.15rem;
    font-size: 1.1rem;
}

.forensics-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem 1.5rem;
}

/* shared.css forces .nav-link:hover to primary blue (!important), which makes
   the active pill's label blue-on-blue. Higher specificity wins it back. */
#forensicsTabs .nav-link.active,
#forensicsTabs .nav-link.active:hover {
    color: var(--bs-nav-pills-link-active-color, #fff) !important;
}

#tab-clone input[type="range"],
#tab-levelsweep input[type="range"],
#tab-lumgrad input[type="range"],
#tab-ela input[type="range"],
#tab-noise input[type="range"],
#tab-strings input[type="range"],
#tab-magnifier input[type="range"] {
    max-width: 200px;
}

#forensicsTabsContent {
    min-height: 9rem;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1rem;
    background: var(--bs-body-bg);
}

@media (max-width: 991.98px) {
    .forensics-stage {
        min-height: 260px;
    }
}

@media (max-width: 575.98px) {
    .forensics-heading-note {
        width: 100%;
        border-radius: 0.75rem;
    }

    #forensics-drop-zone {
        min-height: 190px;
        padding: 1.5rem 1rem;
    }

    #forensicsTabsContent {
        padding: 0.75rem;
    }
}

#clone-progress-bar {
    width: 0%;
}

#metric-dims,
#metric-filesize,
#metric-metacount {
    font-size: 0.85rem;
}

.forensics-metric-label {
    font-size: 0.65rem;
}
