/* ============================================================
   SKIP NAV
   ============================================================ */

.skip-nav {
    position: absolute;
    top: -100%;
    left: var(--size-4);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: var(--font-size-1);
    padding: var(--size-2) var(--size-5);
    border-radius: 0 0 var(--radius-2) var(--radius-2);
    z-index: 9999;
    background-image: none;
    padding-bottom: var(--size-2);
    transition: top 0.15s;
}

.skip-nav:focus {
    top: 0;
    outline: 2px solid var(--olive-dk);
    outline-offset: 2px;
}

/* ============================================================
   THEME TOKENS
   ============================================================ */

:root {
    color-scheme: light;

    /* Olive — used everywhere */
    --accent: oklch(44% 0.12 130);
    --olive-dk: oklch(28% 0.1 130); /* headings, site title */
    --olive-md: oklch(44% 0.12 130); /* accent, links */
    --olive-lt: oklch(92% 0.025 130); /* tinted surface */

    /* White surfaces with olive undertone */
    --bg: oklch(99% 0.004 130);
    --bg-2: var(--olive-lt);
    --fg: var(--olive-dk);
    --fg-2: oklch(48% 0.06 130);
    --border: oklch(86% 0.025 130);

    --texture-fine: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
    --texture-coarse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.2' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
    --lines: repeating-linear-gradient(
        -55deg,
        transparent 0,
        transparent 6px,
        oklch(44% 0.12 130 / 0.04) 6px,
        oklch(44% 0.12 130 / 0.04) 7px
    );

    /* Squiggle underline variants (light theme) */
    /* gentle — one slow wave, default links */
    --sq-gentle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0,4 C5,0 15,6 20,4' fill='none' stroke='%233C5F00' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    --sq-gentle-sz: 20px 6px;
    /* tight — faster frequency, headline links */
    --sq-tight: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5'%3E%3Cpath d='M0,3.5 C2.5,0.5 7.5,4.5 10,3.5' fill='none' stroke='%233C5F00' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    --sq-tight-sz: 10px 5px;
    /* double — two bumps per tile, body text links */
    --sq-double: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0,3 C3.5,0 6.5,6 10,3 C13.5,0 16.5,6 20,3' fill='none' stroke='%233C5F00' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    --sq-double-sz: 20px 6px;
}

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

    --accent: oklch(65% 0.12 130);
    --olive-dk: oklch(88% 0.04 130);
    --olive-md: oklch(65% 0.12 130);
    --olive-lt: oklch(18% 0.04 130);

    --bg: oklch(12% 0.02 130);
    --bg-2: var(--olive-lt);
    --fg: var(--olive-dk);
    --fg-2: oklch(58% 0.06 130);
    --border: oklch(26% 0.05 130);

    --texture-fine: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.07'/%3E%3C/svg%3E");
    --texture-coarse: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='400'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.2' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='400' height='400' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
    --lines: repeating-linear-gradient(
        -55deg,
        transparent 0,
        transparent 6px,
        oklch(65% 0.12 130 / 0.06) 6px,
        oklch(65% 0.12 130 / 0.06) 7px
    );

    /* Squiggle underline variants (dark theme) */
    --sq-gentle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0,4 C5,0 15,6 20,4' fill='none' stroke='%23779E4B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    --sq-tight: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5'%3E%3Cpath d='M0,3.5 C2.5,0.5 7.5,4.5 10,3.5' fill='none' stroke='%23779E4B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
    --sq-double: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='6'%3E%3Cpath d='M0,3 C3.5,0 6.5,6 10,3 C13.5,0 16.5,6 20,3' fill='none' stroke='%23779E4B' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* ============================================================
   BASE
   ============================================================ */

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

html {
    font-size: clamp(15px, 1.1vw, 17px);
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    font-family: "Raleway", system-ui, sans-serif;
    background-color: var(--bg);
    background-image: var(--lines), var(--texture-fine), var(--texture-coarse);
    background-size:
        auto,
        200px 200px,
        400px 400px;
    color: var(--fg);
    line-height: var(--font-lineheight-3);
    min-height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    transition:
        background-color 0.25s,
        color 0.25s;
}

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

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1,
h2,
h3,
h4 {
    font-family: "Bitter", Georgia, serif;
    font-weight: 800;
    line-height: var(--font-lineheight-1);
    color: var(--olive-dk);
}

