/* --------------------------------------------------
   Shared website theme
-------------------------------------------------- */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --font-mono:
        "Courier New",
        Courier,
        monospace;

    --font-body:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Helvetica,
        Arial,
        sans-serif;

    --page-background: #ffffff;
    --page-text: #333333;

    --heading-color: #111111;

    --link-color: #242424;
    --strong-link-color: #111111;
    --brand-accent: #795c5c;
    --hover-color: var(--brand-accent);

    --muted-text: #666666;
    --subtle-text: #707070;
    --faint-text: #767676;

    --border-color: #dddddd;
    --strong-border-color: #cccccc;
    --blockquote-border: #aaaaaa;

    color-scheme: light;

    --page-foreground: #000000;

    --blur-background: rgba(255, 255, 255, 0.25);

    --control-background: rgba(255, 255, 255, 0.78);
    --control-border: rgba(0, 0, 0, 0.35);
    --control-text: rgba(0, 0, 0, 0.8);
}

html[data-theme="dark"] {
    --page-background: #0a0a0a;
    --page-text: #ccc3c3;

    --heading-color: #ffffff;

    --link-color: #e0e0e0;
    --strong-link-color: #ffffff;
    --brand-accent: #917373;
    --hover-color: var(--brand-accent);

    --muted-text: #888888;
    --subtle-text: #808080;
    --faint-text: #7a7a7a;

    --border-color: #222222;
    --strong-border-color: #333333;
    --blockquote-border: #444444;

    color-scheme: dark;

    --page-foreground: #ffffff;

    --blur-background: rgba(0, 0, 0, 0.25);

    --control-background: rgba(0, 0, 0, 0.72);
    --control-border: rgba(255, 255, 255, 0.45);
    --control-text: rgba(255, 255, 255, 0.8);
}

html {
    background: var(--page-background);
    color: var(--page-text);
    scroll-behavior: smooth;
}

body {
    background: var(--page-background);
    color: var(--page-text);

    transition:
        background-color 300ms ease,
        color 300ms ease;
}

/* --------------------------------------------------
   Shared section-page shell
-------------------------------------------------- */

.site-shell {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 24px;
    align-items: center;

    margin-bottom: clamp(42px, 6vw, 68px);
    padding-bottom: 15px;

    border-bottom: 1px solid var(--border-color);

    font-family: var(--font-mono);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

.site-brand,
.site-navigation a {
    color: var(--muted-text);
    text-decoration: none;
    transition: color 180ms ease;
}

.site-brand {
    color: var(--heading-color);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.site-navigation {
    display: flex;
    justify-content: center;
    gap: clamp(14px, 3vw, 28px);
}

.site-navigation a {
    position: relative;
}

.site-navigation a::after {
    content: "";

    position: absolute;
    right: 0;
    bottom: -6px;
    left: 0;

    height: 1px;
    background: var(--hover-color);
    opacity: 0;
    transform: scaleX(0.4);

    transition:
        opacity 180ms ease,
        transform 180ms ease;
}

.site-navigation a:hover,
.site-navigation a:focus-visible,
.site-navigation a[aria-current="page"] {
    color: var(--heading-color);
}

.site-navigation a[aria-current="page"]::after {
    opacity: 1;
    transform: scaleX(1);
}

.site-brand:focus-visible,
.site-navigation a:focus-visible {
    outline: 1px solid var(--hover-color);
    outline-offset: 4px;
}

.site-theme-toggle {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;
    min-height: 32px;
    padding: 0;

    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: transparent;
    color: var(--muted-text);
    cursor: pointer;

    line-height: 1;

    transition:
        border-color 180ms ease,
        color 180ms ease,
        background-color 180ms ease;
}

.site-theme-toggle:hover,
.site-theme-toggle:focus-visible {
    border-color: var(--strong-border-color);
    background: var(--page-foreground);
    color: var(--page-background);
}

.site-theme-toggle:focus-visible {
    outline: 1px solid var(--hover-color);
    outline-offset: 3px;
}

.theme-icon-stack {
    position: relative;

    display: block;

    width: 18px;
    height: 18px;
}

.theme-icon {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    fill: none;
    stroke: currentColor;
    stroke-width: 1.45;
    stroke-linecap: round;
    stroke-linejoin: round;

    opacity: 0;

    transform:
        scale(0.65)
        rotate(-20deg);

    transition:
        opacity 220ms ease,
        transform 320ms cubic-bezier(.22, 1, .36, 1);
}

html[data-theme="light"]
.theme-icon--moon,
html[data-theme="dark"]
.theme-icon--sun {
    opacity: 1;

    transform:
        scale(1)
        rotate(0);
}

/* --------------------------------------------------
   Shared section-page footer
-------------------------------------------------- */

.site-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 18px;

    margin-top: 58px;
    padding-top: 20px;

    border-top: 1px solid var(--border-color);

    color: var(--subtle-text);

    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.site-footer a {
    color: var(--muted-text);
    text-decoration: none;

    transition: color 180ms ease;
}

.site-footer a:hover,
.site-footer a:focus-visible {
    color: var(--brand-accent);
}

.site-footer a:focus-visible {
    outline: 1px solid var(--brand-accent);
    outline-offset: 3px;
}

@media (max-width: 640px) {
    .site-shell {
        grid-template-areas:
            "brand theme"
            "navigation navigation";
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 18px 16px;
        margin-bottom: 40px;
    }

    .site-brand {
        grid-area: brand;
    }

    .site-navigation {
        grid-area: navigation;
        justify-content: flex-start;
    }

    .site-theme-toggle {
        grid-area: theme;
    }

    .site-footer {
        flex-direction: column;
    }
}

a,
button,
input,
textarea,
select {
    color: inherit;
}

::selection {
    background: var(--brand-accent);
    color: #ffffff;
}

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