/*
    Site themes (planner item 45; Manage → Theme). The body carries the preset ("theme-glass") and any finer choices
    ("cards-glass", "corners-large", "buttons-pill", "spacing-airy", "fonts-serif", "page-bg-gradient"). Presets work
    through the site's tokens (site.css :root), so the brand colors still lead. Only public pages get these classes.
*/

/* ---------- The page background (a choice, or the theme's) ---------- */

body.page-bg-color,
body.page-bg-gradient {
    background: var(--theme-page-bg, var(--site-surface)) fixed;
}

body.page-bg-plain {
    background: var(--site-surface);
}

/* ---------- Presets ---------- */

/* Classic: the look sites have always had (nothing to change). */

/* Liquid glass: frosted panels over a gradient, with light catching their edges. */
body.theme-glass {
    --site-radius: 1.25rem;
    --site-radius-sm: 0.85rem;
    --theme-glass-bg: rgba(255, 255, 255, 0.55);
    --theme-glass-blur: blur(14px) saturate(160%);
}

body.theme-glass:not(.page-bg-plain):not(.page-bg-color):not(.page-bg-gradient) {
    background: linear-gradient(150deg, rgba(var(--site-accent-rgb), 0.55) 0%, rgba(var(--site-highlight-rgb), 0.45) 45%, rgba(var(--site-primary-rgb), 0.55) 100%) fixed;
}

body.theme-glass .site-header {
    background-color: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(18px) saturate(180%);
    -webkit-backdrop-filter: blur(18px) saturate(180%);
}

body.theme-glass .site-footer {
    background-color: rgba(var(--site-primary-rgb), 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.theme-glass .section-alt {
    background-color: rgba(255, 255, 255, 0.28);
}

/* Glass surfaces: the preset's own, or "Cards: glass" with any preset. */
body.theme-glass:not(.cards-flat):not(.cards-raised) :is(.card, .form-surface, .hero-panel, .post-comment, .search-result),
body.cards-glass :is(.card, .form-surface, .hero-panel, .post-comment, .search-result) {
    position: relative;
    background-color: var(--theme-glass-bg, rgba(255, 255, 255, 0.55));
    backdrop-filter: var(--theme-glass-blur, blur(14px) saturate(160%));
    -webkit-backdrop-filter: var(--theme-glass-blur, blur(14px) saturate(160%));
    border-top: 1px solid rgba(255, 255, 255, 0.82);
    border-left: 1px solid rgba(255, 255, 255, 0.6);
    border-right: 1px solid rgba(255, 255, 255, 0.32);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -6px 16px rgba(0, 0, 0, 0.06),
                0 8px 32px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Soft: tinted surfaces, very round corners, pill buttons, big soft shadows. */
body.theme-soft {
    --site-radius: 1.5rem;
    --site-radius-sm: 1rem;
    --site-surface-alt: rgba(var(--site-highlight-rgb), 0.14);
    --site-shadow-sm: 0 4px 18px rgba(var(--site-primary-rgb), 0.08);
    --site-shadow-lg: 0 18px 50px rgba(var(--site-primary-rgb), 0.16);
}

body.theme-soft:not(.page-bg-plain):not(.page-bg-color):not(.page-bg-gradient) {
    background: linear-gradient(180deg, rgba(var(--site-highlight-rgb), 0.12), var(--site-surface) 40%);
}

body.theme-soft:not(.buttons-square):not(.buttons-rounded) .btn {
    border-radius: 999px;
}

/* Bold: square corners, heavy headings, color bands, crisp offset shadows. */
body.theme-bold {
    --site-radius: 0;
    --site-radius-sm: 0;
    --site-shadow-sm: 4px 4px 0 rgba(var(--site-primary-rgb), 0.9);
    --site-shadow-lg: 8px 8px 0 rgba(var(--site-primary-rgb), 0.9);
}

body.theme-bold :is(h1, h2, h3, .h1, .h2, .h3) {
    font-weight: 800;
    letter-spacing: -0.02em;
}

body.theme-bold .card {
    border: 2px solid var(--site-primary);
}

body.theme-bold .section-alt {
    background-color: rgba(var(--site-accent-rgb), 0.16);
}

/* Minimal: no shadows, fine lines, generous space. */
body.theme-minimal {
    --site-radius: 0.25rem;
    --site-radius-sm: 0.2rem;
    --site-shadow-sm: none;
    --site-shadow: none;
    --site-shadow-lg: none;
    --site-surface-alt: #fafafa;
}

body.theme-minimal:not(.spacing-compact):not(.spacing-regular) .section {
    padding-block: clamp(4rem, 10vw, 7rem);
}

body.theme-minimal .card {
    border-color: var(--site-border);
}

/* Dark: light text on dark surfaces (with Bootstrap's own dark mode for its components). */
body.theme-dark {
    --site-surface: #121418;
    --site-surface-alt: #1a1e24;
    --site-text: #e8eaed;
    --site-text-muted: #b6bcc6;
    --site-border: #2c323b;
    --bs-link-color: var(--site-highlight);
    --bs-link-color-rgb: var(--site-highlight-rgb);
    --bs-link-hover-color: #ffffff;
    --bs-body-color: var(--site-text);
    background-color: var(--site-surface);
    color: var(--site-text);
}

body.theme-dark .site-header:not(.header-bg-brand):not(.header-bg-dark) {
    background-color: rgba(18, 20, 24, 0.9);
}

body.theme-dark :is(h1, h2, h3, h4, h5, h6) {
    color: #ffffff;
}

/* ---------- Finer choices (each overrides the preset) ---------- */

/* Cards */
body.cards-flat .card {
    box-shadow: none;
    border: 1px solid var(--site-border);
}

body.cards-raised .card {
    border-color: transparent;
    box-shadow: 0 0.75rem 2rem rgba(var(--site-primary-rgb), 0.14);
}

/* Corners */
body.corners-square { --site-radius: 0; --site-radius-sm: 0; --bs-border-radius: 0; }
body.corners-small { --site-radius: 0.375rem; --site-radius-sm: 0.25rem; --bs-border-radius: 0.25rem; }
body.corners-medium { --site-radius: 0.75rem; --site-radius-sm: 0.5rem; --bs-border-radius: 0.5rem; }
body.corners-large { --site-radius: 1.5rem; --site-radius-sm: 1rem; --bs-border-radius: 1rem; }

/* Buttons */
body.buttons-square .btn { border-radius: 0; }
body.buttons-rounded .btn { border-radius: 0.5rem; }
body.buttons-pill .btn { border-radius: 999px; }

/* Spacing between page sections */
body.spacing-compact .section { padding-block: clamp(2rem, 5vw, 3rem); }
body.spacing-regular .section { padding-block: clamp(3rem, 8vw, 5.5rem); }
body.spacing-airy .section { padding-block: clamp(4.5rem, 11vw, 8rem); }

/* Fonts (system families only) */
body.fonts-system {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --site-heading-font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body.fonts-serif {
    --site-heading-font: ui-serif, Georgia, Cambria, "Times New Roman", serif;
}

body.fonts-rounded {
    font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
    --site-heading-font: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, sans-serif;
}

body.fonts-mono {
    --site-heading-font: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

body:is(.fonts-serif, .fonts-rounded, .fonts-mono, .fonts-system) :is(h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6) {
    font-family: var(--site-heading-font);
}

/* Someone who asks for less transparency gets solid surfaces. */
@media (prefers-reduced-transparency: reduce) {
    body.theme-glass :is(.card, .form-surface, .hero-panel),
    body.cards-glass :is(.card, .form-surface, .hero-panel) {
        background-color: var(--site-surface);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
