/* ───────────────────────────────────────────────────────────────────
 * Quota-economy UI (2026-04-29)
 *
 * Replaces the credits-balance display with a quota-aware UI for
 * users in the QUOTA_MODEL experiment. Until Phase 6 (D-day), this
 * stylesheet only takes effect when window._experimentFlags.quota_model
 * is true — JS adds `html.quota-mode` and the CSS scoped under it.
 *
 * Header changes:
 *   - The credits pill (#navCredits) is hidden
 *   - A single tier pill (#navTierPill) is shown — Free / Basic / Pro / Pro+
 *
 * Cost labels (Phase 3b+):
 *   - .regen-cost (the "15" badge on image buttons) is hidden
 *   - .regen-quota (a new sibling element) is shown with "used/cap"
 *
 * Everything outside `html.quota-mode` is untouched.
 * ───────────────────────────────────────────────────────────────── */

/* Hide credits pill in quota mode (header + everywhere it lives) */
html.quota-mode #navCredits {
    display: none !important;
}

/* Tier pill — one chip showing the user's current tier */
.nav-tier-pill {
    display: none;            /* default hidden; JS reveals when quota-mode active */
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.10);
    transition: filter 0.15s, transform 0.1s;
    user-select: none;
    white-space: nowrap;
}
.nav-tier-pill:hover { filter: brightness(1.15); }
.nav-tier-pill:active { transform: translateY(1px); }
html.quota-mode .nav-tier-pill {
    display: inline-flex;
}

/* Tier-specific styling */
.nav-tier-pill[data-tier="free"] {
    background: rgba(255, 255, 255, 0.04);
    color: rgba(195, 188, 215, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
}
.nav-tier-pill[data-tier="basic"] {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.18) 0%, rgba(167, 139, 250, 0.10) 100%);
    color: #c4b5fd;
    border-color: rgba(139, 92, 246, 0.40);
}
.nav-tier-pill[data-tier="pro"] {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.35) 0%, rgba(124, 58, 237, 0.20) 100%);
    color: #ddd6fe;
    border-color: rgba(167, 139, 250, 0.55);
    box-shadow: 0 2px 12px rgba(139, 92, 246, 0.20);
}
.nav-tier-pill[data-tier="proplus"] {
    background: linear-gradient(135deg, #a78bfa 0%, #ec4899 50%, #f59e0b 100%);
    color: #1a0e3a;
    border-color: rgba(255, 255, 255, 0.20);
    box-shadow: 0 4px 16px rgba(244, 114, 182, 0.35),
                inset 0 1px 0 rgba(255, 255, 255, 0.30);
    font-weight: 800;
}

.nav-tier-pill .tier-label {
    font-family: inherit;
}
.nav-tier-pill .tier-boost-mark {
    /* Small dot/ring shown on legacy-boosted users (former Basic/Pro
     * subscribers temporarily upgraded to Pro+ during migration). */
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fde68a;
    margin-left: 2px;
    box-shadow: 0 0 8px #fcd34d;
}

/* ── Cost label swap (Phase 3b) ─────────────────────────────────── */
/* The legacy `.regen-cost` shows credit cost ("15"). In quota mode
 * we hide it and surface `.regen-quota` instead. Both elements are
 * rendered inside the same button so CSS toggles which one is visible
 * — JS only needs to update content, not DOM structure. */
.regen-quota {
    display: none;
    font-family: var(--oi-mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
}
html.quota-mode .regen-cost {
    display: none !important;
}
/* Hard-suppress the legacy Pro+ "FREE" overlay (style.css uses
 * html.tier-unlimited .regen-cost::after { content: "FREE" }) when
 * quota mode is on — both classes can co-exist on Pro+ users and we
 * want the new ∞ in .regen-quota to win. */
html.quota-mode .regen-cost::before,
html.quota-mode .regen-cost::after {
    content: none !important;
    display: none !important;
}
html.quota-mode .regen-quota {
    display: inline;
}

/* Cost-badge — used by "See her right now" + narrator generate buttons
 * via creditCostLabel(). JS overrides text content to ∞ or used/cap;
 * the .free variant keeps its green styling so Pro+ visually still
 * stands out. No display rules needed (we only mutate text). */
html.quota-mode .cost-badge.free {
    /* keep existing green look — text already overwritten by JS */
}

/* nv2-cost / nv2-chip-bar-cost — narrator v2 inline cost spans.
 * JS already mutates text. Add a bit of font-numeric for tabular
 * alignment so "3/3" doesn't jitter as the digits change width. */
html.quota-mode .nv2-cost,
html.quota-mode .nv2-chip-bar-cost,
html.quota-mode .nv2-chip-capture-cost {
    font-variant-numeric: tabular-nums;
}

/* ── Hide credit-pack purchase paths in quota mode ──────────────────
 * Packs were retired with the credits→quota migration. Subscriptions
 * are the only paid path now. These selectors hide the pack-related
 * UI everywhere it was rendered (paywall modal, pricing page, chat
 * inline paywall). Keep the markup so non-quota-users still see
 * packs as before during the rollout window. */
html.quota-mode .paywall-buy-credits,
html.quota-mode .pack-card-row,
html.quota-mode .prx-packs,
html.quota-mode .prx-cost-row,
html.quota-mode .prx-pack-section,
html.quota-mode .pricing-credit-packs,
html.quota-mode .pw-pack-section,
html.quota-mode #creditPacksGrid,
html.quota-mode #creditPacks,
html.quota-mode .is-crypto-only,
html.quota-mode .legacy-credits-only {
    display: none !important;
}

/* Inverse: show quota-only sections only in quota mode. */
.quota-only { display: none; }
html.quota-mode .quota-only { display: block; }
html.quota-mode .quota-only.is-row { display: flex; }
html.quota-mode .quota-only.is-grid { display: grid; }

/* ── Achievement boost-choice modal (claim flow) ────────────────── */
.ach-boost-overlay {
    position: fixed;
    inset: 0;
    z-index: 9995;
    background: rgba(11, 10, 18, 0.78);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: oi-fade-in 0.2s ease-out;
}
.ach-boost-card {
    width: 100%;
    max-width: 380px;
    background: var(--oi-bg, #0b0a12);
    border: 1px solid var(--oi-violet-line, rgba(139, 92, 246, 0.35));
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5),
                inset 0 1px 0 rgba(255, 255, 255, 0.05);
    color: var(--oi-text, rgba(240, 235, 250, 0.96));
    font-family: var(--oi-font, "Inter", system-ui, sans-serif);
    text-align: center;
}
.ach-boost-title {
    font-family: var(--oi-display, "Fraunces", Georgia, serif);
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}
.ach-boost-subtitle {
    font-size: 13px;
    color: var(--oi-muted, rgba(195, 188, 215, 0.62));
    margin-bottom: 18px;
}
.ach-boost-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}
.ach-boost-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 16px 14px;
    border-radius: 12px;
    border: 1px solid var(--oi-hairline-hi, rgba(255, 255, 255, 0.10));
    background: rgba(255, 255, 255, 0.03);
    color: inherit;
    cursor: pointer;
    font-family: inherit;
    transition: filter 0.15s, transform 0.1s, border-color 0.15s;
}
.ach-boost-opt:hover {
    border-color: var(--oi-violet-line, rgba(139, 92, 246, 0.55));
    filter: brightness(1.1);
}
.ach-boost-opt:active { transform: translateY(1px); }
.ach-boost-opt-icon { font-size: 28px; line-height: 1; }
.ach-boost-opt-name {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--oi-text);
}
.ach-boost-opt-desc {
    font-size: 12px;
    color: var(--oi-text-soft, rgba(225, 218, 240, 0.88));
    line-height: 1.4;
}
.ach-boost-cancel {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--oi-hairline-hi);
    background: transparent;
    color: var(--oi-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
}
.ach-boost-cancel:hover {
    color: var(--oi-text);
}

