/*
 * KAN-981 (CMO, 2026-11-11 §3): profile.html follows the phone's dark mode.
 * Dave's rule: anything a customer or budtender sees follows the phone's
 * setting. This covers the real customer profile (after a scan), the sample
 * and self views (also inside the tutorial and the app's WebView), and their
 * banners, cards and states.
 *
 * Opt-in: only pages with .theme-auto on <html> and <body> (profile.html,
 * budtender-enroll.html). portal.css is shared by the dashboard and other
 * pages, which stay light.
 *
 * The root matters on iPhone Safari: the page's <meta name="color-scheme">
 * and a dark <html> keep its own UI (keyboard accessory bar, status bar) and
 * the rubber-band overscroll dark, not white.
 *
 * Palette: the tutorial's dark spec. Page #121212, cards #1E1E1E, the green
 * card family #16241B with #22392A dividers, text #F3F4F6, muted #9CA3AF,
 * green text #4ADE80. Solid green buttons and badges don't change.
 */
@media (prefers-color-scheme: dark) {
    html.theme-auto, html:has(body.theme-auto) {
        color-scheme: dark;
        background: #121212;
    }

    body.theme-auto {
        color-scheme: dark;
        --p-bg: #121212;
        --p-bg-raised: #1A1A1A;
        --p-bg-card: #16241B;
        --p-surface: #1E1E1E;
        --p-text: #F3F4F6;
        --p-text-muted: #9CA3AF;
        /* Text and link green: the light green reads on dark. Solid
           backgrounds use --p-primary, which stays. */
        --p-primary-dark: #4ADE80;
        --p-border: #22392A;
        --p-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
        --p-shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.55);
        --p-error: #F87171;
        --p-error-bg: #3B1515;
        --p-error-border: #7F1D1D;
        --p-success-bg: #16241B;
        --p-success-border: #22392A;
        --p-warning: #FBBF24;
        --p-warning-bg: #3A2A0B;
        --p-warning-border: #78530F;
        background: var(--p-bg);
        color: var(--p-text);
    }

    /* portal.css: the colours it doesn't take from variables */
    body.theme-auto .p-nav { background: rgba(18, 18, 18, 0.97); box-shadow: 0 1px 0 #2A2A2A; }
    /* Not border-color: that would also take the green left edge off the
       shelf and favourites cards (.pick-card, border-left). */
    body.theme-auto .p-card { border-top-color: rgba(74, 222, 128, 0.10); border-right-color: rgba(74, 222, 128, 0.10); border-bottom-color: rgba(74, 222, 128, 0.10); }
    body.theme-auto .p-btn-secondary { color: #4ADE80; border-color: #4ADE80; }
    body.theme-auto .p-btn-secondary:hover { background: #16241B; }

    /* profile.html's own hard-coded colours */
    body.theme-auto .tag.strength-0 { background: #2A2A2A; color: #D1D5DB; }
    body.theme-auto .tag-more:hover { background: rgba(255, 255, 255, 0.06); }
    body.theme-auto .badge-feeling { background: #2E1065; color: #C4B5FD; }
    body.theme-auto .scan-notice.info { background: #172554; border-color: #1E3A8A; color: #93C5FD; }
    body.theme-auto .badge-confidence.limited { background: #3A2A0B; color: #FCD34D; }
    body.theme-auto .badge-confidence.building { background: #172554; color: #93C5FD; }
    body.theme-auto .potency-bar { background: #2A2A2A; }
    body.theme-auto .potency-marker, body.theme-auto .potency-avoid-marker { border-color: #1E1E1E; }
    body.theme-auto .badge-stated { color: #C4B5FD; background: rgba(124, 58, 237, 0.18); border-color: rgba(167, 139, 250, 0.45); }
    body.theme-auto .stated-label { color: #9CA3AF; }
    body.theme-auto .stated-chip { background: rgba(124, 58, 237, 0.18); color: #DDD6FE; border-color: rgba(167, 139, 250, 0.4); }
    body.theme-auto .stated-chip.avoid { background: rgba(220, 38, 38, 0.15); color: #FCA5A5; border-color: rgba(248, 113, 113, 0.4); }
    body.theme-auto .summary-card { background: linear-gradient(135deg, #16241B 0%, #132A2E 100%); }
    body.theme-auto .app-cta { background: linear-gradient(135deg, #16241B 0%, #241B3A 100%); border-color: rgba(167, 139, 250, 0.22); }
    body.theme-auto .app-cta-badge--ios,
    body.theme-auto .handoff-bar a.p-btn-store { border: 1px solid #3F3F46; }
    body.theme-auto .sample-banner { background: #1E1E1E; }
    body.theme-auto .handoff-note { color: #FBBF24; }
    body.theme-auto .tut-help { background: #2A2A2A; border-color: #3F3F46; color: #F3F4F6; }
    body.theme-auto.handoff-cards .rec-card[data-product-uuid]:active { background: rgba(74, 222, 128, 0.08); }

    /* The beta modal (beta-modal.css), opened from "Join the Android beta" */
    body.theme-auto .bm-overlay { background: rgba(0, 0, 0, 0.7); }
    body.theme-auto .bm-modal { background: #1E1E1E; color: #F3F4F6; }
    body.theme-auto .bm-title { color: #F3F4F6; }
    body.theme-auto .bm-lede, body.theme-auto .bm-field-label, body.theme-auto .bm-fine, body.theme-auto .bm-account-note { color: #9CA3AF; }
    body.theme-auto .bm-close { color: #F3F4F6; }
    body.theme-auto .bm-input, body.theme-auto .bm-select { background: #121212; color: #F3F4F6; border-color: #3F3F46; }
    body.theme-auto .bm-success { background: #16241B; color: #86EFAC; }
    body.theme-auto .bm-error { background: #3B1515; color: #FCA5A5; }
}
