/* matthounslow.dev — shared styles
   palette: gruvbox-inspired cream / charcoal, one muted teal-blue accent */

@font-face {
    font-family: "iA Writer Quattro";
    font-style: normal;
    font-display: swap;
    font-weight: 400;
    src: url(/assets/fonts/quattro-400.woff2) format("woff2");
}
@font-face {
    font-family: "iA Writer Quattro";
    font-style: normal;
    font-display: swap;
    font-weight: 700;
    src: url(/assets/fonts/quattro-700.woff2) format("woff2");
}
@font-face {
    font-family: "iA Writer Mono";
    font-style: normal;
    font-display: swap;
    font-weight: 400;
    src: url(/assets/fonts/mono-400.woff2) format("woff2");
}

:root {
    color-scheme: light;
    --bg: #f9f5d7;
    --bg-alt: #f3ecc8;
    --bg-sunk: #ebdbb2;
    --line: #e2d6ae;
    --line-strong: #bdae93;
    --muted: #71665b;
    --text-3: #665c54;
    --text-2: #504945;
    --text: #3c3836;
    --accent: #076678;
    --on-accent: #f9f5d7;
    --header-bg: rgb(249 245 215 / 0.88);

    --font-sans: "iA Writer Quattro", -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "iA Writer Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --wrap: 52rem;
    --gutter: 1.5rem;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --bg: #1d2021;
        --bg-alt: #252829;
        --bg-sunk: #161819;
        --line: #32302f;
        --line-strong: #504945;
        --muted: #9d8e7e;
        --text-3: #a89984;
        --text-2: #d5c4a1;
        --text: #ebdbb2;
        --accent: #83a598;
        --on-accent: #1d2021;
        --header-bg: rgb(29 32 33 / 0.88);
    }
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #1d2021;
    --bg-alt: #252829;
    --bg-sunk: #161819;
    --line: #32302f;
    --line-strong: #504945;
    --muted: #9d8e7e;
    --text-3: #a89984;
    --text-2: #d5c4a1;
    --text: #ebdbb2;
    --accent: #83a598;
    --on-accent: #1d2021;
    --header-bg: rgb(29 32 33 / 0.88);
}

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

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}


::selection {
    background: var(--accent);
    color: var(--on-accent);
}

a {
    color: inherit;
}

img,
svg {
    display: block;
    max-width: 100%;
}

.mono {
    font-family: var(--font-mono);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -3rem;
    z-index: 200;
    padding: 0.5rem 0.75rem;
    background: var(--accent);
    color: var(--on-accent);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    text-decoration: none;
}
.skip-link:focus {
    top: 1rem;
}

.wrap {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 var(--gutter);
}

@media (max-width: 640px) {
    :root {
        --gutter: 1rem;
    }
}

/* ---------- page transitions ----------
   cross-document view transitions (chrome/edge/safari; others just navigate).
   the header stays pinned; the page underneath softly crossfades. */

@view-transition {
    navigation: auto;
}

.site-header {
    view-transition-name: site-header;
}

::view-transition-group(site-header) {
    animation: none;
}

::view-transition-old(root) {
    animation: vt-fade-out 200ms ease-out both;
}

::view-transition-new(root) {
    animation: vt-fade-in 360ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}

@keyframes vt-fade-out {
    to {
        opacity: 0;
    }
}

@keyframes vt-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

