/* ============================================================
   Floating "Report a problem" widget (_ReportWidget.cshtml).
   Rendered on every page, for everyone - signed in, guest, or
   nobody at all - so it carries its own tokens rather than
   leaning on the .qs scope, which is not present on the gate,
   the login page or the planning journey.
   ============================================================ */

.rp {
    --rp-ink: #0F1A14;
    --rp-ink-2: #4A5550;
    --rp-ink-3: #7B847F;
    --rp-brand: #1F3D2A;
    --rp-brand-hover: #122318;
    --rp-brand-soft: #E8EFE9;
    --rp-accent: #7CB342;
    --rp-gold: #B5895A;
    --rp-surface: #FFFFFF;
    --rp-surface-2: #F4F5F4;
    --rp-border: #E5E7E4;
    --rp-border-strong: #D1D5D0;
    --rp-danger: #B91C1C;
    --rp-danger-bg: #FEF2F2;
    --rp-success: #047857;
    --rp-success-bg: #ECFDF5;
    --rp-ease: cubic-bezier(0.16, 1, 0.3, 1);

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    color: var(--rp-ink);
}

.rp *, .rp *::before, .rp *::after { box-sizing: border-box; }

/* ---------- the button ---------- */

/* Bottom LEFT on purpose: the bottom right corner already belongs to Rory on the storefront and
   to the chat button on a quote, and a support button is not worth fighting them for it. */
.rp-fab {
    position: fixed;
    left: max(1rem, env(safe-area-inset-left));
    bottom: max(1rem, env(safe-area-inset-bottom));
    z-index: 120;

    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.95rem 0.55rem 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 999px;
    background: var(--rp-brand);
    color: #FBF6EC;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(9, 18, 12, 0.28), 0 1px 0 rgba(255, 255, 255, 0.12) inset;
    transition: transform 200ms var(--rp-ease), opacity 200ms var(--rp-ease), background 200ms var(--rp-ease), box-shadow 200ms var(--rp-ease);
}

.rp-fab:hover {
    background: var(--rp-brand-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(9, 18, 12, 0.34);
}

.rp-fab:focus-visible {
    outline: 2px solid var(--rp-accent);
    outline-offset: 3px;
}

.rp-fab-mark {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(251, 246, 236, 0.14);
    color: #F6EEDF;
    flex: none;
}

/* Pages that put the entry point in their own chrome (the planning journey) keep the panel and
   drop the button, so the scene is not covered. */
.rp-fab[hidden] { display: none; }

@media (max-width: 720px) {
    /* Room is tight and the dock/chat live along the bottom edge - shrink to the glyph alone. */
    .rp-fab { padding: 0.55rem; gap: 0; }
    .rp-fab-label { display: none; }

    /* Pages with the phone tab bar carry "Report a problem" in its sheet, so a floating button
       would only sit on top of the content and the bar. */
    body:has(.tn-tabs) .rp-fab { display: none; }

    /* Everywhere else it steps aside while the reader scrolls down through the page and comes
       back on the way up (report-widget.js), the way a phone browser treats its own toolbar. */
    .rp-fab.rp-fab-tucked {
        transform: translateX(calc(-100% - 1.5rem));
        opacity: 0;
        pointer-events: none;
    }
}

/* ---------- the panel ---------- */

.rp-modal {
    position: fixed;
    inset: 0;
    z-index: 240;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.rp-modal[hidden] { display: none; }

.rp-scrim {
    position: absolute;
    inset: 0;
    background: rgba(9, 18, 12, 0.5);
    backdrop-filter: blur(3px);
    animation: rp-fade 180ms var(--rp-ease);
}

.rp-panel {
    position: relative;
    width: min(540px, 100%);
    max-height: min(88vh, 780px);
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--rp-surface);
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(9, 18, 12, 0.42);
    overflow: hidden;
    animation: rp-rise 220ms var(--rp-ease);
}

/* The form is the part that gives: it takes the space left under the header and lets its own
   body scroll, which is what keeps the footer pinned inside the panel instead of hanging off
   the bottom of it on a short screen. min-height:0 is required - a flex child defaults to
   min-height:auto and refuses to shrink below its content. */
.rp-panel > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

@keyframes rp-fade { from { opacity: 0; } }
@keyframes rp-rise { from { opacity: 0; transform: translateY(14px) scale(0.985); } }
@keyframes rp-sheet { from { transform: translateY(100%); } }

/* Phones: the panel comes up from the bottom edge as a sheet, where the thumb already is,
   instead of floating in the middle of a small screen. */
@media (max-width: 560px) {
    .rp-modal {
        align-items: flex-end;
        padding: 0;
    }

    .rp-panel {
        width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        border-radius: 18px 18px 0 0;
        animation: rp-sheet 260ms var(--rp-ease);
    }

    .rp-close { width: 36px; height: 36px; }
    .rp-send { min-height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
    .rp-scrim, .rp-panel, .rp-fab { animation: none; transition: none; }
}

/* Header: a slim brand band, so the panel reads as part of Rooney's rather than a browser dialog. */
.rp-head {
    flex: none;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, var(--rp-brand) 0%, #16301F 100%);
    color: #FBF6EC;
}

.rp-head-mark {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(251, 246, 236, 0.13);
    color: #F6EEDF;
    flex: none;
}

.rp-head-text { flex: 1; min-width: 0; }

.rp-head-title {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.rp-head-sub {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    line-height: 1.45;
    color: rgba(251, 246, 236, 0.72);
}

.rp-close {
    flex: none;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 8px;
    background: rgba(251, 246, 236, 0.1);
    color: #FBF6EC;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 160ms var(--rp-ease);
}

.rp-close:hover { background: rgba(251, 246, 236, 0.22); }

.rp-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 1.05rem 1.1rem 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.rp-field { display: flex; flex-direction: column; gap: 0.35rem; }

.rp-label {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--rp-ink-3);
}

.rp-label span {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    color: var(--rp-ink-3);
}

.rp-input,
.rp-textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--rp-border-strong);
    border-radius: 10px;
    background: var(--rp-surface);
    color: var(--rp-ink);
    font: inherit;
    font-size: 0.875rem;
    transition: border-color 160ms var(--rp-ease), box-shadow 160ms var(--rp-ease);
}

