/* ================================================================================================
 *  MathCracker registration invitation -- inline card + modal
 *
 *  This is the single most important conversion surface on the site, and its job is NOT to sell.
 *  A student has just watched their problem get solved; the card appears where the remaining
 *  steps would have been and offers to keep going. Everything about the styling follows from
 *  that: it sits inside the solution flow rather than covering it, the free action is the only
 *  loud element, and the PRO line is deliberately quiet typography at the bottom.
 *
 *  Theme-aware via [data-theme="dark"] -- see .claude/commands/dark-theme-guide.md.
 * ============================================================================================= */

/* ------------------------------------------------------------------------------------------
 *  The "Answer:" label above the final answer a walled student keeps.
 *
 *  Carried alongside the site-wide `solution-class`, which supplies bold + the grey pill --
 *  but only on pages that load main.css or sccss.css. The dashboard loads NEITHER, so there
 *  the label would render as plain body text. This rule guarantees the weight on every
 *  surface; where `solution-class` also applies, the two agree and nothing conflicts.
 * --------------------------------------------------------------------------------------- */
.mc-pw-answer-label {
    font-weight: 700;
}

/* ------------------------------------------------------------------------------------------
 *  THE LOCK -- a locked CONTINUATION of the solution, not a card bolted underneath it.
 *
 *  This is the pattern every competitor converged on (Symbolab, Chegg, Course Hero,
 *  Photomath): the withheld work stays on the page as blurred shapes that fade out, with the
 *  invitation floating over it. It works because the student can SEE that the solution keeps
 *  going -- a detached box below a finished answer reads as an advert and gets ignored.
 *
 *  IMPORTANT -- the blurred rows are a SKELETON, not the real steps under a CSS blur.
 *  Competitors ship the real HTML and blur it, which means the steps are one devtools click
 *  away. The backend here deliberately never sends withheld steps (that was the whole point
 *  of the gate fix), so these are abstract placeholder bars sized from the real step count.
 *  Same visual pull, nothing to un-blur. Do not "improve" this by sending the real steps.
 * --------------------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------------------------
 *  PALETTE. Declared on BOTH roots because the modal is appended to <body>, NOT inside the
 *  lock -- so anything scoped to .mc-pw-lock alone is undefined once the modal opens. That is
 *  not theoretical: it rendered the modal's primary button with no background and white text,
 *  i.e. an invisible call to action. If you add a root, add it here too.
 * ----------------------------------------------------------------------------------------- */
.mc-pw-lock,
.mc-pw-overlay {
    --mc-pw-accent: #1a73e8;
    --mc-pw-accent-strong: #1557b0;
    --mc-pw-surface: #ffffff;
    --mc-pw-ink: #202124;
    --mc-pw-ink-soft: #5f6368;
    --mc-pw-line: #dadce0;
}

.mc-pw-lock {
    position: relative;
    margin: 0 0 22px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.55;
    color: var(--mc-pw-ink);
}

/* The ghosted continuation. Fades AND blurs downward so the eye is pulled to the gate. */
.mc-pw-lock__preview {
    padding: 2px 2px 0;

    /* MUST stay comfortably taller than .mc-pw-lock__gate's negative margin below, or the
       gate slides up over the whole block and the blur disappears entirely. That is not
       hypothetical -- it happened once the row floor was lowered to one row. */
    min-height: 140px;
    -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 20%, transparent 90%);
    mask-image: linear-gradient(to bottom, #000 0%, #000 20%, transparent 90%);
    pointer-events: none;
    user-select: none;
}

/* Kept short on purpose. The blur only has to SAY "the work continues here" -- the eye is
   meant to land on the gate, so extra ghost rows just push the button down the page. */
.mc-pw-ghost { margin-bottom: 14px; }
.mc-pw-ghost:nth-child(1) { filter: blur(2.5px); opacity: 0.52; }
.mc-pw-ghost:nth-child(2) { filter: blur(3.5px); opacity: 0.34; }
.mc-pw-ghost:nth-child(3) { filter: blur(4.5px); opacity: 0.20; }

