/* Owner: package P3 (Commerce, beta and social modals). Clockface Online rebrand overrides, linked last in the index.php head.
   Covers: upgrade modal + pricing tabs + rewarded-ad offer, reward granted, downsell, Welcome Plus, beta welcome and gates,
   academic + Back to School + academic checkout, coffee, Join Club, the user profile card and the Friends hub.
   Colours come only from tokens, so one rule set serves light and dark. */

/* ---------- Shared modal pieces ---------- */

/* Status icon on a 12% tint circle (replaces the big glowing icons). */
.upg-status-icon {
    display: inline-grid;
    place-items: center;
    align-self: center;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    border-radius: var(--radius-pill);
    font-size: 30px;
    line-height: 1;
}
.upg-status-gold { background: var(--gold-tint); color: var(--gold-ink); }
.upg-status-primary { background: var(--primary-tint); color: var(--primary-ink); }

/* Badges sit centred in the column-flex modal and the grid gate panels instead of stretching. */
.p3-badge-centre { align-self: center; justify-self: center; }

/* Long CTA labels wrap on phones instead of overflowing the pill. */
#upgradeModal .cfo-btn-block,
#rewardGrantedModal .cfo-btn-block,
#downsellModal .cfo-btn-block,
#betaWelcomeModal .cfo-btn-block,
#academicModal .cfo-btn-block,
#welcomePlusModal .cfo-btn-block,
#coffeeModal .cfo-btn-block,
#joinClubModal .cfo-btn-block,
#academicCheckoutModal .cfo-btn-block,
.beta-gate-panel .cfo-btn-block {
    height: auto;
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
    white-space: normal;
    text-align: center;
}
.upg-cta.cfo-btn { min-height: 52px; font-size: 16px; }

.p3-small-link { font-size: 13px; }
.p3-quiet-link { color: var(--text-secondary); font-weight: 500; }

/* Currency pickers: TextField look at a 44px target. */
.upg-currency-select {
    height: 44px;
    padding: 0 8px;
    border: 1px solid var(--border-control);
    border-radius: var(--radius-md);
    background-color: var(--surface-subtle);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease);
}
.upg-currency-select:hover { border-color: var(--text-secondary); }

/* ---------- Upgrade modal ---------- */

/* Pricing tabs: SegmentedTabs that wrap, because there are five plans. */
.upg-toggle-bg.cfo-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-1);
    width: 100%;
    padding: var(--space-1);
    border: 0;
    border-radius: var(--radius-lg);
    background: var(--surface-subtle);
}
.upg-toggle-bg .cfo-tab { flex: 1 1 auto; gap: 6px; }
.upg-toggle-bg .cfo-tab.active,
.aca-tabs .cfo-tab.active { background: var(--accent); color: var(--on-primary); font-weight: 600; box-shadow: var(--shadow-sm); }
.aca-tabs.cfo-tabs { width: 100%; }

.upg-price,
#pricingDisplay,
#acaPricingDisplay {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 5px;
    margin-bottom: 20px;
    font-size: 32px;
    line-height: 40px;
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.upg-price .upg-price-sub { font-size: 14px; line-height: 20px; font-weight: 500; color: var(--text-secondary); }

/* Feature rows; the trigger feature gets a tint (class set by openUpgradeModal / openJoinClubModal). */
.upg-feature {
    margin: 0 0 4px -8px;
    padding: 6px 8px;
    font-size: 14px;
    line-height: 1.45;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: background-color var(--dur-base) var(--ease), box-shadow var(--dur-base) var(--ease);
}
.upg-feature:last-child { margin-bottom: 0; }
.upg-feature > i,
.upg-feature > svg { color: var(--primary-ink); margin-right: 10px; width: 16px; text-align: center; }
.upg-feature strong { color: var(--text-primary); font-weight: 600; }
.upg-feature.is-highlighted { background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--gold-line); }
#joinClubModal .upg-feature.is-highlighted { background: var(--primary-tint); box-shadow: inset 0 0 0 1px var(--primary-line); }

/* Testimonials: a quiet well. The rotation (testi-N opacity) stays inline. */
.upg-testimonials { background: var(--surface-subtle); border: 0; border-radius: var(--radius-lg); }
.upg-testi-stars { color: var(--gold-ink); font-size: 12px; margin-bottom: 5px; }
.upg-testi-quote { margin: 0; font-size: 13px; line-height: 1.4; font-style: italic; color: var(--text-secondary); }
.upg-testi-quote strong { font-style: normal; font-size: 11px; font-weight: 600; color: var(--text-primary); }

.upg-fineprint { font-size: 12px; line-height: 16px; color: var(--text-tertiary); }
.upg-divider { border-top: 1px solid var(--border); }
.upg-academic-link.cfo-btn { font-size: 14px; }

/* Trust box and payment marks. */
.upg-trust-box { background: var(--surface-subtle); border: 0; border-radius: var(--radius-md); color: var(--text-tertiary); }
.upg-trust-box p { font-size: 12px; color: var(--text-tertiary); }
.upg-trust-box strong { color: var(--text-secondary); font-weight: 600; }
.upg-pay-icons { color: var(--text-tertiary); }

