/* rapttor/yii2-themes. The chosen theme's variables are emitted inline by Themes::registerHead(); these are the defaults.
   Variables: --bg --surface --text --muted --line --brand --brand-ink --link --accent --elev --elev-sm --elev-in
   Hooks on <html>: data-theme="<id>", data-mode="light|dark" (absent for `system`, which follows the device), data-style="soft".
   Soft (neumorphic) themes set --elev* to dual light/dark shadows: apply `box-shadow: var(--elev)` to raised surfaces
   and `var(--elev-in)` to inset ones (inputs, pressed buttons). Flat themes set them to `none`, so the same CSS fits both. */
:root {
    color-scheme: light dark;
    --bg: #f2f2f7; --surface: #ffffff; --text: #1c1c1e; --muted: #5f5f66; --line: #d9d9de;
    --brand: #0062cc; --brand-ink: #ffffff; --link: #0062cc; --accent: #c93400;
    --elev: none; --elev-sm: none; --elev-in: none;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000; --surface: #1c1c1e; --text: #f2f2f7; --muted: #b0b0b8; --line: #2e2e31;
        --brand: #0a84ff; --brand-ink: #0a0a0a; --link: #64a8ff; --accent: #ff9f0a;
    }
}
:root[data-mode=light] { color-scheme: light; }
:root[data-mode=dark] { color-scheme: dark; }