.rp-textarea { resize: vertical; min-height: 92px; line-height: 1.55; }

.rp-input:focus,
.rp-textarea:focus {
    outline: none;
    border-color: var(--rp-brand);
    box-shadow: 0 0 0 3px var(--rp-brand-soft);
}

/* Contact block - anonymous reporters only. Optional, and said to be optional, because demanding
   an address is exactly what makes someone abandon the report. */
.rp-contact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    padding: 0.7rem;
    border: 1px dashed var(--rp-border-strong);
    border-radius: 12px;
    background: var(--rp-surface-2);
}

.rp-contact-note {
    grid-column: 1 / -1;
    margin: 0;
    font-size: 0.6875rem;
    line-height: 1.45;
    color: var(--rp-ink-3);
}

@media (max-width: 460px) {
    .rp-contact { grid-template-columns: 1fr; }
}

/* ---------- the screenshot toggle ---------- */

.rp-shot {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--rp-border);
    border-radius: 10px;
    background: var(--rp-surface-2);
    cursor: pointer;
    transition: border-color 160ms var(--rp-ease), background 160ms var(--rp-ease);
}

.rp-shot:hover { border-color: var(--rp-border-strong); }

.rp-shot:has(input:checked) {
    border-color: var(--rp-brand);
    background: var(--rp-brand-soft);
}

.rp-shot input {
    flex: none;
    width: 16px;
    height: 16px;
    margin: 0.1rem 0 0;
    accent-color: var(--rp-brand);
    cursor: pointer;
}

.rp-shot-text { min-width: 0; font-size: 0.6875rem; line-height: 1.45; color: var(--rp-ink-3); }
.rp-shot-text b { display: block; font-size: 0.8125rem; color: var(--rp-ink); margin-bottom: 0.1rem; }

/* ---------- foot ---------- */

.rp-foot {
    flex: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.1rem;
    padding-bottom: max(0.85rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--rp-border);
    background: var(--rp-surface-2);
}

.rp-send {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.6rem 1rem;
    border: 0;
    border-radius: 10px;
    background: var(--rp-brand);
    color: #FFF;
    font: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: background 160ms var(--rp-ease);
}

.rp-send:hover:not(:disabled) { background: var(--rp-brand-hover); }

/* On a narrow phone the button and the link cannot share a row without the button's label
   wrapping onto two lines, so they stack - send on top, where the thumb already is. */
@media (max-width: 420px) {
    .rp-foot { flex-direction: column-reverse; align-items: stretch; gap: 0.5rem; }
    .rp-mine { text-align: center; }
}
.rp-send:disabled { opacity: 0.6; cursor: progress; }

.rp-mine {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rp-ink-2);
    text-decoration: none;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    white-space: nowrap;
}

.rp-mine:hover { background: var(--rp-brand-soft); color: var(--rp-brand); }

.rp-error {
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid #FECACA;
    border-radius: 10px;
    background: var(--rp-danger-bg);
    color: var(--rp-danger);
    font-size: 0.78125rem;
    line-height: 1.45;
}

.rp-error[hidden] { display: none; }

/* ---------- the thank-you ---------- */

.rp-done {
    padding: 2rem 1.4rem 1.6rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.rp-done[hidden] { display: none; }

.rp-done-mark {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--rp-success-bg);
    color: var(--rp-success);
    margin-bottom: 0.25rem;
}

.rp-done h3 {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.rp-done p {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.55;
    color: var(--rp-ink-2);
    max-width: 34ch;
}

.rp-done-ref {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--rp-surface-2);
    border: 1px solid var(--rp-border);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--rp-ink-2);
    font-variant-numeric: tabular-nums;
}

.rp-done-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
}

.rp-done-actions a,
.rp-done-actions button {
    padding: 0.5rem 0.9rem;
    border-radius: 10px;
    border: 1px solid var(--rp-border-strong);
    background: var(--rp-surface);
    color: var(--rp-ink-2);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.rp-done-actions .rp-primary {
    background: var(--rp-brand);
    border-color: var(--rp-brand);
    color: #FFF;
}

.rp-done-actions a:hover { border-color: var(--rp-brand); }
.rp-done-actions .rp-primary:hover { background: var(--rp-brand-hover); }
