/* CyberForge Arcade — Ad Diagnostics overlay
 *
 * Dev/QA-only inspector for verifying ads.txt and the sponsored-slot layout.
 * Toggled with Alt+A or window.AdDiagnostics.open(); hidden by default.
 */

#adDiagnosticsOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 11000;
    padding: 1.5rem;
    box-sizing: border-box;
}

#adDiagnosticsOverlay.visible {
    display: flex;
}

.ad-diag-panel {
    background: var(--background, #0a0a10);
    border: 1px solid var(--primary, #c0c0c0);
    box-shadow:
        0 0 32px var(--glow-color-60, rgba(192, 192, 192, 0.6)),
        0 0 64px var(--glow-color-40, rgba(192, 192, 192, 0.4));
    color: var(--text, #fff);
    width: min(960px, 100%);
    max-height: min(86vh, 800px);
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    overflow: hidden;
    font-family: inherit;
}

.ad-diag-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.2rem;
    border-bottom: 1px solid var(--primary, #c0c0c0);
    background: rgba(0, 0, 0, 0.6);
}

.ad-diag-header h2 {
    margin: 0;
    font-size: 1rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--primary, #c0c0c0);
    text-shadow: 0 0 10px var(--glow-color-60, rgba(192, 192, 192, 0.6));
}

.ad-diag-actions {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
}

.ad-diag-btn {
    background: transparent;
    border: 1px solid var(--primary, #c0c0c0);
    color: var(--text, #fff);
    font: inherit;
    font-size: 0.8rem;
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.ad-diag-btn:hover,
.ad-diag-btn:focus-visible {
    background: var(--primary, #c0c0c0);
    color: var(--background, #000);
    transform: translateY(-1px);
    box-shadow: 0 0 12px var(--glow-color-40, rgba(192, 192, 192, 0.4));
    outline: none;
}

.ad-diag-body {
    overflow: auto;
    padding: 1.1rem 1.2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.ad-diag-section h3 {
    margin: 0 0 0.5rem;
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--text, #fff);
    opacity: 0.75;
}

.ad-diag-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.6rem;
}

.ad-diag-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 0.7rem 0.85rem;
    border-radius: 4px;
}

.ad-diag-stat-label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    opacity: 0.65;
    margin-bottom: 0.25rem;
}

.ad-diag-stat-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary, #c0c0c0);
    text-shadow: 0 0 8px var(--glow-color-40, rgba(192, 192, 192, 0.4));
}

.ad-diag-status {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    border: 1px solid currentColor;
}

.ad-diag-status.ok        { color: #4ade80; }
.ad-diag-status.warn      { color: #facc15; }
.ad-diag-status.error     { color: #f87171; }
.ad-diag-status.info      { color: var(--primary, #c0c0c0); }

.ad-diag-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 6px currentColor;
}

.ad-diag-pre {
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.7rem 0.85rem;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    border-radius: 4px;
    max-height: 180px;
    overflow: auto;
    margin: 0;
}

.ad-diag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.ad-diag-entry {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 0.65rem 0.85rem;
    display: grid;
    grid-template-columns: minmax(110px, 0.6fr) repeat(3, minmax(90px, 0.6fr)) auto;
    gap: 0.6rem;
    align-items: center;
    font-size: 0.82rem;
}

.ad-diag-entry code {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.78rem;
    color: var(--text, #fff);
    opacity: 0.92;
    word-break: break-all;
}

.ad-diag-entry .ad-diag-status {
    justify-self: end;
}

.ad-diag-slot {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    padding: 0.75rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ad-diag-slot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.ad-diag-slot-id {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.8rem;
    color: var(--primary, #c0c0c0);
}

.ad-diag-slot-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.45rem;
    font-size: 0.78rem;
    opacity: 0.85;
}

.ad-diag-slot-meta div span {
    display: block;
    font-size: 0.66rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    opacity: 0.6;
    margin-bottom: 0.1rem;
}

.ad-diag-slot-actions {
    display: inline-flex;
    gap: 0.4rem;
}

.ad-diag-empty {
    padding: 0.8rem;
    text-align: center;
    opacity: 0.7;
    font-size: 0.85rem;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    border-radius: 4px;
}

/* Highlight ring placed over a slot when "Locate" is clicked. */
.ad-diag-highlight-ring {
    position: absolute;
    pointer-events: none;
    border: 2px solid #4ade80;
    box-shadow:
        0 0 18px rgba(74, 222, 128, 0.7),
        inset 0 0 12px rgba(74, 222, 128, 0.35);
    border-radius: 4px;
    z-index: 10999;
    animation: ad-diag-pulse 0.9s ease-out 2;
}

@keyframes ad-diag-pulse {
    0%   { transform: scale(1);     opacity: 1;   }
    100% { transform: scale(1.06);  opacity: 0;   }
}

@media (max-width: 600px) {
    .ad-diag-entry {
        grid-template-columns: 1fr;
    }
    .ad-diag-entry .ad-diag-status {
        justify-self: start;
    }
}
