/*
 * "Help & feedback" (lib/feedback): the header and footer links and the form's dialog.
 * Only pages lib/feedback/page_entry adds them to load this, so with HKI_FEEDBACK off
 * nothing here applies anywhere.
 *
 * The dialog is a native <dialog> in the top layer, so opening it moves nothing on the
 * page. Colours come from tokens.css, so both themes follow the reader's choice.
 */

/* the header link: a quiet outlined pill after the nav; a row of the sheet below 72rem */
.site-help {
    margin-left: auto;
    padding: .4rem .7rem;
    border: 1px solid var(--header-field-border);
    border-radius: var(--radius-sm);
    color: var(--header-text);
    font-size: var(--fs-sm);
    white-space: nowrap;
    transition: background var(--speed) ease;
}

.site-help:hover {
    background: var(--header-control-bg);
}

.site-help:focus-visible {
    outline: 2px solid var(--header-text);
    outline-offset: 2px;
}

.site-menu .site-help + .theme-toggle {
    margin-left: 0;
}

/* the compact bar holds the search too: the link drops its border to save room */
.site-header[data-header-mode="compact"] .site-help {
    border-color: transparent;
    color: var(--header-muted);
}

.site-header[data-header-mode="compact"] .site-help:hover {
    color: var(--header-text);
}

/* in the sheet the menu button opens (header.css) */
@media (width < 72rem) {
    .site-help,
    .site-header[data-header-mode="compact"] .site-help {
        margin-left: 0;
        padding: .7rem .75rem;
        border-color: transparent;
        color: var(--header-muted);
        font-size: var(--fs-base);
    }
}

/* the footer link is an <a> styled as the footer's other link buttons (components.css) */
a.footer-link-button {
    color: var(--footer-text);
}


/* the dialog */