h1 {
    font-size: clamp(var(--font-size-5), 5.5vw, var(--font-size-8));
}
h2 {
    font-size: var(--font-size-5);
}
h3 {
    font-size: var(--font-size-4);
}

p {
    max-width: 100%;
}

a {
    color: var(--accent);
    text-decoration: none;
    background-image: var(--sq-gentle);
    background-repeat: repeat-x;
    background-position: 0 100%;
    background-size: var(--sq-gentle-sz);
    padding-bottom: 3px;
    transition: color 0.15s;
}

strong {
    font-weight: 700;
}
em {
    font-style: italic;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.inner {
    max-width: 65ch;
    margin-inline: auto;
    padding-inline: var(--size-6);
}

/* ============================================================
   HEADER & NAV
   ============================================================ */

header {
    padding-block: var(--size-4);
    border-bottom: 3px solid var(--accent);
}

nav {
    max-width: 65ch;
    margin-inline: auto;
    padding-inline: var(--size-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--size-4);
}

.site-title,
.nav-links > a,
.post-card-link,
.post-card-title a,
.footer-links a,
.toc a,
.tag,
.series-list a,
[data-theme="dark"] .site-title,
[data-theme="dark"] .nav-links > a,
[data-theme="dark"] .post-card-link,
[data-theme="dark"] .post-card-title a,
[data-theme="dark"] .footer-links a,
[data-theme="dark"] .toc a,
[data-theme="dark"] .tag,
[data-theme="dark"] .series-list a {
    background-image: none;
    padding-bottom: 0;
}

.site-title {
    font-family: "Bitter", Georgia, serif;
    font-size: var(--font-size-4);
    font-weight: 900;
    font-style: italic;
    color: var(--olive-dk);
    text-decoration: none;
    letter-spacing: -0.02em;
    transition: color 0.15s;
}

.site-title:hover {
    color: var(--accent);
    text-decoration: none;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: var(--size-5);
}

.nav-links > a {
    color: var(--fg-2);
    text-decoration: none;
    font-size: var(--font-size-0);
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-4);
    text-transform: uppercase;
    transition: color 0.15s;
    position: relative;
}

.nav-links > a::after {
    content: "";
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.2s ease;
    border-radius: var(--radius-round);
}

.nav-links > a:hover {
    color: var(--accent);
}

.nav-links > a:hover::after {
    width: 100%;
}

/* ============================================================
   THEME TOGGLE
   ============================================================ */

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--fg-2);
    width: 2.2rem;
    height: 2.2rem;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: color 0.2s;
    flex-shrink: 0;
    padding: 0;
}

.theme-toggle:hover {
    color: var(--accent);
}

.theme-toggle svg {
    width: 1rem;
    height: 1rem;
    display: block;
}

/* ============================================================
   MAIN
   ============================================================ */

main {
    max-width: 65ch;
    margin-inline: auto;
    padding-inline: var(--size-6);
    padding-block: var(--size-6);
    width: 100%;
}

/* ============================================================
   HOME HERO
   ============================================================ */

.home-hero {
    padding-block-start: var(--size-6);
    margin-block-end: var(--size-4);
    padding-block-end: var(--size-4);
    position: relative;
    overflow: visible;
}

/* large faint star — decorative */
.home-hero::before {
    content: "✦";
    position: absolute;
    right: -1rem;
    top: -0.5rem;
    font-size: 9rem;
    color: var(-4accent);
    opacity: 0.06;
    transform: rotate(12deg);
    pointer-events: none;
    line-height: 1;
    user-select: none;
}

.home-hero h1 {
    margin-block: var(--size-2) var(--size-4);
    letter-spacing: -0.03em;
    position: relative;
    display: inline-block;
}