/* ---------- header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.site-header .wrap {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 3.5rem;
}

.logo {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
    margin-right: auto;
}
.logo .prompt {
    color: var(--muted);
    font-weight: 400;
    margin-right: 0.3rem;
}

.site-nav ul {
    display: flex;
    gap: 0.25rem;
    list-style: none;
}

.site-nav a {
    display: block;
    padding: 0.3rem 0.55rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-3);
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.site-nav a:hover {
    color: var(--text);
    border-color: var(--line-strong);
}
.site-nav a[aria-current="page"] {
    color: var(--text);
    border-color: var(--line);
    background: var(--bg-alt);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: none;
    border: 1px solid transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover {
    color: var(--text);
    border-color: var(--line-strong);
}
.theme-toggle svg {
    width: 1rem;
    height: 1rem;
}
.theme-toggle .icon-sun {
    display: none;
}
:root[data-theme="dark"] .theme-toggle .icon-sun {
    display: block;
}
:root[data-theme="dark"] .theme-toggle .icon-moon {
    display: none;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-sun {
        display: block;
    }
    :root:not([data-theme="light"]) .theme-toggle .icon-moon {
        display: none;
    }
}

@media (max-width: 640px) {
    .site-header .wrap {
        flex-wrap: wrap;
        row-gap: 0;
        padding-top: 0.5rem;
    }
    .theme-toggle {
        order: 2;
    }
    .site-nav {
        order: 3;
        width: calc(100% + 2 * var(--gutter));
        margin: 0 calc(-1 * var(--gutter));
        padding: 0.25rem var(--gutter) 0.5rem;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .site-nav::-webkit-scrollbar {
        display: none;
    }
    .site-nav ul {
        gap: 0.125rem;
    }
    .site-nav a {
        padding: 0.25rem 0.4rem;
        font-size: 0.75rem;
    }
    .site-nav li:first-child a {
        margin-left: -0.4rem;
    }
}

/* ---------- headings & sections ---------- */

main {
    display: block;
}

.section {
    padding: 2.75rem 0 0;
}

.section-title {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 1.125rem;
}
.section-title .hash {
    font-family: var(--font-mono);
    font-weight: 400;
    color: var(--accent);
}
.section-title .aside {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--muted);
}
.section-title .aside a {
    color: var(--text-3);
    text-decoration: none;
    border-bottom: 1px dashed var(--line-strong);
}
.section-title .aside a:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

@media (max-width: 640px) {
    .section {
        padding-top: 2.25rem;
    }
    .section-title {
        font-size: 1.1875rem;
    }
}

/* ---------- buttons, tags, links ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.2;
    color: var(--text);
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--line-strong);
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s, transform 0.15s;
}
.btn:hover {
    border-color: var(--text);
    background: var(--bg-alt);
}
.btn svg {
    width: 0.9rem;
    height: 0.9rem;
    flex-shrink: 0;
}
.btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
}
.btn.primary:hover {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}

.tag {
    display: inline-block;
    padding: 0.05rem 0.4rem;
    font-family: var(--font-mono);
    font-size: 0.71875rem;
    color: var(--text-3);
    border: 1px solid var(--line-strong);
    white-space: nowrap;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.text-link {
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px solid var(--line-strong);
    transition: color 0.15s, border-color 0.15s;
}
.text-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.125rem;
    height: 2.125rem;
    color: var(--text-3);
    border: 1px solid transparent;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.icon-link:hover {
    color: var(--text);
    border-color: var(--line-strong);
    background: var(--bg-alt);
}
.icon-link svg {
    width: 1.0625rem;
    height: 1.0625rem;
}

/* ---------- footer ---------- */

.site-footer {
    margin-top: 4rem;
    border-top: 1px solid var(--line);
}
.site-footer .wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding-top: 1.5rem;
    padding-bottom: 2rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--muted);
}
.site-footer a {
    color: var(--text-3);
    text-decoration: none;
}
.site-footer a:hover {
    color: var(--accent);
}
.site-footer .prompt {
    color: var(--accent);
}

/* ---------- terminal bits ---------- */

.prompt {
    color: var(--muted);
}

.cursor {
    display: inline-block;
    width: 0.55ch;
    height: 1em;
    margin-left: 0.12em;
    vertical-align: -0.1em;
    background: var(--accent);
    animation: blink 1.1s step-end infinite;
}

@keyframes blink {
    50% {
        opacity: 0;
    }
}

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

@media print {
    .site-header,
    .site-footer,
    .skip-link,
    .no-print {
        display: none !important;
    }
}
