/**
 * 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;
}

/* Reader surfaces (overlay + dedicated /reader/ page): the Omoi reader draws
   the page edge-to-edge under the theme chrome, so a bordered, labelled pill
   sat on top of the artwork. Collapse it to a quiet icon-only flag — no
   border, dimmer than the close/back controls, same 40px hit target — and
   keep the label for assistive tech only. */
.reader-overlay__report,
.reader-page__report {
    position: relative;
    gap: 0;
    padding: 8px;
    border-color: transparent;
    border-radius: 50%;
    opacity: 0.45;
    transition: opacity 0.2s, background-color 0.2s;
}

.reader-overlay__report .user-report__icon,
.reader-page__report .user-report__icon {
    width: 20px;
    height: 20px;
}

.reader-overlay__report .user-report__trigger-label,
.reader-page__report .user-report__trigger-label {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    white-space: nowrap;
}

.reader-overlay__report:hover,
.reader-overlay__report:focus-visible,
.reader-page__report:hover,
.reader-page__report:focus-visible {
    opacity: 1;
    border-color: transparent;
    background: var(--color-gray-dark);
}

/* Overlay chrome placement: left of the close button, vertically centred on
   its 24px glyph so the two controls sit on one line */
.reader-overlay__report {
    position: absolute;
    top: 18px;
    right: 60px;
    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;
    /* Details row + note + reload made the panel taller (v1.49.192); on a short
       phone with the keyboard up it must scroll rather than run off-screen. */
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.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;
}

/* Second-level answer ("What do you see?") under a category that asks one */
.user-report__details {
    margin: -4px 0 12px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--color-background-2);
}

.user-report__details[hidden] {
    display: none;
}

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

.user-report__chips--details {
    margin: 0;
}

.user-report__chip--detail {
    background: var(--color-background);
    font-size: 12px;
    padding: 6px 12px;
}

.user-report__chip--detail.user-report__chip--selected {
    background: var(--color-text);
}

.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;
}

/* Post-send follow-ups on the result screen: a note, and a reload with its outcome */
.user-report__followup {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--color-line);
}

.user-report__followup-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.user-report__text--note {
    flex: 1;
    margin: 0;
}

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

/* ---- 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; }
    }
}