/* squiggly underline after the name */
.home-hero h1::after {
    content: "";
    display: block;
    width: 180px;
    height: 12px;
    margin-top: var(--size-1);
    background-color: var(--accent);
    opacity: 0.5;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M0,6 C10,0 30,12 40,6' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
    mask-repeat: repeat-x;
    mask-size: 40px 12px;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='12'%3E%3Cpath d='M0,6 C10,0 30,12 40,6' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
    -webkit-mask-repeat: repeat-x;
    -webkit-mask-size: 40px 12px;
}

/* decorative circle — behind the first letter */
.home-hero h1::before {
    content: "";
    position: absolute;
    width: 1.4em;
    height: 1.4em;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.12;
    top: -0.15em;
    left: -0.25em;
    z-index: -1;
}

.hero-deco {
    position: absolute;
    top: 0;
    right: 0;
    width: 160px;
    height: 160px;
    color: var(--accent);
    pointer-events: none;
    user-select: none;
}

.hero-body {
    font-size: var(--font-size-2);
    color: var(--fg-2);
    max-width: 50ch;
    line-height: var(--font-lineheight-4);
}

.hero-body p + p {
    margin-top: var(--size-4);
}

/* ============================================================
   EYEBROW LABEL
   ============================================================ */

.eyebrow {
    display: block;
    font-size: var(--font-size-00);
    font-weight: 700;
    letter-spacing: var(--font-letterspacing-5);
    text-transform: uppercase;
    color: var(--accent);
    margin-block-end: var(--size-2);
}

.eyebrow::before {
    content: "✦ ";
    font-style: normal;
    letter-spacing: 0;
}

/* ============================================================
   POST LIST
   ============================================================ */

.post-index {
    display: grid;
    gap: var(--size-6);
}

.post-index + .post-index {
    margin-block-start: var(--size-8);
}

.post-list {
    list-style: none;
    display: grid;
    gap: var(--size-1);
}

.post-list li {
    display: grid;
    gap: var(--size-1);
    padding-block: var(--size-4);
}

.post-list a {
    font-family: "Bitter", Georgia, serif;
    font-size: var(--font-size-3);
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
    font-style: italic;
    display: i;
    background-image: var(--sq-tight);
    background-size: var(--sq-tight-sz);
}

.post-list a:hover {
    color: var(--accent);
}

.post-list time {
    font-size: var(--font-size-00);
    color: var(--fg-2);
    letter-spacing: var(--font-letterspacing-3);
    text-transform: uppercase;
    white-space: nowrap;
}

/* ============================================================
   SECTION HEADER
   ============================================================ */

.section-header {
    margin-block-end: var(--size-4);
    padding-block-end: var(--size-4);
}

.section-description {
    font-size: var(--font-size-2);
    color: var(--fg-2);
    margin-top: var(--size-3);
    max-width: 50ch;
}

/* ============================================================
   POST CARDS
   ============================================================ */

.post-cards {
    list-style: none;
    display: grid;
    gap: var(--size-6);
}

.post-card {
    position: relative;
    overflow: hidden;
    background: oklch(92% 0.025 130 / 0.5);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid oklch(44% 0.12 130 / 0.12);
    border-left: 5px solid var(--border);
    border-radius: 0 var(--radius-3) var(--radius-3) 0;
    padding: var(--size-7) var(--size-7) var(--size-6);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.4),
        0 2px 8px oklch(44% 0.12 130 / 0.04);
    transition:
        border-left-color 0.25s,
        box-shadow 0.25s,
        transform 0.25s;
}

/* large faint index number */
.post-card::before {
    content: attr(data-num);
    position: absolute;
    right: var(--size-5);
    bottom: -0.15em;
    font-family: "Bitter", Georgia, serif;
    font-weight: 900;
    font-size: 9rem;
    line-height: 1;
    color: var(--accent);
    opacity: 0.07;
    pointer-events: none;
    user-select: none;
}

/* decorative star */
.post-card::after {
    content: "✦";
    position: absolute;
    top: var(--size-5);
    right: var(--size-5);
    font-size: var(--font-size-2);
    color: var(--accent);
    opacity: 0.2;
    pointer-events: none;
    transition:
        opacity 0.25s,
        transform 0.25s;
}