/* Rewarded-ad offer (markup from updateRewardedAdBar): a secondary button above an "or" divider. */
.reward-ad-btn.cfo-btn { height: auto; min-height: 52px; padding: 8px 18px; gap: 10px; white-space: normal; }
.reward-ad-btn > i,
.reward-ad-btn > svg { font-size: 20px; color: var(--accent-ink); flex-shrink: 0; }
.reward-ad-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.35; text-align: left; }
.reward-ad-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.reward-ad-sub { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.reward-ad-or {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 0;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.reward-ad-or span { flex: 1; height: 1px; background: var(--border); }

/* ---------- Academic, Back to School and academic checkout ---------- */
#academicModal .custom-input { font-size: 14px; }
.aca-code-input.custom-input { font-size: 20px; letter-spacing: 5px; font-weight: 700; }
.aca-file-input.custom-input { font-size: 12px; color: var(--text-secondary); }
#acaMessage { font-size: 13px; font-weight: 600; text-align: left; }

/* ---------- Coffee ---------- */
.coffee-amounts .coffee-amt-btn.cfo-chip {
    flex: 1;
    justify-content: center;
    height: 48px;
    padding: 0 var(--space-2);
    border-radius: var(--radius-lg);
    gap: 0;
    font-size: 18px;
    font-weight: 700;
}
.coffee-custom-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.coffee-sym-prefix { color: var(--text-primary); font-weight: 700; font-size: 14px; pointer-events: none; }
.coffee-custom-input.custom-input { flex-grow: 0; font-weight: 700; }

/* ---------- Beta welcome and gates ---------- */
.beta-welcome-box.cfo-card { gap: var(--space-2); }
.beta-gate-panel.cfo-modal { padding: var(--space-8) var(--space-6) var(--space-6); }
.beta-terms-box.cfo-card { display: block; }
.beta-terms-box h3 { font-size: 14px; line-height: 20px; font-weight: 700; color: var(--ink); }
.beta-terms-box p { margin: 0; font-size: 13px; line-height: 1.6; color: var(--text-secondary); }

/* ---------- User profile card (#userProfileModal, now paper via .cfo-paper) ---------- */
#upmAvatar { background-color: var(--accent); color: var(--on-primary); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
#upmStatusDot { border: 3px solid var(--surface); background: var(--border-control); }
#upmUsername.cfo-modal-title { font-size: 20px; line-height: 28px; }
.upm-ic-primary { color: var(--primary-ink); }
.upm-ic-accent { color: var(--accent-ink); }
.upm-ic-danger { color: var(--danger); }
.upm-ic-gold { color: var(--gold-ink); }
.upm-ic-info { color: var(--info); }
.upm-stat { background: var(--surface-subtle); padding: 12px 5px; border-radius: var(--radius-lg); border: 1px solid transparent; }
.upm-stat > i,
.upm-stat > svg { font-size: 16px; margin-bottom: 5px; }
.upm-stat-value { font-size: 16px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.upm-stat-value-sm { font-size: 12px; margin-top: 4px; }
.upm-stat-label { margin-top: 2px; font-size: 10px; line-height: 1.3; letter-spacing: 0.3px; text-transform: uppercase; color: var(--text-secondary); }
/* The global dark heading rule would turn these overline labels ink; keep them secondary. */
body.dark-mode #userProfileModal h4.cfo-overline { color: var(--text-secondary) !important; }
.upm-stat-mutual { margin-top: 2px; font-size: 10px; font-weight: 700; color: var(--primary-ink); }
.upm-empty {
    width: 100%;
    padding: 12px;
    font-size: 12px;
    text-align: center;
    color: var(--text-secondary);
    background: var(--surface-subtle);
    border: 1px dashed var(--border-control);
    border-radius: var(--radius-md);
}
.upm-empty-plain { background: none; border: 0; }
.upm-theme-likes { padding: 2px 5px; border-radius: var(--radius-sm); background: var(--scrim); color: var(--on-glass); font-size: 10px; }

/* Milestone badge chips. The badge's own colour stays on its icon (content); hover is CSS, not inline JS. */
.user-badge-chip {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    padding: 6px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-subtle);
    cursor: pointer;
    transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.user-badge-chip:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.user-badge-icon { font-size: 15px; color: var(--gold-ink); }
.user-badge-name { font-size: 12px; font-weight: 700; color: var(--text-primary); white-space: nowrap; }
.user-badge-month { margin-top: 2px; }

/* Friend actions (renderFriendActionButtons). Cancel/Unfriend swap their label on hover and keyboard focus. */
.upm-friend-btn.cfo-btn { font-size: 13px; }
.upm-swap-btn .upm-swap-rest,
.upm-swap-btn .upm-swap-hover { display: inline-flex; align-items: center; gap: var(--space-2); }
.upm-swap-btn .upm-swap-hover { display: none; }
.upm-swap-btn:hover .upm-swap-rest,
.upm-swap-btn:focus-visible .upm-swap-rest { display: none; }
.upm-swap-btn:hover .upm-swap-hover,
.upm-swap-btn:focus-visible .upm-swap-hover { display: inline-flex; }
.upm-swap-btn.cfo-btn:hover,
.upm-swap-btn.cfo-btn:focus-visible { background: var(--danger-tint); color: var(--danger); }
.upm-block-btn.cfo-icon-btn { color: var(--danger); }
.upm-block-btn.cfo-icon-btn:hover { background: var(--danger-tint); color: var(--danger); }

/* ---------- Phones: the profile card and Friends hub become bottom sheets like the other paper modals ---------- */
@media (max-width: 600px) {
    #userProfileModal,
    #friendsHubModal { align-items: flex-end !important; }
    #friendsHubModal .fh-card.cfo-paper { height: min(600px, 90vh); }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .user-badge-chip:hover { transform: none; }
    .upg-feature { transition: none; }
}
