/**
 * User report ("Report issue") — cross-surface sheet, toast, and trigger pill (BEM)
 *
 * Block `.user-report` is shared by the reader overlay, the dedicated
 * /reader/ page, and (Phase 2) checkout. Reader chrome is dark, so the
 * trigger is tuned for a black ground; the sheet itself uses the light
 * component palette so it reads the same on every surface.
 */

/* ---- Trigger pill (flag icon + "Report") ---- */
.user-report__trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--color-gray-dark);
    border-radius: 10px;
    color: var(--color-white);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, border-color 0.2s;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.user-report__trigger:hover,
.user-report__trigger:focus-visible {
    opacity: 1;
    border-color: var(--color-gray-mid);
}

.user-report__trigger:focus-visible {
    outline: 2px solid var(--color-white);
    outline-offset: 2px;
}

/* Server renders the trigger hidden; the adapter reveals it once the core has
   registered (fail-soft is no button, never a dead one). */
.user-report__trigger[hidden] {
    display: none !important;
}

.user-report__icon {
    flex: 0 0 auto;
}

.user-report__trigger-label {
    font-family: "Maax Medium";
    font-weight: 400;
}

/* Series-page inline preview: light page ground, so invert the pill colours */
.series-inline-reader__report {
    color: var(--color-text);
    border-color: var(--color-line-2);
    flex: 0 0 auto;
    margin-bottom: 0.4rem;
}

.series-inline-reader__report:hover,
.series-inline-reader__report:focus-visible {
    border-color: var(--color-text);
}

.series-inline-reader__report:focus-visible {
    outline-color: var(--color-text);
}

/* Error-attached variant (checkout): a text-styled inline button inside the
   error message, coloured like the message itself */
.user-report__trigger--inline {
    display: inline;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-family: "Maax Medium";
    font-weight: 400;
    text-decoration: underline;
    opacity: 1;
    cursor: pointer;
}

.user-report__trigger--inline:hover,
.user-report__trigger--inline:focus-visible {
    border: none;
    text-decoration-thickness: 2px;
}

/* Overlay chrome placement: left of the close button */
.reader-overlay__report {
    position: absolute;
    top: 20px;
    right: 64px;
    z-index: 10;
}

/* ---- Sheet ---- */
.user-report {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 10000;
    display: flex;
    justify-content: center;
    padding: 0 12px 12px;
    pointer-events: none;
}

.user-report[hidden] {
    display: none !important;
}

.user-report__panel {
    pointer-events: auto;
    width: 100%;
    max-width: 440px;
    background: var(--color-background);
    color: var(--color-text);
    border: 1px solid var(--color-line);
    border-radius: 14px;
    box-shadow: var(--box-shadow-md);
    padding: 16px;
    font-size: 14px;
    line-height: 1.4;
}

.user-report__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.user-report__title {
    margin: 0;
    font-family: "Maax Medium";
    font-weight: 400;
    font-size: 16px;
}

.user-report__close {
    background: transparent;
    border: none;
    color: var(--color-text-2);
    cursor: pointer;
    padding: 4px;
    line-height: 0;
}

.user-report__close:hover,
.user-report__close:focus-visible {
    color: var(--color-text);
}

.user-report__hint {
    margin: 0 0 10px;
    color: var(--color-text-2);
    font-size: 13px;
}

.user-report__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
    padding: 0;
    list-style: none;
}

.user-report__chip {
    background: var(--color-background-2);
    color: var(--color-text);
    border: 1px solid var(--color-line);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.user-report__chip:hover,
.user-report__chip:focus-visible {
    border-color: var(--color-text);
}

.user-report__chip--selected {
    background: var(--color-text);
    color: var(--color-background);
    border-color: var(--color-text);
    font-family: "Maax Medium";
    font-weight: 400;
}

.user-report__text {
    width: 100%;
    min-height: 64px;
    max-height: 160px;
    resize: vertical;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--color-line);
    border-radius: 10px;
    background: var(--color-background);
    color: var(--color-text);
    font: inherit;
    font-size: 14px;
}

.user-report__text:focus-visible {
    outline: 2px solid var(--color-text);
    outline-offset: 1px;
}

.user-report__disclosure {
    margin: 10px 0 12px;
    color: var(--color-text-2);
    font-size: 12px;
}

.user-report__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.user-report__button {
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    cursor: pointer;
    border: 1px solid var(--color-line);
    background: var(--color-background);
    color: var(--color-text);
    font-family: "Maax Medium";
    font-weight: 400;
}

.user-report__button--primary {
    background: var(--color-text);
    color: var(--color-background);
    border-color: var(--color-text);
}

.user-report__button[disabled] {
    opacity: 0.5;
    cursor: default;
}

.user-report__status {
    margin: 0;
    min-height: 1.4em;
    color: var(--color-text-2);
    font-size: 13px;
}

.user-report__status--error {
    color: var(--color-red);
}

/* Confirmation */
.user-report__result {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-report__id-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.user-report__id {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 15px;
    letter-spacing: 0.04em;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--color-background-2);
    border: 1px solid var(--color-line);
    user-select: all;
}

/* ---- Auto-prompt toast (never steals focus) ---- */
.user-report__toast {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 24px);
    padding: 10px 12px 10px 16px;
    border-radius: 999px;
    background: var(--color-text);
    color: var(--color-background);
    border: 1px solid var(--color-gray-dark);
    box-shadow: var(--box-shadow-md);
    font-size: 14px;
}

.user-report__toast[hidden] {
    display: none !important;
}

.user-report__toast-action {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    text-decoration: underline;
    font: inherit;
    font-family: "Maax Medium";
    font-weight: 400;
    padding: 4px 6px;
}

.user-report__toast-dismiss {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    line-height: 0;
    opacity: 0.7;
}

.user-report__toast-dismiss:hover,
.user-report__toast-dismiss:focus-visible {
    opacity: 1;
}

@media (min-width: 640px) {
    .user-report {
        inset: auto 20px 20px auto;
        padding: 0;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .user-report__panel {
        animation: user-report-rise 0.18s ease-out;
    }
    @keyframes user-report-rise {
        from { transform: translateY(8px); opacity: 0; }
        to { transform: none; opacity: 1; }
    }
}