.post-card:hover {
    border-left-color: var(--accent);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.4),
        0 8px 28px oklch(44% 0.12 130 / 0.12);
    transform: translateX(4px) translateY(-2px);
}

.post-card:hover::after {
    opacity: 0.5;
    transform: rotate(20deg) scale(1.2);
}

[data-theme="dark"] .post-card {
    background: oklch(18% 0.04 130 / 0.5);
    border-color: oklch(65% 0.12 130 / 0.1);
    border-left-color: var(--border);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.05),
        0 2px 8px oklch(0% 0 0 / 0.2);
}

[data-theme="dark"] .post-card:hover {
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.05),
        0 8px 28px oklch(0% 0 0 / 0.35);
}

/* invisible full-card click target */
.post-card-link {
    position: absolute;
    inset: 0;
}

.post-card-meta {
    display: flex;
    align-items: center;
    gap: var(--size-3);
    margin-block-end: var(--size-4);
    font-size: var(--font-size-00);
    color: var(--fg-2);
    letter-spacing: var(--font-letterspacing-3);
    text-transform: uppercase;
}

.post-card-meta time {
    white-space: nowrap;
}

.series-badge {
    background: oklch(from var(--accent) l c h / 0.1);
    border: 1px solid oklch(from var(--accent) l c h / 0.2);
    color: var(--accent);
    border-radius: var(--radius-round);
    padding: 0.1em 0.5em;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-2);
}

.post-card-title {
    font-size: var(--font-size-5);
    margin-block-end: var(--size-3);
    line-height: var(--font-lineheight-2);
    letter-spacing: -0.02em;
}

.post-card-title a {
    color: var(--fg);
    text-decoration: none;
    position: relative;
    z-index: 1;
    transition: color 0.15s;
}

.post-card:hover .post-card-title a {
    color: var(--accent);
}

.post-card-description {
    color: var(--fg-2);
    font-size: var(--font-size-1);
    line-height: var(--font-lineheight-4);
    max-width: 52ch;
}

.post-card .tag-list {
    position: relative;
    z-index: 1;
    margin-top: var(--size-5);
}

/* ============================================================
   POST PAGE
   ============================================================ */

.post-header {
    margin-block-end: var(--size-6);
    padding-block-end: var(--size-6);
    position: relative;
}

/* the colored gradient rule under title */
.post-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: var(--size-14);
    background: var(--accent);
    border-radius: var(--radius-round);
}

.post-date {
    display: block;
    font-size: var(--font-size-00);
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-4);
    text-transform: uppercase;
    color: var(--accent);
    margin-block-end: var(--size-3);
}

.post-header h1 {
    letter-spacing: -0.03em;
}

.post-body {
    font-size: var(--font-size-2);
    line-height: var(--font-lineheight-4);
}

.post-body a {
    background-image: var(--sq-double);
    background-size: var(--sq-double-sz);
}

.post-body > * + * {
    margin-top: var(--size-5);
}

.post-body h2 {
    font-size: var(--font-size-4);
}

.post-body h3 {
    margin-top: var(--size-8);
    font-size: var(--font-size-3);
}

.post-body ul,
.post-body ol {
    padding-left: var(--size-6);
}

.post-body li + li {
    margin-top: var(--size-2);
}

.post-body blockquote {
    border-left: 4px solid var(--accent);
    background: oklch(92% 0.025 130 / 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: var(--size-4) var(--size-6);
    margin-inline: 0;
    border-radius: 0 var(--radius-3) var(--radius-3) 0;
    border-top: 1px solid oklch(44% 0.12 130 / 0.12);
    border-right: 1px solid oklch(44% 0.12 130 / 0.12);
    border-bottom: 1px solid oklch(44% 0.12 130 / 0.12);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.45),
        0 4px 16px oklch(44% 0.12 130 / 0.06);
    font-family: "Bitter", Georgia, serif;
    font-style: italic;
    font-size: var(--font-size-3);
    color: var(--fg-2);
}

.post-body code {
    font-family: ui-monospace, "Cascadia Code", monospace;
    font-size: 0.88em;
    background: var(--bg-2);
    padding: 0.1em 0.4em;
    border-radius: var(--radius-2);
    color: var(--accent);
    border: 1px solid var(--border);
}