/* ── Quota-migration welcome modal ──────────────────────────────── */
.qm-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9996;
    background: rgba(11, 10, 18, 0.82);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: oi-fade-in 0.25s ease-out;
}
.qm-modal-overlay.qm-closing { animation: oi-fade-out 0.2s ease-in forwards; }
.qm-modal-card {
    width: 100%;
    max-width: 420px;
    background: var(--oi-bg, #0b0a12);
    border: 1px solid var(--oi-violet-line, rgba(139, 92, 246, 0.40));
    border-radius: 20px;
    padding: 28px 24px 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55),
                0 0 60px rgba(139, 92, 246, 0.15),
                inset 0 1px 0 rgba(255, 255, 255, 0.06);
    color: var(--oi-text, rgba(240, 235, 250, 0.96));
    font-family: var(--oi-font, "Inter", system-ui, sans-serif);
}
.qm-modal-eyebrow {
    font-size: 11px;
    color: var(--oi-violet-hi, #a78bfa);
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.qm-modal-title {
    font-family: var(--oi-display, "Fraunces", Georgia, serif);
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.4px;
    line-height: 1.2;
    margin: 0 0 14px 0;
    color: var(--oi-text);
}
.qm-modal-body {
    font-size: 14px;
    line-height: 1.55;
    color: var(--oi-text-soft, rgba(225, 218, 240, 0.88));
    margin-bottom: 20px;
}
.qm-modal-body p { margin: 0 0 10px 0; }
.qm-modal-body p:last-child { margin-bottom: 0; }
.qm-modal-body b { color: var(--oi-text); font-weight: 600; }
.qm-modal-body ul { margin: 10px 0; padding-left: 20px; }
.qm-modal-body li { margin: 4px 0; }
.qm-modal-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #a78bfa 0%, #8b5cf6 55%, #7c3aed 100%);
    color: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.2px;
    font-family: inherit;
    box-shadow: 0 8px 22px rgba(139, 92, 246, 0.40),
                inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.qm-modal-cta:hover { filter: brightness(1.08); }
.qm-modal-cta:active { transform: translateY(1px); }

/* Lock body scroll while modal is open */
body.oi-modal-open {
    overflow: hidden;
    touch-action: none;
}