/* --- Picker (ThemePicker widget) --- */
.theme-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.theme-picker label { margin: 0; font-weight: 600; }
.theme-group { grid-column: 1 / -1; display: block; margin-block: 8px 0; padding: 4px 2px; border-block-end: 1px solid var(--line); font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.theme-group:first-child { margin-block-start: 0; }
.theme-picker[data-tab]:not([data-tab=all]) .theme-group:not([data-group=system]) { display: none; }
.theme-option.is-tab-hidden, .theme-option.is-filtered, .theme-card.is-tab-hidden { display: none; }
.theme-filter { display: inline-flex; margin-block-end: 8px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.theme-filter button { min-block-size: 24px; padding: 1px 10px; border: 0; background: none; font: inherit; font-size: .75rem; line-height: 1.7; font-weight: 600; color: var(--muted); cursor: pointer; }
.theme-filter button.is-on { background: var(--brand); color: var(--brand-ink); }
.theme-tabs { display: flex; gap: 5px; margin-block-end: 8px; padding-block-end: 3px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.theme-tabs[hidden] { display: none; }
@media (min-width: 640px) { .theme-tabs { flex-wrap: wrap; overflow: visible; } }
.theme-tabs button { flex: none; min-block-size: 24px; padding: 1px 10px; border: 1px solid transparent; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, var(--surface)); font: inherit; font-size: .75rem; line-height: 1.7; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.theme-tabs button:hover { color: var(--text); }
.theme-tabs button.is-on { background: var(--brand); color: var(--brand-ink); }
.theme-tabs button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.theme-option { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: center; font-size: .78rem; line-height: 1.2; }
.theme-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.theme-option:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.theme-option:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.theme-name { inline-size: 100%; text-align: center; }
.theme-swatch { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; gap: 3px; inline-size: 100%; block-size: 46px; padding: 6px; border-radius: 8px; background: var(--sw-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sw-text) 18%, transparent); overflow: hidden; }
.theme-swatch b { grid-column: 1 / -1; align-self: start; font-size: .8rem; line-height: 1; color: var(--sw-text); }
.theme-swatch i { display: block; block-size: 8px; border-radius: 4px; }
.theme-swatch i:nth-of-type(1) { background: var(--sw-brand); }
.theme-swatch i:nth-of-type(2) { background: var(--sw-link); }
.theme-swatch i:nth-of-type(3) { background: var(--sw-accent); }
.theme-swatch.is-split { background: linear-gradient(115deg, var(--sw-bg) 0 50%, var(--sw-bg2) 50% 100%); }
.theme-swatch.is-split b { justify-self: center; font-size: .9rem; }
.theme-swatch.is-split b u { text-decoration: none; }
.theme-swatch.is-split b u:first-child { color: var(--sw-text); }
.theme-swatch.is-split b u:last-child { color: var(--sw-text2); }

/* user-defined theme controls (one colour, light or dark) sit under the Custom tile */
.theme-custom { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 4px 2px 8px; }
.theme-custom > label { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; margin: 0; }
.theme-custom input[type=color] { inline-size: 44px; block-size: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.theme-custom .appearance { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.theme-custom .appearance label { position: relative; margin: 0; }
.theme-custom .appearance input { position: absolute; opacity: 0; }
.theme-custom .app-opt { display: block; padding: 5px 16px; font-size: .85rem; cursor: pointer; }
.theme-custom .appearance label:has(input:checked) { background: var(--brand); color: var(--brand-ink); }
.theme-custom .appearance label:has(input:focus-visible), .theme-custom input[type=color]:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
/* the user-defined theme is a card of its own below the groups */
.theme-card { margin-block-start: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.theme-card-title { margin: 0 0 8px; font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.theme-card-body { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }
.theme-card .theme-option { inline-size: 92px; }
.theme-card .theme-custom { padding: 0; }

/* glass themes (data-style="glass"): a soft colour page and translucent surfaces. Host CSS on raised surfaces:
   background: var(--glass-bg); backdrop-filter: var(--glass-filter); -webkit-backdrop-filter: var(--glass-filter);
   border: 1px solid var(--glass-line); box-shadow: var(--elev). Other styles set --glass-bg to the plain surface and the filter to none, so one stylesheet serves all. */
html[data-style=glass] { background: var(--page-bg); background-attachment: fixed; }
html[data-style=glass] body { background: transparent !important; }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { html[data-style=glass] { --glass-bg: var(--surface); } }
@media (prefers-reduced-transparency: reduce) { html[data-style=glass] { --glass-bg: var(--surface); --glass-filter: none; } }

/* page backgrounds (data-bg on <html>): --tbg-image is the still layer, --tbg-overlay the white/black veil that keeps content readable;
   animated ones draw in #theme-bg (theme-bg.js). The body must not paint over them. */
html[data-bg] { background: var(--bg); }
html[data-bg] body { background: transparent !important; }
html[data-bg]::before, html[data-bg]::after { content: ''; position: fixed; inset: 0; z-index: -1; pointer-events: none; }
html[data-bg]::before { background: var(--tbg-image, var(--bg)); }
html[data-bg]::after { background: var(--tbg-overlay, transparent); }
/* liquid interface: the containers (Themes::liquidCss()) and every surface that uses --glass-bg turn semi-transparent over the background */
html[data-liquid] { --glass-bg: color-mix(in srgb, var(--surface) var(--tbg-liquid, 60%), transparent); --glass-filter: blur(16px) saturate(140%); }
#theme-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
#theme-bg-credit { position: fixed; inset-inline-end: 8px; inset-block-end: 8px; z-index: 5; padding: 2px 10px; border-radius: 999px; background: var(--surface); color: var(--link); font: 600 11px/1.6 system-ui, sans-serif; text-decoration: none; opacity: .9; }

/* picker: Colours / Backgrounds */
.theme-modes { display: inline-flex; margin-block-end: 10px; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.theme-modes button { min-block-size: 32px; padding: 4px 16px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.theme-modes button.is-on { background: var(--brand); color: var(--brand-ink); }
.theme-modes button:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -3px; }
.theme-pane[hidden] { display: none; }
.bg-picker { padding: 12px 14px 16px; border: 1px solid var(--glass-line); border-radius: 16px; background: var(--glass-bg); -webkit-backdrop-filter: var(--glass-filter); backdrop-filter: var(--glass-filter); }
.bg-section { margin-block-start: 14px; }
.bg-section:first-of-type { margin-block-start: 8px; }
.bg-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.bg-tile { position: relative; display: flex; align-items: flex-end; min-block-size: 68px; padding: 6px; border: 2px solid var(--line); border-radius: 12px; background-color: var(--surface); background-size: cover; color: #fff; font: inherit; font-size: .75rem; font-weight: 600; text-align: start; cursor: pointer; overflow: hidden; }
.bg-tile > span { padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, .62); line-height: 1.5; }
.bg-tile.is-none { background: repeating-linear-gradient(45deg, var(--surface) 0 8px, var(--bg) 8px 16px); color: var(--text); }
.bg-tile.is-none > span { background: var(--surface); color: var(--text); }
.bg-tile.is-on, .bg-custom.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.bg-tile:focus-visible, .bg-photo:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 2px; }
.bg-solid { background: var(--surface); color: var(--text); }
.bg-solid > span { background: var(--surface); color: var(--text); }
.bg-solid input[type=color], .bg-custom input[type=color] { inline-size: 44px; block-size: 28px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: none; cursor: pointer; }
.bg-solid input[type=color] { position: absolute; inset-block-start: 6px; inset-inline-start: 6px; }
.bg-custom { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-block-start: 8px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 12px; }
.bg-custom label { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .85rem; font-weight: 600; }
.bg-search { display: flex; gap: 6px; }
.bg-search input { flex: 1; min-inline-size: 0; min-block-size: 32px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.bg-search button, .bg-photo-note button, .bg-remove { min-block-size: 32px; padding: 4px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.bg-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-block: 8px; }
.bg-chip { min-block-size: 24px; padding: 1px 10px; border: 1px solid transparent; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, var(--surface)); color: var(--muted); font: inherit; font-size: .75rem; font-weight: 600; cursor: pointer; }
.bg-chip:hover { color: var(--text); }
.bg-photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.bg-photo { position: relative; display: flex; align-items: flex-end; aspect-ratio: 3 / 2; padding: 4px; border: 2px solid transparent; border-radius: 10px; background-size: cover; background-position: center; cursor: pointer; overflow: hidden; }
.bg-photo > span { max-inline-size: 100%; padding: 0 6px; border-radius: 999px; background: rgba(0, 0, 0, .62); color: #fff; font-size: .68rem; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bg-photo.is-on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.bg-photo-note { margin: 8px 0 0; font-size: .75rem; color: var(--muted); }
.bg-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-block-start: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.bg-controls .appearance { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.bg-controls .appearance label { position: relative; margin: 0; }
.bg-controls .appearance input { position: absolute; opacity: 0; }
.bg-controls .app-opt { display: block; padding: 5px 14px; font-size: .85rem; cursor: pointer; }
.bg-controls .appearance label:has(input:checked) { background: var(--brand); color: var(--brand-ink); }
.bg-controls .appearance label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -3px; }
.bg-range { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .85rem; font-weight: 600; }
.bg-palette { margin: 0; font-size: .85rem; font-weight: 600; }
.bg-palette.is-off { opacity: .55; }
.bg-controls.is-off > :not(.bg-remove) { opacity: .5; pointer-events: none; }
.bg-palette-box { display: inline-flex; align-items: center; gap: 10px; }
.bg-palette-box[hidden] { display: none; }
.bg-swatches { display: inline-flex; gap: 4px; }
.bg-swatch { display: block; inline-size: 26px; block-size: 26px; border: 1px solid var(--line); border-radius: 8px; }
.bg-palette-box .appearance { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.bg-palette-box .appearance label { position: relative; margin: 0; }
.bg-palette-box .appearance input { position: absolute; opacity: 0; }
.bg-palette-box .app-opt { display: block; padding: 5px 14px; font-size: .85rem; cursor: pointer; }
.bg-palette-box .appearance label:has(input:checked) { background: var(--brand); color: var(--brand-ink); }
.bg-palette-box .appearance label:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -3px; }
[data-bg-section].is-tab-hidden { display: none; }
.bg-tile.is-tab-hidden { display: none; }
[data-live-groups] { margin-block-end: 10px; }