.post-body pre {
    background: oklch(92% 0.025 130 / 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    padding: var(--size-5);
    /*border-radius: var(--radius-3);*/
    overflow-x: auto;
    /*border-left: 4px solid var(--accent);
    border-top: 1px solid oklch(44% 0.12 130 / 0.12);
    border-right: 1px solid oklch(44% 0.12 130 / 0.12);
    border-bottom: 1px solid oklch(44% 0.12 130 / 0.12);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.45),
        0 4px 16px oklch(44% 0.12 130 / 0.06);*/
}

.post-body pre code {
    background: none;
    border: none;
    color: inherit;
    padding: 0;
    font-size: var(--font-size-0);
}

.copy-btn {
    position: absolute;
    top: var(--size-3);
    right: var(--size-3);
    font-size: var(--font-size-00);
    font-family: inherit;
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-3);
    text-transform: uppercase;
    color: var(--fg-2);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-2);
    padding: 0.2em 0.6em;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.15s,
        color 0.15s;
}

.post-body pre:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.post-body hr {
    border: none;
    height: 1px;
    background: var(--border);
    margin-block: var(--size-10);
    position: relative;
}

.post-body hr::before {
    content: "◆";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg);
    padding-inline: var(--size-3);
    color: var(--accent);
    font-size: var(--font-size-1);
}

/* ============================================================
   FOOTER
   ============================================================ */

footer {
    border-top: 3px solid var(--accent);
    padding-block: var(--size-10);
}

.footer-inner {
    max-width: 65ch;
    margin-inline: auto;
    padding-inline: var(--size-6);
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: var(--size-4) var(--size-8);
    align-items: start;
}

.footer-brand {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
}

.footer-tagline {
    font-size: var(--font-size-0);
    color: var(--fg-2);
    max-width: 40ch;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--size-2);
    align-items: flex-end;
}

.footer-links a {
    font-size: var(--font-size-0);
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-4);
    text-transform: uppercase;
    color: var(--fg-2);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-links a:hover {
    color: var(--accent);
}

.footer-copy {
    font-size: var(--font-size-00);
    color: var(--fg-2);
    letter-spacing: var(--font-letterspacing-3);
    grid-column: 1 / -1;
    opacity: 0.6;
}

@media (max-width: 640px) {
    .footer-inner {
        grid-template-columns: 1fr;
    }
    .footer-links {
        align-items: flex-start;
        flex-direction: row;
        flex-wrap: wrap;
        gap: var(--size-4);
    }
}

p.empty {
    color: var(--fg-2);
    font-style: italic;
}

/* ============================================================
   TAGS
   ============================================================ */

.tag-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--size-2);
    margin-top: var(--size-4);
}

.post-list .tag-list {
    margin-top: var(--size-3);
}

.post-list .tag {
    font-size: 0.65rem;
    padding: 0.1em 0.5em;
    letter-spacing: var(--font-letterspacing-2);
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: var(--size-1);
    font-size: var(--font-size-00);
    font-weight: 600;
    letter-spacing: var(--font-letterspacing-3);
    color: var(--accent);
    background: oklch(from var(--accent) l c h / 0.08);
    border: 1px solid oklch(from var(--accent) l c h / 0.2);
    border-radius: var(--radius-round);
    padding: 0.2em 0.7em;
    text-decoration: none;
    transition:
        background 0.15s,
        border-color 0.15s;
}

.tag:hover {
    background: oklch(from var(--accent) l c h / 0.15);
    border-color: var(--accent);
    text-decoration: none;
    animation: tag-wiggle 0.4s ease-in-out;
}

