/**
 * QR invites — /join landing, /app download page, and the host-side QR modal.
 *
 * Three surfaces, one file, because they share a vocabulary and all three are
 * read on a phone held at arm's length in a room that is dimmer than a design
 * review. Type is bigger than the site default throughout, on purpose.
 *
 * The QR itself sits on a real white tile — a code needs true black on true
 * white to scan. Only the tile, though. Everything around it stays on the
 * neumorphic dark theme, same as the rest of the site.
 */

/* ==========================================================================
   Shared page shell — /join and /app
   ========================================================================== */

.mf-join-page,
.mf-app-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem 4rem;
}

.mf-join-card,
.mf-app-card {
    width: 100%;
    max-width: 32rem;
    padding: 2rem 1.75rem 2.25rem;
    border-radius: 1rem;
    background: #1f2937;
    text-align: center;
}

/* ==========================================================================
   /join/{code}
   ========================================================================== */

.mf-join-kicker {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
}

.mf-join-title {
    margin: 0 0 0.5rem;
    font-size: 1.9rem;
    line-height: 1.2;
    color: #e5e7eb;
}

.mf-join-when {
    margin: 0 0 1.25rem;
    font-size: 1.05rem;
    color: #fb923c;
}

/* A night with no schedule set yet. Quieter than a real date — it is not
   information, it is the absence of it — but it still holds the line, so a
   game-night invite never silently loses its "when" row and read as a guild
   invite. */
.mf-join-when-tbd {
    color: #9ca3af;
    font-style: italic;
}

.mf-join-body {
    margin: 0 0 1.5rem;
    font-size: 1.02rem;
    line-height: 1.6;
    color: #9ca3af;
}

.mf-join-facts {
    list-style: none;
    margin: 1.25rem 0 1.5rem;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.mf-join-facts li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
}

.mf-join-fact-label {
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #6b7280;
}

.mf-join-fact-value {
    font-size: 1rem;
    color: #e5e7eb;
    text-align: right;
}

/* The one thing on the page a thumb has to find. */
.mf-join-cta,
.mf-app-btn {
    display: block;
    width: 100%;
    min-height: 3.25rem;
    margin-top: 0.5rem;
    font-size: 1.05rem;
}

.mf-join-cta[disabled] {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

.mf-join-sub {
    margin: 1rem 0 0;
    font-size: 0.95rem;
    color: #9ca3af;
}

.mf-join-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: #fb923c;
    text-decoration: underline;
    cursor: pointer;
}

/* "Open in the app" sits below the primary CTA and reads as secondary: someone
   without the app installed must not mistake it for the way in. */
.mf-join-app {
    margin: 0.85rem 0 0;
    font-size: 0.95rem;
}

.mf-join-app-open {
    display: inline-block;
    /* A tap target on a phone in a dim room. 44px is Apple's own floor and the
       underlined-text default is nowhere near it. */
    min-height: 44px;
    line-height: 44px;
}

.mf-join-messages:empty {
    display: none;
}

.mf-join-message {
    margin: 0 0 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.98rem;
    line-height: 1.5;
    text-align: left;
}

.mf-join-message--info {
    background: rgba(59, 130, 246, 0.12);
    color: #bfdbfe;
}

.mf-join-message--success {
    background: rgba(16, 185, 129, 0.14);
    color: #a7f3d0;
}

.mf-join-message--error {
    background: rgba(239, 68, 68, 0.14);
    color: #fecaca;
}

/* ==========================================================================
   /app
   ========================================================================== */

.mf-app-title {
    margin: 0 0 0.5rem;
    font-size: 1.8rem;
    line-height: 1.2;
    color: #e5e7eb;
}

.mf-app-tagline {
    margin: 0 0 1.75rem;
    font-size: 1.02rem;
    line-height: 1.55;
    color: #9ca3af;
}

.mf-app-actions {
    display: grid;
    gap: 0.75rem;
}

/* The platform we sniffed gets the accent; the others stay available but quiet.
   A wrong guess costs a glance, never a dead end. */
.mf-app-btn--primary {
    outline: 2px solid #fb923c;
    outline-offset: 2px;
}

.mf-app-note {
    margin: 0.25rem 0;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.95rem;
    line-height: 1.55;
    color: #9ca3af;
    text-align: left;
}

