/* Shared theme layer — nicolabortignon.com
 *
 * Token defaults, the theme control, and the accessibility primitives used by
 * both the homepage and the post template. Every value here is overwritten at
 * runtime by assets/theme.js; these are the no-JS fallbacks and match the
 * midnight end of the ramp.
 */

:root {
    --bg:            hsl(252, 26%, 5%);
    --surface:       hsl(252, 26%, 10.5%);
    --text:          hsl(252, 18%, 88%);
    --text-soft:     hsl(252, 18%, 73%);
    --text-muted:    hsl(252, 14%, 60%);
    --accent:        hsl(206, 45%, 62%);
    --accent-strong: hsl(206, 45%, 72%);
    --border:        hsl(252, 20%, 26%);
    --border-soft:   hsla(252, 20%, 20%, 0.9);
    --accent-wash:   hsla(206, 45%, 62%, 0.12);
    --accent-glow:   hsla(206, 45%, 62%, 0.24);
    --scrim:         hsla(252, 26%, 5%, 0.92);
    --scrim-strong:  hsla(252, 26%, 5%, 0.94);
    --scrim-mid:     hsla(252, 26%, 5%, 0.62);
    --scrim-fade:    hsla(252, 26%, 5%, 0.18);
    --scrim-none:    hsla(252, 26%, 5%, 0);
    --selection-bg:  hsl(206, 45%, 62%);
    --selection-fg:  hsl(252, 26%, 4%);

    /* 4px spacing rhythm */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4rem;
    --space-9: 6rem;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 160ms;
    --dur: 240ms;

    color-scheme: dark;
}

:root[data-theme="light"] {
    color-scheme: light;
}

/* The palette animates only while it is changing, so hover and focus
 * transitions keep their own much shorter timings the rest of the time. */
html.theme-shifting *,
html.theme-shifting *::before,
html.theme-shifting *::after {
    transition-property: background-color, border-color, color, fill, stroke,
                         box-shadow, text-shadow, opacity;
    transition-duration: 900ms;
    transition-timing-function: var(--ease);
}

::selection {
    background: var(--selection-bg);
    color: var(--selection-fg);
}

:where(a, button, [tabindex]):focus-visible {
    outline: 2px solid var(--accent-strong);
    outline-offset: 3px;
    border-radius: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 100;
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    font-family: 'Space Mono', ui-monospace, monospace;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    text-decoration: none;
    transform: translateY(-200%);
}

.skip-link:focus {
    transform: translateY(0);
}

/* ── Theme control ──────────────────────────────────────────────────── */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0 var(--space-3);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 999px;
    color: var(--text-muted);
    font-family: 'Space Mono', ui-monospace, monospace;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    cursor: pointer;
    transition: color var(--dur) var(--ease),
                border-color var(--dur) var(--ease),
                background-color var(--dur) var(--ease);
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--border);
    background: var(--accent-wash);
}

.theme-toggle:active {
    transform: scale(0.97);
}

.theme-toggle-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    transition: background-color var(--dur) var(--ease),
                box-shadow var(--dur) var(--ease);
}

/* A quarter-lit dot for auto, full for light, hollow for dark. Shape carries
 * the state as well as the text label, never colour alone. */
:root[data-theme-mode="light"] .theme-toggle-dot {
    background: var(--accent-strong);
}

:root[data-theme-mode="dark"] .theme-toggle-dot {
    background: transparent;
    border: 1.5px solid var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .theme-toggle:active {
        transform: none;
    }
}