@keyframes tag-wiggle {
    0% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-4deg);
    }
    75% {
        transform: rotate(4deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

.tag-cloud {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--size-3);
}

.tag-count {
    font-weight: 400;
    opacity: 0.6;
}

.tag-archive h1 {
    margin-block: var(--size-2) 0;
}

/* ============================================================
   THEME TRANSITION (View Transitions API)
   ============================================================ */

/* post list scroll-reveal base state */
@media (prefers-reduced-motion: no-preference) {
    .post-list li {
        transform: translateX(-10px);
        transition:
            opacity 0.4s ease,
            transform 0.4s ease;
    }
    .post-list li.visible {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: no-preference) {
    body {
        animation: texture-drift 60s linear infinite;
    }

    @keyframes texture-drift {
        from {
            background-position:
                0 0,
                0 0,
                0 0;
        }
        to {
            background-position:
                0 0,
                200px 100px,
                -400px 200px;
        }
    }

    /* animated squiggle underline on hover */
    a:hover {
        animation: link-squiggle 2s linear infinite;
    }
    @keyframes link-squiggle {
        from {
            background-position: 0 100%;
        }
        to {
            background-position: 20px 100%;
        }
    }

    /* hero entrance — staggered fade up */
    .home-hero .eyebrow {
        animation: fade-up 0.5s ease both;
    }
    .home-hero h1 {
        animation: fade-up 0.6s ease both 0.1s;
    }
    .hero-body {
        animation: fade-up 0.5s ease both 0.35s;
    }
    @keyframes fade-up {
        from {
            opacity: 0;
            transform: translateY(14px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* squiggle draws in left to right */
    .home-hero h1::after {
        clip-path: inset(0 100% 0 0);
        animation: squiggle-reveal 0.8s ease forwards 0.4s;
    }
    @keyframes squiggle-reveal {
        to {
            clip-path: inset(0 0% 0 0);
        }
    }

    /* decorative star slow spin */
    .home-hero::before {
        animation: slow-spin 25s linear infinite;
    }
    @keyframes slow-spin {
        from {
            transform: rotate(12deg);
        }
        to {
            transform: rotate(372deg);
        }
    }

    /* theme transition */
    ::view-transition-old(root) {
        animation: none;
    }
    ::view-transition-new(root) {
        animation: theme-reveal 0.45s cubic-bezier(0.4, 0, 0.2, 1);
    }
    @keyframes theme-reveal {
        from {
            clip-path: circle(0% at calc(100% - 3.5rem) 3.5rem);
        }
        to {
            clip-path: circle(150% at calc(100% - 3.5rem) 3.5rem);
        }
    }
}

/* ============================================================
   POST SUBTITLE
   ============================================================ */

.post-subtitle {
    font-size: var(--font-size-3);
    color: var(--fg-2);
    font-style: italic;
    margin-top: var(--size-2);
}

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */

.toc {
    background: oklch(92% 0.025 130 / 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-left: 4px solid var(--accent);
    border-top: 1px solid oklch(44% 0.12 130 / 0.12);
    border-right: 1px solid oklch(44% 0.12 130 / 0.12);
    border-bottom: 1px solid oklch(44% 0.12 130 / 0.12);
    border-radius: 0 var(--radius-3) var(--radius-3) 0;
    padding: var(--size-5) var(--size-6);
    margin-block: var(--size-8);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.45),
        0 4px 16px oklch(44% 0.12 130 / 0.06);
}

.toc ol {
    padding-left: var(--size-5);
    margin-top: var(--size-2);
    list-style: decimal;
}

.toc li + li {
    margin-top: var(--size-2);
}

.toc a {
    color: var(--fg-2);
    text-decoration: none;
    font-size: var(--font-size-1);
    transition: color 0.15s;
}

.toc a:hover {
    color: var(--accent);
}

.toc ol ol {
    margin-top: var(--size-1);
    padding-left: var(--size-4);
}

/* ============================================================
   CALLOUTS
   ============================================================ */

.callout {
    border-left: 4px solid var(--accent);
    background: oklch(from var(--accent) l c h / 0.06);
    padding: var(--size-4) var(--size-6);
    border-radius: 0 var(--radius-3) var(--radius-3) 0;
    margin-block: var(--size-5);
}

.callout-warning {
    border-left-color: oklch(65% 0.2 50);
    background: oklch(65% 0.2 50 / 0.06);
}

.callout-tip {
    border-left-color: oklch(55% 0.15 160);
    background: oklch(55% 0.15 160 / 0.06);
}

.callout-title {
    display: block;
    margin-block-end: var(--size-2);
    font-size: var(--font-size-0);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: var(--font-letterspacing-4);
}

/* ============================================================
   GLASS — DARK MODE OVERRIDES
   ============================================================ */

[data-theme="dark"] .toc,
[data-theme="dark"] .series-nav,
[data-theme="dark"] .post-body pre,
[data-theme="dark"] .post-body blockquote {
    background: oklch(18% 0.04 130 / 0.55);
    border-top-color: oklch(65% 0.12 130 / 0.12);
    border-right-color: oklch(65% 0.12 130 / 0.12);
    border-bottom-color: oklch(65% 0.12 130 / 0.12);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.06),
        0 4px 20px oklch(0% 0 0 / 0.25);
}

/* ============================================================
   SEARCH
   ============================================================ */

.search-page h1 {
    margin-block: var(--size-2) 0;
}

.search-box {
    margin-block: var(--size-6);
}

.search-box input {
    width: 100%;
    padding: var(--size-3) var(--size-4);
    font-size: var(--font-size-2);
    font-family: inherit;
    background: var(--bg-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-3);
    color: var(--fg);
    outline: none;
    transition: border-color 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
}

/* ============================================================
   READING PROGRESS BAR
   ============================================================ */

.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent);
    z-index: 1000;
    transition: width 0.1s linear;
}

/* ============================================================
   SERIES NAV
   ============================================================ */

.series-nav {
    background: oklch(92% 0.025 130 / 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-left: 4px solid var(--accent);
    border-top: 1px solid oklch(44% 0.12 130 / 0.12);
    border-right: 1px solid oklch(44% 0.12 130 / 0.12);
    border-bottom: 1px solid oklch(44% 0.12 130 / 0.12);
    border-radius: 0 var(--radius-3) var(--radius-3) 0;
    padding: var(--size-5) var(--size-6);
    margin-block: var(--size-8);
    box-shadow:
        inset 0 1px 0 oklch(100% 0 0 / 0.45),
        0 4px 16px oklch(44% 0.12 130 / 0.06);
}

.series-list {
    list-style: decimal;
    padding-left: var(--size-5);
    margin-top: var(--size-2);
    display: grid;
    gap: var(--size-2);
}

.series-list a {
    color: var(--fg-2);
    text-decoration: none;
    font-size: var(--font-size-1);
    transition: color 0.15s;
}

.series-list a:hover {
    color: var(--accent);
}

.series-current a {
    color: var(--fg);
    font-weight: 600;
    pointer-events: none;
}

/* ============================================================
   POST META
   ============================================================ */

.post-meta {
    display: flex;
    gap: var(--size-3);
    align-items: baseline;
}

.post-reading-time {
    font-size: var(--font-size-00);
    color: var(--fg-2);
    letter-spacing: var(--font-letterspacing-3);
    text-transform: uppercase;
    white-space: nowrap;
}

/* ============================================================
   BACK TO TOP
   ============================================================ */

.back-to-top {
    position: fixed;
    bottom: var(--size-8);
    right: var(--size-6);
    width: 2.5rem;
    height: 2.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-round);
    cursor: pointer;
    display: grid;
    place-items: center;
    opacity: 0;
    transform: translateY(8px);
    transition:
        opacity 0.2s,
        transform 0.2s;
    pointer-events: none;
    z-index: 100;
}

.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.back-to-top:hover {
    background: var(--olive-dk);
}

.back-to-top svg {
    width: 1rem;
    height: 1rem;
}

/* ============================================================
   NOT FOUND
   ============================================================ */

.not-found {
    padding-block: var(--size-12);
}

.not-found h1 {
    margin-block: var(--size-2) var(--size-4);
}

.not-found p {
    color: var(--fg-2);
    margin-block-end: var(--size-6);
}

/* ============================================================
   POST SIDEBAR LAYOUT
   ============================================================ */

/* main stays same width as header/footer — body column aligns */
.main--post {
    max-width: 65ch;
    overflow-x: hidden;
}

@media (min-width: 1050px) {
    .main--post {
        overflow: visible;
    }
}

/* On wide viewports, bleed sidebars into the gutters via negative margin */
@media (min-width: 1050px) {
    .post-layout {
        --toc-w: 180px;
        --toc-gap: var(--size-7);
        display: grid;
        align-items: start;
    }

    /* TOC only — left gutter */
    .post-layout--toc {
        grid-template-columns: var(--toc-w) 1fr;
        gap: var(--toc-gap);
        margin-left: calc(-1 * (var(--toc-w) + var(--toc-gap)));
        width: calc(100% + var(--toc-w) + var(--toc-gap));
    }

    /* Series only — right gutter */
    .post-layout--series {
        grid-template-columns: 1fr var(--toc-w);
        gap: var(--toc-gap);
        margin-right: calc(-1 * (var(--toc-w) + var(--toc-gap)));
        width: calc(100% + var(--toc-w) + var(--toc-gap));
    }

    /* Both — bleed both gutters */
    .post-layout--full {
        grid-template-columns: var(--toc-w) 1fr var(--toc-w);
        gap: var(--toc-gap);
        margin-left: calc(-1 * (var(--toc-w) + var(--toc-gap)));
        margin-right: calc(-1 * (var(--toc-w) + var(--toc-gap)));
        width: calc(100% + 2 * (var(--toc-w) + var(--toc-gap)));
    }

    .post-sidebar,
    .post-sidebar-right {
        position: sticky;
        top: var(--size-8);
        align-self: start;
    }
}

@media (max-width: 1049px) {
    .post-sidebar,
    .post-sidebar-right {
        display: none;
    }
}

/* plain toc — no card chrome */
.toc--plain {
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin-block: 0;
}

.toc--plain ol {
    padding-left: 0;
    list-style: none;
}

.toc--plain li + li {
    margin-top: var(--size-3);
}

.toc--plain ol ol {
    margin-top: var(--size-2);
    padding-left: var(--size-3);
}

.toc--plain a {
    font-size: var(--font-size-0);
    line-height: var(--font-lineheight-3);
}

.toc--plain a.toc-active {
    color: var(--fg);
    font-weight: 600;
}

.series-nav--plain {
    background: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin-block: 0 var(--size-6);
}

.post-list-desc {
    font-size: var(--font-size-1);
    color: var(--fg-2);
    line-height: var(--font-lineheight-4);
    max-width: 52ch;
    padding-block-start: var(--size-2);
    padding-block-end: var(--size-1);
}

.see-all {
    margin-block-start: var(--size-5);
    font-size: var(--font-size-1);
}

.see-all a {
    color: var(--fg-2);
    text-decoration: none;
}

.see-all a:hover {
    color: var(--fg-1);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Post body: wrap long words/URLs, never overflow */
.post-body {
    overflow-wrap: break-word;
    min-width: 0;
}

@media (max-width: 640px) {
    main {
        padding-inline: var(--size-4);
        padding-block: var(--size-6);
    }

    /* Tighten nav gap on small screens */
    nav {
        gap: var(--size-3);
    }
    .nav-links {
        gap: var(--size-4);
    }

    /* Reading time is secondary — hide it on small screens */
    .post-reading-time {
        display: none;
    }

    /* Tighter post header */
    .post-header {
        margin-block-end: var(--size-5);
    }

    /* Scale down h2/h3 slightly */
    .post-body h2 {
        font-size: var(--font-size-3);
    }
    .post-body h3 {
        font-size: var(--font-size-2);
    }

    /* Code blocks: slightly smaller font, ensure scroll */
    .post-body pre {
        font-size: var(--font-size-00);
        padding: var(--size-4);
    }

    /* Images fill width */
    .post-body img {
        width: 100%;
    }
}

/* ============================================================
   MERMAID DIAGRAMS
   ============================================================ */

.mermaid-wrap {
    margin-block: var(--size-8);
    padding: var(--size-6);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-3);
    overflow-x: auto;
    text-align: center;
}

.mermaid-wrap pre.mermaid {
    margin: 0;
    background: none;
    border: none;
    padding: 0;
}

.mermaid-wrap svg {
    max-width: 100%;
    height: auto;
}
