/* =============================================================================
   Content report overlay — one stylesheet for all five report surfaces
   (section test, dynamic exam, road signs, 3D driving game, 2D parking game).

   Self-contained on purpose: the two game pages load no Bootstrap and no
   `smartdrive.css`, so every colour is declared inside the overlay's own
   scope rather than inherited from the host page. The host page only decides
   light or dark.

   The design language follows DESIGN.md — the asphalt ink for text, signal
   blue for the primary action, amber kept away (it is reserved for premium
   status and warnings), and hairline rules instead of heavy borders.
   ========================================================================== */

.sd-report-root {
    /* Light theme (default) — matches the paper surfaces of the website. */
    --sd-r-bg: #fefdf8;
    --sd-r-panel: #ffffff;
    --sd-r-text: #191b20;
    --sd-r-muted: #4b5058;
    --sd-r-faint: #868c97;
    --sd-r-border: #dcd9cd;
    --sd-r-border-strong: #c6c0ae;
    --sd-r-accent: #1a5bc4;
    --sd-r-accent-soft: rgba(26, 91, 196, .08);
    --sd-r-danger: #dc2b2b;
    --sd-r-danger-soft: rgba(220, 43, 43, .09);
    --sd-r-success: #14803b;
    --sd-r-success-soft: rgba(20, 128, 59, .09);
    --sd-r-shadow: 0 8px 18px rgba(25, 27, 32, .10), 0 30px 60px rgba(25, 27, 32, .14);
    --sd-r-radius: 14px;

    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(25, 27, 32, .55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease;
    font-family: inherit;
}

.sd-report-root.is-open {
    opacity: 1;
    visibility: visible;
}

/* The overlay toggles its member form / guest panel with the `hidden`
   attribute. Several of those elements carry an author `display` rule
   (`.sd-report-actions` is `display:flex`), and an author declaration beats
   the user-agent `[hidden] { display: none }` rule — so without this the
   attribute does nothing and both panels show at once. */
.sd-report-root [hidden] {
    display: none !important;
}

/* Dark theme — the game pages. */
.sd-report-root.sd-report-root--dark {
    --sd-r-bg: #0b1220;
    --sd-r-panel: #131f38;
    --sd-r-text: #f1f5f9;
    --sd-r-muted: #cbd5e1;
    --sd-r-faint: #94a3b8;
    --sd-r-border: rgba(148, 163, 184, .25);
    --sd-r-border-strong: rgba(148, 163, 184, .45);
    --sd-r-accent: #60a5fa;
    --sd-r-accent-soft: rgba(96, 165, 250, .12);
    --sd-r-danger: #f87171;
    --sd-r-danger-soft: rgba(248, 113, 113, .12);
    --sd-r-success: #4ade80;
    --sd-r-success-soft: rgba(74, 222, 128, .12);
    --sd-r-shadow: 0 20px 50px rgba(0, 0, 0, .55);
}

/* ---------------------------------------------------------------- dialog */

.sd-report-dialog {
    width: min(560px, 100%);
    max-height: min(88vh, 720px);
    display: flex;
    flex-direction: column;
    background: var(--sd-r-bg);
    color: var(--sd-r-text);
    border: 1px solid var(--sd-r-border);
    border-radius: var(--sd-r-radius);
    box-shadow: var(--sd-r-shadow);
    overflow: hidden;
    transform: translateY(10px) scale(.985);
    transition: transform .18s ease;
}

.sd-report-root.is-open .sd-report-dialog {
    transform: translateY(0) scale(1);
}

.sd-report-head {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: 1.15rem 1.25rem .9rem;
    border-bottom: 1px solid var(--sd-r-border);
}

.sd-report-title {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--sd-r-text);
    flex: 1;
}

.sd-report-sub {
    margin: .25rem 0 0;
    font-size: .8rem;
    line-height: 1.45;
    color: var(--sd-r-muted);
}

.sd-report-close {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--sd-r-muted);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.sd-report-close:hover,
.sd-report-close:focus-visible {
    background: var(--sd-r-accent-soft);
    border-color: var(--sd-r-border);
    color: var(--sd-r-text);
    outline: none;
}

.sd-report-body {
    padding: 1.1rem 1.25rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

/* The subject being reported — a snapshot, so it always reads. */
.sd-report-subject {
    display: flex;
    align-items: flex-start;
    gap: .55rem;
    padding: .7rem .85rem;
    margin-bottom: 1.05rem;
    background: var(--sd-r-accent-soft);
    border: 1px solid var(--sd-r-border);
    border-left: 3px solid var(--sd-r-accent);
    border-radius: 10px;
    font-size: .88rem;
    line-height: 1.45;
    color: var(--sd-r-text);
}

.sd-report-subject-icon {
    flex: 0 0 auto;
    margin-top: .1rem;
    color: var(--sd-r-accent);
    font-size: .95rem;
}

.sd-report-subject-text {
    min-width: 0;
    word-break: break-word;
}

/* --------------------------------------------------------------- reasons */

.sd-report-label {
    display: block;
    margin-bottom: .5rem;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--sd-r-faint);
}