.mc-pw-ghost span {
    display: block;
    height: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    background: linear-gradient(90deg, #c8ccd1 0%, #dfe3e8 100%);
}

/* Centred bar = the display-math line every step ends on. */
.mc-pw-ghost .mc-pw-ghost--math {
    height: 25px;
    width: 42%;
    margin: 11px auto 0;
    border-radius: 7px;
    background: linear-gradient(90deg, #d4d8dd 0%, #e7eaee 100%);
}

/* The invitation itself: floats OVER the fade, which is what ties the two together. */
.mc-pw-lock__gate {
    position: relative;
    margin-top: -72px;
    padding: 24px 28px 22px;
    border: 1px solid var(--mc-pw-line);
    border-radius: 14px;
    background: var(--mc-pw-surface);
    box-shadow: 0 2px 6px rgba(60, 64, 67, 0.10), 0 14px 34px rgba(60, 64, 67, 0.13);
    text-align: center;
}

/* Standalone card (no steps to ghost -- e.g. anonymous access switched off entirely). */
.mc-pw-lock--bare .mc-pw-lock__gate { margin-top: 0; }

.mc-pw-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(26, 115, 232, 0.10);
    color: var(--mc-pw-accent-strong, #1557b0);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.mc-pw-headline {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.mc-pw-body {
    margin: 0 auto 18px;
    max-width: 52ch;
    color: var(--mc-pw-ink-soft);
    font-size: 15px;
}

.mc-pw-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 20px;
}

/* The card's primary action carries the whole surface, so it is bigger than a stock button. */
.mc-pw-lock__gate .mc-pw-actions .mc-pw-btn {
    min-width: 240px;
    padding: 14px 32px;
    font-size: 16px;
}

.mc-pw-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: 0;
    border-radius: 10px;
    /* Literal fallbacks throughout: an undefined variable here means an INVISIBLE call to
       action (white text, no background), which is the worst possible failure on this
       surface. Degrade to a plain blue button instead. */
    background: var(--mc-pw-accent, #1a73e8);
    color: #fff;
    font: inherit;
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 1px 2px rgba(26, 115, 232, 0.35), 0 4px 12px rgba(26, 115, 232, 0.22);
}

.mc-pw-btn:hover  { background: var(--mc-pw-accent-strong, #1557b0); transform: translateY(-1px); color: #fff; }
.mc-pw-btn:active { transform: translateY(0); }

.mc-pw-btn--ghost {
    background: transparent;
    color: var(--mc-pw-accent);
    box-shadow: none;
    padding: 12px 14px;
}
.mc-pw-btn--ghost:hover { background: rgba(26, 115, 232, 0.08); color: var(--mc-pw-accent-strong); transform: none; }

/* The hook. Carries the number the whole offer rests on, so it gets weight and ink while
   the rest of the sentence stays soft -- the eye should catch it before reading the line. */
.mc-pw-hook {
    font-weight: 700;
    color: var(--mc-pw-ink, #202124);
}

/* Reassurance, NOT a second message. Deliberately small, muted and BELOW the button:
   beside it, a grey disclaimer competes with the call to action for the same glance. */
.mc-pw-fineprint {
    display: block;
    margin: 10px 0 0;
    color: var(--mc-pw-ink-soft, #5f6368);
    font-size: 12.5px;
    text-align: center;
}

/* The PRO line. Separated by a hairline so it reads as an aside, never as a second CTA. */
.mc-pw-pro {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--mc-pw-line);
    font-size: 13.5px;
    color: var(--mc-pw-ink-soft);
}
.mc-pw-pro a { color: var(--mc-pw-ink-soft); text-decoration: underline; text-underline-offset: 2px; }
.mc-pw-pro a:hover { color: var(--mc-pw-accent-strong); }

/* ------------------------------------------------------------------------------------------
 *  Modal. Registration happens HERE, over the solution, because navigating away loses the
 *  problem the student came with -- see the 'registration' block in includes/auth.php.
 * --------------------------------------------------------------------------------------- */

.mc-pw-overlay {
    position: fixed;
    inset: 0;
    z-index: 2147483000;              /* above MathLive's virtual keyboard and legacy headers */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(32, 33, 36, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    animation: mc-pw-fade 0.18s ease forwards;
}

@keyframes mc-pw-fade { to { opacity: 1; } }
@keyframes mc-pw-rise { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }

.mc-pw-modal {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    padding: 32px 30px 26px;
    border-radius: 18px;
    background: var(--mc-pw-surface, #fff);
    color: var(--mc-pw-ink, #202124);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.28);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    text-align: center;
    animation: mc-pw-rise 0.22s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.mc-pw-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #5f6368;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.mc-pw-close:hover { background: rgba(60, 64, 67, 0.09); }

.mc-pw-modal .mc-pw-headline { font-size: 22px; margin-bottom: 10px; }
.mc-pw-modal .mc-pw-body     { margin: 0 auto 22px; font-size: 14.5px; }

.mc-pw-providers { display: flex; flex-direction: column; gap: 10px; }

.mc-pw-provider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--mc-pw-line, #dadce0);
    border-radius: 10px;
    background: #fff;
    color: #3c4043;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.mc-pw-provider:hover { background: #f8f9fa; box-shadow: 0 1px 4px rgba(60, 64, 67, 0.14); }
.mc-pw-provider svg { width: 18px; height: 18px; flex: none; }

.mc-pw-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: var(--mc-pw-ink-soft, #5f6368);
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.mc-pw-divider::before,
.mc-pw-divider::after { content: ""; flex: 1; height: 1px; background: var(--mc-pw-line, #dadce0); }

.mc-pw-modal .mc-pw-btn { width: 100%; }

.mc-pw-footnote {
    margin-top: 18px;
    color: var(--mc-pw-ink-soft, #5f6368);
    font-size: 13px;
}
.mc-pw-footnote a { color: var(--mc-pw-accent, #1a73e8); text-decoration: none; font-weight: 600; }
.mc-pw-footnote a:hover { text-decoration: underline; }

/* Status line: shown while the popup is open, and again on success. */
.mc-pw-status {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 9px;
    margin-top: 18px;
    padding: 11px 14px;
    border-radius: 10px;
    background: rgba(26, 115, 232, 0.08);
    color: var(--mc-pw-accent-strong, #1557b0);
    font-size: 13.5px;
    text-align: left;
}
.mc-pw-status.is-visible { display: flex; }
.mc-pw-status.is-error   { background: rgba(217, 48, 37, 0.08); color: #c5221f; }
.mc-pw-status.is-success { background: rgba(52, 168, 83, 0.10); color: #188038; }

.mc-pw-spinner {
    width: 15px;
    height: 15px;
    flex: none;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: mc-pw-spin 0.7s linear infinite;
}
@keyframes mc-pw-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------------------------------
 *  Dark theme
 * --------------------------------------------------------------------------------------- */

[data-theme="dark"] .mc-pw-lock,
[data-theme="dark"] .mc-pw-overlay {
    --mc-pw-accent: #8ab4f8;
    --mc-pw-accent-strong: #aecbfa;
    --mc-pw-surface: #202124;
    --mc-pw-ink: #e8eaed;
    --mc-pw-ink-soft: #9aa0a6;
    --mc-pw-line: #3c4043;
}

[data-theme="dark"] .mc-pw-lock__gate {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45), 0 14px 34px rgba(0, 0, 0, 0.4);
}

/* Ghost bars must read as dim shapes on dark, not as glowing white blocks. */
[data-theme="dark"] .mc-pw-ghost span {
    background: linear-gradient(90deg, #3c4043 0%, #4a4d51 100%);
}
[data-theme="dark"] .mc-pw-ghost .mc-pw-ghost--math {
    background: linear-gradient(90deg, #43464a 0%, #52565b 100%);
}

[data-theme="dark"] .mc-pw-badge   { background: rgba(138, 180, 248, 0.16); color: var(--mc-pw-accent-strong); }
[data-theme="dark"] .mc-pw-btn     { background: var(--mc-pw-accent); color: #202124; box-shadow: none; }
[data-theme="dark"] .mc-pw-btn:hover { background: var(--mc-pw-accent-strong); color: #202124; }
[data-theme="dark"] .mc-pw-btn--ghost { background: transparent; color: var(--mc-pw-accent); }
[data-theme="dark"] .mc-pw-provider { background: #2d2e31; border-color: var(--mc-pw-line); color: var(--mc-pw-ink); }
[data-theme="dark"] .mc-pw-provider:hover { background: #35363a; }
[data-theme="dark"] .mc-pw-close   { color: var(--mc-pw-ink-soft); }
[data-theme="dark"] .mc-pw-close:hover { background: rgba(232, 234, 237, 0.12); }
[data-theme="dark"] .mc-pw-modal   { box-shadow: 0 12px 48px rgba(0, 0, 0, 0.65); }

/* ------------------------------------------------------------------------------------------
 *  Small screens -- the modal becomes a bottom sheet, which is the expected mobile pattern
 *  and keeps the primary button under the thumb.
 * --------------------------------------------------------------------------------------- */

@media (max-width: 560px) {
    .mc-pw-overlay { align-items: flex-end; padding: 0; }
    .mc-pw-modal {
        max-width: none;
        max-height: 92vh;
        border-radius: 18px 18px 0 0;
        padding: 28px 22px 22px;
    }
    @keyframes mc-pw-rise { from { opacity: 0; transform: translateY(100%); } to { opacity: 1; transform: none; } }
    .mc-pw-lock__gate { padding: 20px 18px 18px; border-radius: 12px; margin-top: -60px; }
    .mc-pw-headline { font-size: 18px; }
    .mc-pw-actions { gap: 10px; }
    .mc-pw-actions .mc-pw-btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .mc-pw-overlay, .mc-pw-modal { animation: none; opacity: 1; transform: none; }
    .mc-pw-spinner { animation-duration: 2s; }
}
