/* ==========================================================================
   Fonts
   ========================================================================== */

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/atkinson-hyperlegible-400.woff2") format("woff2");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/atkinson-hyperlegible-400-italic.woff2") format("woff2");
}

@font-face {
    font-family: "Atkinson Hyperlegible";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("/fonts/atkinson-hyperlegible-700.woff2") format("woff2");
}

@font-face {
    font-family: "JetBrains Mono";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
}

/* ==========================================================================
   Design tokens
   ========================================================================== */

:root {
    --bg: oklch(98.4% 0.003 247.858);
    --fg: oklch(13% 0.028 261);
    --muted: oklch(55% 0.02 247);
    --accent: oklch(65% 0.2 5);
    --accent-hover: oklch(55% 0.22 5);
    --border: oklch(90% 0.01 247);

    /* Code blocks: warm rose-pine-dawn palette (light) */
    --code-bg: #faf4ed;

    --font-sans: "Atkinson Hyperlegible", ui-sans-serif, system-ui, sans-serif;
    --font-mono:
        "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --measure: 42rem;
    --radius: 0.375rem;
}

:root[data-theme="dark"] {
    --bg: oklch(12% 0.02 261);
    --fg: oklch(95% 0.005 247);
    --muted: oklch(60% 0.02 247);
    --accent: oklch(72% 0.2 5);
    --accent-hover: oklch(80% 0.18 5);
    --border: oklch(25% 0.02 261);

    /* Code blocks: rose-pine palette (dark) */
    --code-bg: #191724;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg: oklch(12% 0.02 261);
        --fg: oklch(95% 0.005 247);
        --muted: oklch(60% 0.02 247);
        --accent: oklch(72% 0.2 5);
        --accent-hover: oklch(80% 0.18 5);
        --border: oklch(25% 0.02 261);

        /* Code blocks: rose-pine palette (dark) */
        --code-bg: #191724;
    }
}

/* ==========================================================================
   Resets
   ========================================================================== */

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

* {
    margin: 0;
}

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

/* ==========================================================================
   Body shell
   ========================================================================== */

html {
    color-scheme: light;
}

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;
    }
}

body {
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--fg);
    background-color: var(--bg);
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

main {
    width: 100%;
    max-width: var(--measure);
    margin-inline: auto;
    padding-inline: 1.25rem;
    padding-block: 2.5rem;
}

/* ==========================================================================
   Skip link
   ========================================================================== */

.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    font-weight: 700;
    text-decoration: none;
    z-index: 100;
}

.skip-link:focus {
    top: 1rem;
}

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

/* ==========================================================================
   Header / nav
   ========================================================================== */

header {
    position: relative;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: var(--measure);
    margin-inline: auto;
    width: 100%;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--fg);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.logo svg {
    flex-shrink: 0;
    color: var(--accent);
}

.logo span {
    font-size: 1.25rem;
}

header nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

header nav ul {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 0.25rem;
}

header nav a {
    color: var(--fg);
    text-decoration: none;
    padding: 0.25rem 0.375rem;
    font-size: 1.0625rem;
}

/* Links show a dashed accent underline on hover (no pink text); the active
   nav page keeps it persistently as the current-page indicator. */
header nav a:hover,
header nav a[aria-current="page"],
.mobile-menu a:hover,
.mobile-menu a[aria-current="page"],
.prose a:hover,
.post-title:hover,
.rss-link:hover span,
.footer-sitemap a:hover {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

/* Theme toggle */

.theme-toggle,
.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fg);
    display: grid;
    place-items: center;
    padding: 0.375rem;
    margin-left: 0.25rem;
    border-radius: var(--radius);
}

