/* The site's theme picker: light / auto / dark, and every colour theme the app ships.
   Painted only in the page theme's variables (themes.css), so it is itself a preview. */

.theme-picker {
    position: relative;
    flex: 0 0 auto;
}

.theme-picker-trigger {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 32px;
    padding: 0 10px;
    border-radius: 9px;
    border: 1px solid var(--card-border);
    background: color-mix(in srgb, var(--ink) 5%, transparent);
    color: var(--ink);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
}
.theme-picker-trigger:hover { background: color-mix(in srgb, var(--ink) 10%, transparent); }
.theme-picker-trigger:focus-visible,
.theme-picker-scheme button:focus-visible,
.theme-picker-swatch:focus-visible {
    outline: 2px solid var(--highlight);
    outline-offset: 2px;
}

.theme-picker-dots { display: inline-flex; }
.theme-picker-dots span {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 1.5px solid var(--surface);
}
.theme-picker-dots span + span { margin-left: -4px; }
.theme-picker-dots span:nth-child(1) { background: var(--accent-1); }
.theme-picker-dots span:nth-child(2) { background: var(--accent-2); }
.theme-picker-dots span:nth-child(3) { background: var(--accent-3); }

.theme-picker-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 62;
    width: min(440px, calc(100vw - 24px));
    max-height: min(72vh, 620px);
    overflow-y: auto;
    padding: 14px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--card-border);
    box-shadow: 0 18px 48px color-mix(in srgb, #000 28%, transparent);
    color: var(--ink);
    text-align: left;
}
.theme-picker-panel[hidden] { display: none; }

.theme-picker-heading {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-2);
}
.theme-picker-heading + .theme-picker-heading,
.theme-picker-scheme + .theme-picker-heading { margin-top: 14px; }

.theme-picker-scheme {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: 11px;
    background: color-mix(in srgb, var(--ink) 6%, transparent);
}
.theme-picker-scheme button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 6px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.theme-picker-scheme button[aria-pressed="true"] {
    /* The selection mark (design SSOT, hard gate 4): a four-sided 2.5px edge in the page's
       emphasis colour and a heavier label, never a fill; inset, so nothing moves. */
    box-shadow: inset 0 0 0 2.5px var(--highlight);
    font-weight: 700;
}

.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    gap: 8px;
}

/* One app theme: its page colour with its three lead accents laid on it, and its name.
   The swatch colours are the theme's own, set inline from app-themes.json. */
.theme-picker-swatch {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    overflow: hidden;
}
.theme-picker-swatch:hover { border-color: var(--highlight); }
.theme-picker-swatch[aria-pressed="true"] {
    /* The selection mark (design SSOT, hard gate 4): a four-sided 2.5px edge in the page's
       emphasis colour and a heavier label, never a fill; inset, so nothing moves. */
    box-shadow: inset 0 0 0 2.5px var(--highlight);
}
.theme-picker-swatch-paint {
    display: flex;
    align-items: flex-end;
    gap: 5px;
    height: 46px;
    padding: 8px 9px;
}
.theme-picker-swatch-paint i {
    display: block;
    width: 18px;
    border-radius: 6px;
}
.theme-picker-swatch-paint i:nth-child(1) { height: 28px; }
.theme-picker-swatch-paint i:nth-child(2) { height: 20px; }
.theme-picker-swatch-paint i:nth-child(3) { height: 14px; }
.theme-picker-swatch-paint i:nth-child(4) { height: 9px; }
.theme-picker-swatch-name {
    padding: 7px 9px 8px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.25;
}
.theme-picker-check {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--highlight-fill);
    color: var(--on-highlight);
    display: none;
    align-items: center;
    justify-content: center;
}
.theme-picker-swatch[aria-pressed="true"] .theme-picker-check { display: flex; }

/* A phone: the panel is a sheet along the bottom of the screen. */
@media (max-width: 600px) {
    .theme-picker-panel {
        position: fixed;
        top: auto;
        left: 12px;
        right: 12px;
        bottom: 12px;
        width: auto;
        max-height: 75vh;
    }
    .theme-picker-trigger-label { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
    html.theme-switching,
    html.theme-switching * {
        transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease !important;
    }
}