.mf-app-qr-block {
    margin-top: 2rem;
    padding-top: 1.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.mf-app-qr-label {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
}

.mf-app-qr {
    width: 12rem;
    max-width: 100%;
    margin: 0 auto;
    padding: 0.5rem;
    border-radius: 0.5rem;
    background: #ffffff;
}

.mf-app-qr svg {
    display: block;
    width: 100%;
    height: auto;
}

/* The URL is one unbreakable token. Without a wrapping rule it runs past its
   container on any phone and takes the whole document's scrollWidth with it —
   the print rule below and .mf-qr-modal__url both already break it, and this is
   the third place the same string is shown. */
.mf-app-qr-url {
    margin: 0.75rem 0 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.95rem;
    color: #e5e7eb;
    word-break: break-all;
    user-select: all;
}

.mf-app-qr-hint {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: #6b7280;
}

/* ==========================================================================
   Host-side entry point — the "Invite by QR" button on the guild dashboard
   ========================================================================== */

.gd-invite-wrap {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.gd-invite-hint {
    font-size: 0.9rem;
    color: #9ca3af;
}

/* ==========================================================================
   Host-side QR modal
   ========================================================================== */

.mf-qr-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;              /* matches .signin-modal, which is the neighbor
                                    that actually has to be cleared */
    display: none;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 1.5rem 1rem 3rem;
    background: rgba(0, 0, 0, 0.72);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.mf-qr-modal__sheet {
    position: relative;
    width: 100%;
    max-width: 26rem;
    padding: 2.5rem 1.5rem 2rem;
    border-radius: 1.25rem;
    background: var(--color-bg-primary, #1f2937);
    box-shadow:
        8px 8px 24px rgba(0, 0, 0, 0.45),
        -8px -8px 24px rgba(255, 255, 255, 0.06);
    text-align: center;
    color: var(--color-text-primary, #e5e7eb);
}

.mf-qr-modal__close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: var(--color-surface-primary, rgba(255, 255, 255, 0.05));
    color: var(--color-text-secondary, #9ca3af);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mf-qr-modal__close:hover {
    background: var(--color-surface-secondary, rgba(255, 255, 255, 0.1));
    color: var(--color-text-primary, #e5e7eb);
}

.mf-qr-modal__title {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    line-height: 1.2;
    color: var(--color-text-primary, #e5e7eb);
}

.mf-qr-modal__subtitle {
    margin: 0 0 1.5rem;
    font-size: 1.05rem;
    color: var(--color-accent-orange-light, #fb923c);
}

/* The one place the dark theme gives way. A QR needs true black on true white,
   and the white margin around it — the quiet zone — is the single
   highest-leverage thing for a scan that has to work first try. So the tile is
   white and generously padded, and it reads as a physical card held up over the
   dark sheet rather than the whole screen going blank. */
.mf-qr-modal__code {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(17rem, 74vw);
    min-height: min(17rem, 74vw);
    margin: 0 auto;
    padding: 0.75rem;
    border-radius: 0.75rem;
    background: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.mf-qr-modal__code svg {
    display: block;
    width: 100%;
    height: auto;
}

.mf-qr-modal__spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(17, 24, 39, 0.15);
    border-top-color: #111827;
    border-radius: 50%;
    animation: mf-qr-spin 0.8s linear infinite;
}

@keyframes mf-qr-spin {
    to { transform: rotate(360deg); }
}

/* Selectable on purpose, and never hidden behind a disclosure — this is the
   fallback for every camera that refuses to focus. The pill is what makes it
   read as something to be copied rather than a caption under the picture. */
.mf-qr-modal__url {
    display: inline-block;
    max-width: 100%;
    margin: 1.25rem 0 0.4rem;
    padding: 0.5rem 0.85rem;
    border-radius: 0.5rem;
    background: var(--color-surface-primary, rgba(255, 255, 255, 0.05));
    font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--color-text-primary, #e5e7eb);
    word-break: break-all;
    user-select: all;
    -webkit-user-select: all;
}

/* Secondary, not tertiary: this line is the escape hatch for a code that will
   not scan ("type that address in"), so it is read in exactly the conditions
   that make text hard to read. Tertiary (#6b7280) measures 3.04:1 on the sheet
   and fails AA's 4.5:1 for normal text; secondary measures 5.78:1. */
.mf-qr-modal__hint {
    margin: 0 0 1.5rem;
    font-size: 0.9rem;
    color: var(--color-text-secondary, #9ca3af);
}

/* Segmented switch: which code the panel is showing. Sized to the 2.75rem
   minimum the tools below use — this gets pressed on a phone, one-handed, in a
   dim room, often by someone who is also holding a drink. */
.mf-qr-modal__switch {
    display: inline-flex;
    gap: 0.25rem;
    margin: 0 auto 1.25rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: var(--color-surface-primary, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--color-border-primary, rgba(255, 255, 255, 0.1));
}

.mf-qr-modal__seg {
    min-height: 2.5rem;
    padding: 0.5rem 1.1rem;
    border: none;
    border-radius: 999px;
    background: none;
    color: var(--color-text-secondary, #9ca3af);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mf-qr-modal__seg:hover {
    color: var(--color-text-primary, #e5e7eb);
}

/* The selected segment carries a filled pill AND the brand orange, not colour
   alone — the switch decides which code a guest is about to scan, so which one
   is live has to survive being read on a dim screen at an angle. */
/* The light orange, not the base one. The pill fill lightens the background it
   sits on (rgba(249,115,22,0.15) over the track resolves to rgb(73,61,59)), so
   the base orange lands at 3.72:1 there — below AA, and 600 weight at 15.2px is
   short of the large-text exemption. The light token reads 4.61:1 on the same
   fill. The selected state should not be the harder one to read. */
.mf-qr-modal__seg[aria-pressed="true"] {
    background: rgba(249, 115, 22, 0.15);
    color: var(--color-accent-orange-light, #fb923c);
    font-weight: 600;
}

.mf-qr-modal__error {
    display: none;
    margin: 0 0 1rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-warning-border, rgba(245, 158, 11, 0.3));
    background: var(--color-warning-bg, rgba(245, 158, 11, 0.1));
    color: var(--color-warning-light, #fbbf24);
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: left;
}

.mf-qr-modal__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.mf-qr-modal__tool {
    min-height: 2.75rem;
    padding: 0.65rem 1.15rem;
    border: 1px solid var(--color-border-secondary, rgba(255, 255, 255, 0.2));
    border-radius: 0.5rem;
    background: var(--color-surface-primary, rgba(255, 255, 255, 0.05));
    color: var(--color-text-primary, #e5e7eb);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.mf-qr-modal__tool:hover {
    background: var(--color-surface-secondary, rgba(255, 255, 255, 0.1));
    border-color: var(--color-border-tertiary, rgba(255, 255, 255, 0.3));
}

/* Brand orange, not amber and not red. Rotating the code is a deliberate act but
   it is not an error state, and the amber this used to wear read as a warning the
   theme never intended — orange is the accent colour every other CTA on the site
   uses. It stays distinguishable from the neutral tools next to it by carrying a
   coloured border and label while they stay grey, so the difference survives for
   anyone who cannot separate the two hues. */
.mf-qr-modal__tool--danger {
    border-color: rgba(249, 115, 22, 0.35);
    color: var(--color-accent-orange, #f97316);
}

.mf-qr-modal__tool--danger:hover {
    background: rgba(249, 115, 22, 0.1);
    border-color: var(--color-accent-orange, #f97316);
    color: var(--color-accent-orange-hover, #fb923c);
}

/* "New code" while its own request is still out. aria-disabled rather than the
   disabled attribute because the button holds focus at that moment and disabling
   the focused element drops focus to <body>, outside an aria-hidden background —
   so this is the only signal the state has, and without it the button would look
   pressable while silently refusing presses. Scoped to aria-disabled alone: the
   [disabled] Copy button is styled by whatever it is styled by today, and this
   bounce is not the place to change how that looks. */
.mf-qr-modal__tool[aria-disabled="true"] {
    opacity: 0.55;
    cursor: default;
}

.mf-qr-modal__confirm {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid rgba(249, 115, 22, 0.35);
    border-radius: 0.5rem;
    background: rgba(249, 115, 22, 0.1);
}

.mf-qr-modal__confirm-text {
    margin: 0 0 0.85rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--color-accent-orange-light, #fb923c);
    text-align: left;
}

.mf-qr-modal__confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.mf-qr-modal__joins {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border-primary, rgba(255, 255, 255, 0.1));
    text-align: left;
}

.mf-qr-modal__joins:empty {
    display: none;
}

.mf-qr-modal__joins-title {
    margin: 0 0 0.5rem;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-text-tertiary, #6b7280);
}

.mf-qr-modal__joins-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mf-qr-modal__joins-list li {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border-primary, rgba(255, 255, 255, 0.1));
    font-size: 0.98rem;
    color: var(--color-text-primary, #e5e7eb);
}

.mf-qr-modal__joins-list li:last-child {
    border-bottom: none;
}

.mf-qr-modal__join-name {
    flex: 1 1 auto;
}

.mf-qr-modal__join-tag {
    flex: 0 0 auto;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: rgba(249, 115, 22, 0.12);
    color: var(--color-accent-orange-light, #fb923c);
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.mf-qr-modal__join-when {
    flex: 0 0 auto;
    color: var(--color-text-tertiary, #6b7280);
    font-size: 0.85rem;
}

.mf-qr-modal__joins-empty,
.mf-qr-modal__joins-more {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
    color: var(--color-text-tertiary, #6b7280);
}

@media (prefers-reduced-motion: reduce) {
    .mf-qr-modal__spinner {
        animation-duration: 2.4s;
    }
}

/* ==========================================================================
   Print — /app is meant to come off a printer
   ==========================================================================

   The page's own copy says "Print it, stick it on the table," and the rotate
   confirmation in InviteQRModal.js says "Every QR you have already shown or
   printed…". Printing is a designed use here, not an edge case, and until now
   there was not a single @media print rule on the page.

   What that produced: `.mf-app-title` and `.mf-app-qr-url` are near-white
   (#e5e7eb) and the only thing behind them is a dark BACKGROUND-COLOR on
   `.mf-app-card`/`body`. Browsers omit background colours from print output
   unless the reader ticks "Background graphics", so the paper came out with
   near-white text on white — about 1.2:1 — i.e. a bare unlabelled QR with no
   title saying what it is and no readable URL to type when a camera fails,
   which is exactly the fallback the caption exists to provide.

   So the rule here is: never rely on a background to create contrast on paper.
   Set the ink dark explicitly, and keep the QR at a size a phone can actually
   resolve from across a table. */
@media print {

    /* Site chrome is noise on a printed sheet, and the feedback widget is a
       floating control that would land on top of the QR. */
    .header,
    .footer,
    .feedback-fab,
    .feedback-panel,
    .feedback-backdrop {
        display: none !important;
    }

    /* Dark theme off. Every colour below is stated rather than inherited,
       because what is inherited here is white-on-dark. */
    .mf-app-page,
    .mf-app-card {
        margin: 0;
        padding: 0;
        border: 0;
        border-radius: 0;
        background: none !important;
        box-shadow: none !important;
        color: #000;
    }

    .mf-app-title {
        color: #000;
        font-size: 20pt;
    }

    .mf-app-tagline,
    .mf-app-note,
    .mf-app-qr-hint {
        color: #333;
    }

    .mf-app-qr-label {
        color: #333;
    }

    /* The typed-URL fallback is the whole point of printing this: it is what a
       reader uses when the camera will not focus. It gets full-strength ink. */
    .mf-app-qr-url {
        color: #000;
        font-size: 12pt;
        word-break: break-all;
    }

    /* Sized in inches, not rem — on paper the only thing that matters is how
       big it physically is. 2.5in of QR scans from across a table. `exact`
       keeps the modules from being treated as a droppable background. */
    .mf-app-qr {
        width: 2.5in;
        padding: 0;
        background: #fff;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* Nothing is more useless than a QR split across two sheets. */
    .mf-app-qr-block {
        margin-top: 0.4in;
        padding-top: 0.25in;
        border-top: 1px solid #999;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Store buttons are dead links on paper, but they still say which stores
       the app is in, so they stay — just without the screen accent. */
    .mf-app-btn {
        color: #000;
        border: 1px solid #999;
        background: none !important;
        box-shadow: none !important;
    }

    .mf-app-btn--primary {
        outline: 1px solid #000;
    }
}