.help-dialog {
    box-sizing: border-box;
    width: min(30rem, calc(100% - 2rem));
    max-height: calc(100% - 2rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
    overflow: auto;
    overscroll-behavior: contain;
}

.help-dialog::backdrop {
    background: rgba(15, 18, 22, .5);
}

@media (prefers-reduced-motion: no-preference) {
    .help-dialog[open] {
        animation: help-in 160ms ease-out;
    }

    @keyframes help-in {
        from {
            opacity: 0;
            transform: translateY(.5rem);
        }
    }
}

.help-form,
.help-done {
    display: grid;
    /* minmax(0, 1fr): a long attached item shortens with an ellipsis instead of widening the form */
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
    padding: var(--space-5);
}

.help-done[hidden],
.help-form[hidden] {
    display: none;
}

.help-title {
    margin: 0;
    font-size: var(--fs-lg);
    line-height: 1.3;
}

.help-title:focus {
    outline: none;
}

.help-types {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .4rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.help-type {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 2.75rem;
    padding: .45rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font-size: var(--fs-sm);
    line-height: 1.25;
    cursor: pointer;
}

.help-type input {
    flex: none;
    margin: 0;
    accent-color: var(--brand);
}

.help-type:hover {
    background: var(--surface-hover);
}

/* the chosen type outlined in the brand red; without :has() the radio alone shows it */
@supports selector(:has(*)) {
    .help-type:has(input:checked) {
        border-color: var(--brand);
        box-shadow: inset 0 0 0 1px var(--brand);
        font-weight: 600;
    }

    .help-type:has(input:focus-visible) {
        outline: 2px solid var(--focus);
        outline-offset: 2px;
    }
}

.help-field {
    display: grid;
    gap: .3rem;
}

.help-field label,
.help-question legend {
    font-size: var(--fs-sm);
    font-weight: 600;
}

.help-field textarea,
.help-field input {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: var(--fs-md);
}

.help-field textarea {
    min-height: 6.5rem;
    resize: vertical;
}

.help-field textarea:focus-visible,
.help-field input:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 1px;
}

.help-field [aria-invalid="true"] {
    border-color: var(--brand);
}

.help-hint {
    margin: 0;
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

.help-count:empty {
    display: none;
}

.help-attached {
    display: grid;
    gap: .35rem;
    padding: .55rem .7rem;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    background: var(--bg);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}

.help-attached-label {
    margin: 0;
}

.help-attached-list {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.help-attached-list:empty {
    display: none;
}

.help-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
}

.help-chip-text {
    min-width: 0;
    padding: .2rem 0 .2rem .6rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.help-chip button {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 2rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.help-chip button:hover {
    color: var(--text);
}

.help-chip button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}

.help-chip svg {
    width: .9rem;
    height: .9rem;
    fill: currentColor;
}

/* Turnstile's widget is 65px tall; the room is kept so it appears without moving the form */
.help-turnstile {
    min-height: 65px;
}

.help-turnstile:empty::before {
    content: "Checking that you're a person…";
    display: block;
    padding-top: 1.4rem;
    color: var(--text-muted);
    font-size: var(--fs-xs);
}

.help-status {
    margin: 0;
    padding: .55rem .7rem;
    border-left: 3px solid var(--brand);
    border-radius: 0 6px 6px 0;
    background: var(--surface-2);
    font-size: var(--fs-sm);
}

.help-status a {
    color: inherit;
    text-decoration: underline;
}

.help-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}

.help-privacy {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    text-decoration: underline;
    text-underline-offset: var(--underline-offset);
}

.help-buttons {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.help-button {
    min-height: 2.75rem;
    padding: .55rem 1.1rem;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-size: var(--fs-md);
    font-weight: 700;
    cursor: pointer;
}

.help-button:hover {
    background: var(--accent-strong);
}

.help-button:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}

.help-button[disabled] {
    opacity: .6;
    cursor: progress;
}

.help-button-quiet,
.help-button-quiet:hover {
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
}

.help-done p {
    margin: 0;
}

.help-ref {
    display: inline-block;
    margin-left: .3rem;
    padding: .15rem .5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: var(--fs-md);
    font-weight: 600;
}

/* a problem report's screenshot (Phase 3) */
.help-shot[hidden],
.help-preview[hidden] {
    display: none;
}

/* a guest's invitation to sign in, in place of the screenshot field */
.help-shot-hint[hidden] {
    display: none;
}

.help-shot-hint a {
    color: inherit;
    text-decoration: underline;
}

.help-shot input[type="file"] {
    padding: .4rem;
    font-size: var(--fs-sm);
}

.help-preview {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.help-preview img {
    max-width: 8rem;
    max-height: 5rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    object-fit: contain;
    background: var(--bg);
}

/* a result dispute: "Is this your channel?" and the owners' hint */
.help-question {
    display: grid;
    gap: .3rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.help-question[hidden],
.help-owner-hint[hidden] {
    display: none;
}

.help-link-button {
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: var(--underline-offset);
    cursor: pointer;
}

.help-owner-hint a {
    color: inherit;
    text-decoration: underline;
}

/* under the score on a result (help_result.js) */
.help-dispute-line {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-sm);
}

.help-dispute-line a,
.help-error-report {
    color: var(--text-muted);
    text-decoration: underline;
    text-underline-offset: var(--underline-offset);
}

.help-dispute-line a:hover,
.help-error-report:hover {
    color: var(--text);
}

/* an error's reference, in the page's error message, the slow scan's panel and a toast */
.help-error-ref {
    margin: var(--space-2) 0 0;
    font-size: var(--fs-sm);
    color: var(--text-muted);
}

.help-error-code {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: .95em;
}

/* a phone: the dialog rises from the bottom edge, full width */
@media (width < 34rem) {
    .help-dialog {
        width: 100%;
        max-width: 100%;
        margin: auto 0 0;
        border-radius: 14px 14px 0 0;
        border-bottom: 0;
    }

    .help-form,
    .help-done {
        padding: var(--space-4);
    }
}

@supports (height: 100dvh) {
    .help-dialog {
        max-height: calc(100dvh - 2rem);
    }

    @media (width < 34rem) {
        .help-dialog {
            max-height: calc(100dvh - 1rem);
        }
    }
}