.theme-toggle > svg,
.menu-toggle > svg {
    grid-area: 1 / 1;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover,
.menu-toggle:hover {
    background: var(--border);
}

.theme-toggle:active,
.menu-toggle:active {
    background: color-mix(in srgb, var(--border), var(--fg) 12%);
}

/* default (light): show sun, hide moon */
.theme-toggle .moon {
    opacity: 0;
    transform: rotate(-90deg);
}

/* dark: show moon, hide sun */
:root[data-theme="dark"] .theme-toggle .sun {
    opacity: 0;
    transform: rotate(90deg);
}

:root[data-theme="dark"] .theme-toggle .moon {
    opacity: 1;
    transform: rotate(0);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"])
        .theme-toggle
        .sun {
        opacity: 0;
        transform: rotate(90deg);
    }

    :root:not([data-theme="light"]):not([data-theme="dark"])
        .theme-toggle
        .moon {
        opacity: 1;
        transform: rotate(0);
    }
}

/* menu toggle: show menu icon, swap to X when expanded */
.menu-toggle .close {
    opacity: 0;
    transform: rotate(-90deg);
}

.menu-toggle[aria-expanded="true"] .open {
    opacity: 0;
    transform: rotate(90deg);
}

.menu-toggle[aria-expanded="true"] .close {
    opacity: 1;
    transform: rotate(0);
}

@media (prefers-reduced-motion: reduce) {
    .theme-toggle > svg,
    .menu-toggle > svg {
        transition: none;
    }
}

/* Mobile menu */

.menu-toggle {
    display: none;
}

.mobile-menu {
    display: none;
}

.mobile-menu ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mobile-menu a {
    color: var(--fg);
    text-decoration: none;
    font-size: 1.0625rem;
    display: block;
    padding: 0.25rem 0;
}

@media (max-width: 48rem) {
    .nav-links {
        display: none;
    }

    .menu-toggle {
        display: grid;
    }

    .mobile-menu:not([hidden]) {
        display: block;
        position: absolute;
        top: 100%;
        left: 1.25rem;
        right: 1.25rem;
        z-index: 50;
        background: var(--bg);
        border: 1px solid var(--accent);
        border-radius: var(--radius);
        padding: 1rem;
    }
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
    padding: 3rem 1.25rem 2.5rem;
    max-width: var(--measure);
    margin-inline: auto;
    width: 100%;
    border-top: 1px solid var(--border);
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
}

.footer-about {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
}

.footer-tagline {
    color: var(--muted);
}

footer ul[aria-label="Social links"] {
    list-style: none;
    padding: 0;
    display: flex;
    gap: 0.75rem;
}

footer ul[aria-label="Social links"] a {
    color: var(--muted);
    display: flex;
}

footer ul[aria-label="Social links"] a:hover {
    color: var(--fg);
}

.footer-sitemap h2 {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 1rem;
}

.footer-sitemap ul {
    list-style: none;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
}

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

.footer-sitemap a:hover {
    color: var(--fg);
}

.footer-copyright {
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: 2rem;
}

@media (min-width: 48rem) {
    .footer-grid {
        grid-template-columns: 1.5fr 1fr;
        gap: 4rem;
    }
}

/* ==========================================================================
   Prose
   ========================================================================== */

.prose {
    max-width: 100%;
    font-size: 1.25rem;
    line-height: 1.8;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
}

.prose h1 {
    font-size: 2.25rem;
}
.prose h2 {
    font-size: 1.875rem;
}
.prose h3 {
    font-size: 1.5rem;
}
.prose h4 {
    font-size: 1.25rem;
}

.prose :is(h1, h2, h3, h4, h5, h6) .anchor {
    opacity: 0;
    margin-left: 0.25em;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.prose :is(h1, h2, h3, h4, h5, h6):hover .anchor,
.prose .anchor:focus {
    opacity: 1;
}

.prose .anchor:hover {
    text-decoration: none;
}

.prose p {
    margin-bottom: 1.5rem;
}

.prose a {
    color: var(--accent);
    text-decoration: none;
}

.prose strong {
    font-weight: 700;
}

.prose em {
    font-style: italic;
}

.prose code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.1em 0.35em;
}

.prose kbd {
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--accent);
    background: var(--code-bg);
    border: 1px solid var(--accent);
    border-radius: 0.25rem;
    padding: 0.1em 0.35em;
}

.prose pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.prose pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}

.prose blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    color: var(--muted);
    margin-block: 1.5rem;
    font-style: italic;
}

.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin-block: 2rem;
}

.prose ul,
.prose ol {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.prose li {
    margin-bottom: 0.375rem;
}

.prose img {
    border-radius: var(--radius);
    margin-block: 1.5rem;
}

.prose table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25rem;
    font-size: 0.9375rem;
}

.prose th,
.prose td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.prose th {
    background: var(--code-bg);
    font-weight: 700;
}

/* ==========================================================================
   Post article header
   ========================================================================== */

.post-header {
    margin-bottom: 2rem;
}

.post-header time {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.post-header h1 {
    font-size: clamp(2.25rem, 4vw, 3rem);
    line-height: 1.1;
    letter-spacing: -0.025em;
    font-weight: 700;
    margin: 0;
}

/* ==========================================================================
   Post list
   ========================================================================== */

.post-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.post-list li {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.post-list time {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}

.post-title {
    color: var(--fg);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.25rem;
}

.post-summary {
    color: var(--muted);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

/* ==========================================================================
   Page title
   ========================================================================== */

.page-title,
.section-title,
.hero h1 {
    font-size: clamp(2.25rem, 4vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.page-title {
    margin-bottom: 2rem;
}

/* ==========================================================================
   Home hero
   ========================================================================== */

.hero {
    margin-bottom: 3rem;
}

.hero-intro {
    margin-top: 0.5rem;
    font-size: 1.25rem;
    color: var(--muted);
}

/* ==========================================================================
   Post section ("Latest" / "Blog" head + RSS)
   ========================================================================== */

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 2rem;
}

.section-head .page-title {
    margin-bottom: 0;
}

.rss-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--fg);
    text-decoration: none;
    font-size: 0.9375rem;
    flex-shrink: 0;
}

.rss-link svg {
    color: #f97316;
}

/* ==========================================================================
   404 / not found
   ========================================================================== */

.not-found {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
    padding-block: 4rem 2rem;
}

.not-found-code {
    font-size: clamp(4rem, 12vw, 7rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.04em;
    color: var(--accent);
}

.not-found-title {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.not-found-text {
    max-width: 42ch;
    color: var(--muted);
    text-wrap: balance;
}

.not-found-link {
    margin-top: 0.75rem;
    color: var(--fg);
    text-decoration: none;
    font-weight: 500;
}

.not-found-link:hover {
    text-decoration: underline;
    text-decoration-style: dashed;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