.sd-report-reasons {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    margin: 0 0 1.05rem;
    padding: 0;
    border: 0;
}

.sd-report-reason {
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .6rem .75rem;
    border: 1px solid var(--sd-r-border);
    border-radius: 10px;
    background: var(--sd-r-panel);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.sd-report-reason:hover {
    border-color: var(--sd-r-border-strong);
}

.sd-report-reason input {
    flex: 0 0 auto;
    margin: .15rem 0 0;
    accent-color: var(--sd-r-accent);
}

.sd-report-reason-text {
    font-size: .9rem;
    line-height: 1.4;
    color: var(--sd-r-text);
}

.sd-report-reason.is-checked {
    border-color: var(--sd-r-accent);
    background: var(--sd-r-accent-soft);
}

/* --------------------------------------------------------------- textarea */

.sd-report-textarea {
    display: block;
    width: 100%;
    min-height: 96px;
    padding: .65rem .8rem;
    border: 1px solid var(--sd-r-border-strong);
    border-radius: 10px;
    background: var(--sd-r-panel);
    color: var(--sd-r-text);
    font-family: inherit;
    font-size: .9rem;
    line-height: 1.5;
    resize: vertical;
}

.sd-report-textarea::placeholder {
    color: var(--sd-r-faint);
}

.sd-report-textarea:focus {
    outline: none;
    border-color: var(--sd-r-accent);
    box-shadow: 0 0 0 3px var(--sd-r-accent-soft);
}

.sd-report-hint {
    margin: .4rem 0 0;
    font-size: .78rem;
    color: var(--sd-r-faint);
}

/* --------------------------------------------------------------- actions */

.sd-report-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    padding: .9rem 1.25rem 1.15rem;
    border-top: 1px solid var(--sd-r-border);
    flex-wrap: wrap;
}

.sd-report-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 42px;
    padding: .55rem 1.15rem;
    border: 1px solid var(--sd-r-border-strong);
    border-radius: 10px;
    background: var(--sd-r-panel);
    color: var(--sd-r-text);
    font-family: inherit;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.sd-report-btn:hover {
    border-color: var(--sd-r-accent);
}

.sd-report-btn--primary {
    background: var(--sd-r-accent);
    border-color: var(--sd-r-accent);
    color: #fff;
}

.sd-report-btn--primary:hover {
    background: var(--sd-r-accent);
    border-color: var(--sd-r-accent);
    opacity: .9;
}

.sd-report-btn:disabled,
.sd-report-btn.is-busy {
    opacity: .55;
    cursor: not-allowed;
}

/* --------------------------------------------------------------- feedback */

.sd-report-feedback {
    display: none;
    margin: 0 0 1rem;
    padding: .7rem .85rem;
    border-radius: 10px;
    font-size: .85rem;
    line-height: 1.45;
    border: 1px solid transparent;
}

.sd-report-feedback.is-visible {
    display: block;
}

.sd-report-feedback--error {
    background: var(--sd-r-danger-soft);
    border-color: var(--sd-r-danger);
    color: var(--sd-r-danger);
}

.sd-report-feedback--success {
    background: var(--sd-r-success-soft);
    border-color: var(--sd-r-success);
    color: var(--sd-r-success);
}

/* The guest prompt — a member cannot report without an account. */
.sd-report-guest,
.sd-report-guest-panel {
    text-align: center;
    padding: .4rem 0 .2rem;
}

.sd-report-guest-icon {
    font-size: 1.9rem;
    margin-bottom: .5rem;
}

.sd-report-guest-title {
    margin: 0 0 .5rem;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    color: var(--sd-r-text);
}

.sd-report-guest-text {
    margin: 0 0 1rem;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--sd-r-muted);
}

.sd-report-guest .sd-report-actions,
.sd-report-actions--guest {
    justify-content: center;
    border-top: 0;
    padding-top: .2rem;
}

/* ------------------------------------------------------- trigger buttons */

/* The flag the host page renders. It inherits the host's text colour so it
   reads on both the paper pages and the dark game pages. */
.sd-report-flag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .22rem .5rem;
    border: 1px solid currentColor;
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: .01em;
    cursor: pointer;
    opacity: .5;
    transition: opacity .18s, background .18s;
}

.sd-report-flag:hover,
.sd-report-flag:focus-visible {
    opacity: 1;
    background: rgba(127, 127, 127, .14);
    outline: none;
}

/* Icon-only variant for the game level cards. */
.sd-report-flag--icon {
    padding: .22rem .4rem;
    font-size: .85rem;
}

.sd-report-flag--corner {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 3;
}

@media (max-width: 575.98px) {
    .sd-report-root {
        padding: .6rem;
        align-items: flex-end;
    }

    .sd-report-dialog {
        max-height: 92vh;
    }

    .sd-report-actions .sd-report-btn {
        flex: 1 1 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sd-report-root,
    .sd-report-dialog {
        transition: none;
    }
}
