html {
    scroll-behavior: smooth;
}

:root {
    /* Core palette — change ONLY these 4 to re-skin the whole site */
    --palette-black: #271d2c;
    --palette-white: #fff8ed;
    --palette-secondary: #7b6960;
    --palette-accent: #e01f3f;

    /* Active vars (palette swaps these, default inherits palette) */
    --black: var(--palette-black);
    --white: var(--palette-white);
    --secondary: var(--palette-secondary);
    --accent: var(--palette-accent);

    /* Derived */
    --black-shadow: color-mix(in srgb, var(--black) 10%, transparent);
    --text: var(--black);
}

:root.palette-comic {
    --black: #00303b;
    --white: #f1f2da;
    --secondary: #ff7777;
    --accent: #ffce96;
}

:root.palette-stone {
    --black: #211e20;
    --white: #e9efec;
    --secondary: #a0a08b;
    --accent: #555568;
}

:root.palette-cave {
    --black: #372a39;
    --white: #f5e9bf;
    --secondary: #788374;
    --accent: #aa644d;
}

:root.palette-earthy {
    --black: #142209;
    --white: #c8c6b2;
    --secondary: #747759;
    --accent: #3a4222;
}

/* Palette toggle in footer */
.palette-toggle {
    background: none;
    border: 1px solid var(--secondary);
    color: var(--secondary);
    padding: 4px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    transition: color 0.2s, border-color 0.2s;
}

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

@font-face {
    font-family: 'League Spartan';
    src: url('font/LeagueSpartan-VF.woff2') format('woff2');
    font-weight: 100 900;
}

@font-face {
    font-family: 'League Gothic';
    src: url('font/LeagueGothic-Regular.woff2') format('woff2');
}

@font-face {
    font-family: 'Fanwood';
    src: url('font/Fanwood.woff') format('woff');
}

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

body {
    background: var(--black);
    color: var(--white);
    font-family: 'League Spartan', Helvetica, Arial;
    text-align: center;
    max-width: 1100px;
    margin: 0 auto;
}

.main-content {
    max-width: 1100px;
    margin: 16px;
    padding: 32px;
    text-align: left;
    background-color: var(--white);
    color: var(--text);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content a {
    color: var(--accent);
    font-weight: bold;
    text-decoration: none;
}

.main-content p {
    font-size: 1.5em;
    line-height: 1.5em;
    text-wrap: auto;
    /* margin-block: 1lh; */
}

.fiction-body {
    text-align: justify;
    word-wrap: break-word;
    font-family: 'Fanwood', serif;
}

.fiction-body .post-hero,
.fiction-body .post-hero * {
    font-family: 'League Spartan', sans-serif;
}

.main-content > ul:not(.picker):not(.item-list):not(.feed) > li {
    font-size: 1.5em;
    line-height: 1em;
    margin-left: 0.8em;
    list-style: none;
}

.main-content > ul:not(.picker):not(.item-list):not(.feed):not(.all-tags) > li:before {
    display: inline-block;
    content: "-";
    width: 0.8em;
    font-weight: 900;
    margin-left: -0.8em;
}

.main-content h2 a {
    color: var(--text);
}

.main-content > ol:not(.series-list) {
    margin-top: 8px;
    margin-bottom: 16px;
    padding-left: 8px;
}

.series-list {
    list-style-position: outside;
    padding-left: 0;
    counter-reset: series-counter;
}

.series-list > li {
    counter-increment: series-counter;
    margin-bottom: 24px;
    list-style: none;
    position: relative;
    padding-left: 60px;
}

.series-list > li::before {
    content: counter(series-counter);
    position: absolute;
    left: 0;
    top: 12px;
    font-size: 2.5em;
    font-weight: 900;
    color: var(--secondary);
    line-height: 1;
}

.main-content > ol:not(.series-list) > li {
    font-size: 1.5em;
    line-height: 1.5em;
    margin-left: 0.8em;
    font-weight: 200;
}

.main-content a:hover {
    text-decoration: underline;
}

.main-content a.tag {
    color: currentColor;
    font-weight: normal;
}

.main-content:has(.about-section) {
    background-image: url('/img/bwsam.jpg');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: top center;
}

.byline {
    line-height: normal;
}

.techlist {
    line-height: normal;
    margin-top: 0px;
    display: block;
    font-weight: 200;
    font-size: 0.75em;
}

.about-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.about-section h1 {
    color: var(--white);
    display: none;
}

.about-section .wordlist {
    height: 0;
    padding-bottom: 86%;
    position: relative;
    overflow: hidden;
}

.about-section .wordlist::before {
    content: "";
    display: block;
    padding-top: 900px;
}

.main-content aside {
    font-style: italic;
    width: 100%;
    font-size: 2em;
    font-weight: 200;
    line-height: 1.2em;
    color: var(--secondary);
    padding: 16px;
    margin: 16px 0 24px;
    background-color: var(--black-shadow);
    border-radius: 8px;
}

.about-section h2 {
    color: var(--white); 
    font-size: 2.5em;
    font-weight: 400;
    margin-top: -8px;
    display: none;
}

.main-content h1 {
    font-size: 4em;
    font-weight: 800;
    letter-spacing: 0.05em;
    margin-bottom: 0.3em;
}

.main-content > h2:not(.wordlist h2) {
    font-size: 3em;
    font-weight: 700;
    margin: 16px 0 24px;
}

.wordlist h2 {
    color: var(--white);
    font-size: 2.5em;
    font-weight: 400;
    margin-top: 8px;
    display: none;
}

.main-content h3 {
    font-size: 2.5em;
    font-weight: 700;
    margin: 16px 0 16px;
}

.main-content h4 {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0 0 8px;
}

.light-text {
    font-weight: 100;
    font-style: italic;
}

.main-content > img.mini {
    width: 40%;
    margin: 32px 32px 32px 0;
}

.main-content > .image-caption {
    width: 40%;
    font-style: italic;
    font-size: 1.2em;
    padding: 16px 32px 16px;
    margin-bottom: 32px;
    font-weight: 200;
    color: var(--secondary);
    text-align: center;
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    background-color: var(--black-shadow);
    border-radius: 8px;
}

.image-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: space-between;
    margin: 16px 0;
}

.image-row img {
    flex: 1 1 auto;
    max-width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 24px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
}

.pixel-screenshot {
    image-rendering: pixelated;
    border-radius: 24px;
    margin-bottom: 16px;
}


.main-content > img:not([class]),
.main-content > p > img:not([class]) {
    border-radius: 24px;
    margin-bottom: 16px;
}


.tooltip {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
    cursor: pointer;
}

.tooltip .tooltiptext {
    visibility: hidden;
    background-color: var(--secondary);
    color: var(--white);
    font-style: italic;
    font-weight: 100;
    text-align: center;
    padding: 8px 16px 8px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    line-height: normal;

    max-width: 300px;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

.tooltip:hover .tooltiptext, .tooltip:focus .tooltiptext, .tooltip:active .tooltiptext,
.tooltip:focus-within .tooltiptext {
    visibility: visible;
}

.tooltip:active .tooltiptext {
    visibility: hidden;
}
/* Summary */
.summary {
    display: none;
    position: relative;
    z-index: 10;
    background-color: var(--secondary);
    color: var(--white);
    font-weight: 300;
    font-size: 2em;
    padding: 16px 24px 16px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    line-height: normal;
    margin-bottom: 16px;
}

.post-hero.has-image + .summary {
    position: relative;
    z-index: 10;
    margin-top: -32px;
}

/* Show the summary text when you hover over the tldr element,
   if .summary comes after .tldr in the DOM */
.post-metadata:has(.tldr:hover) + .summary,
.post-metadata:has(.tldr:focus) + .summary,
.post-metadata:has(.tldr:focus-within) + .summary,
.post-hero:has(.tldr:hover) + .summary,
.post-hero:has(.tldr:focus) + .summary,
.post-hero:has(.tldr:focus-within) + .summary {
    display: block;
}

.post-metadata:has(.tldr:active) + .summary,
.post-hero:has(.tldr:active) + .summary {
    display: none;
}

.tldr {
    cursor: pointer;
    font-weight: 700;
    /* Make it focusable for tap interactions on mobile */
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.picker {
    list-style-type: none;
    display: flex;
    margin: 32px auto 0px;
    gap: 12px;
    /* center the list */
    justify-content: center;
    padding: 12px;
    background-color: var(--black-shadow);
    border-radius: 1024px;
    /* box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow); */
}

.picker a {
    color: var(--secondary);
    font-size: 1.5em;
    font-weight: 700;
    text-decoration: none;
}

.picker .selected {
    text-decoration: underline;
    font-weight: 900;
}

header {
    background-color: var(--black);
    margin: 1em 16px 0;
    text-align: right;
}

nav {
    margin: 0 20px;
}

nav a {
    text-decoration: none;
    font-weight: bold;
    font-size: 1.4em;
}

nav ul {
    display: flex;
    flex-direction: row;
    list-style-type: none;
    padding: 0; 
    margin: 0;
    gap: 16px;
}

nav li a.selected {
    text-decoration: underline;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

nav a:hover:not(.selected) {
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
}

code {
    background-color: var(--black-shadow);
    padding-left: 4px;
    padding-right: 4px;
    border-radius: 8px;
    font-weight: 100;
    font-family: monospace !important;
    color: var(--accent);
}

header .wrapper {
    padding-top: 30px;
    padding-bottom: 30px;
    text-align: right;
    margin-right: 0;
}

header a {
    text-decoration: none;
}

header h3 {
    font-size: 1.5em;
    font-weight: 100;
    color: var(--secondary);
}

header .site-name {
    font-size: 3em;
    font-weight: 700;
    margin-bottom: 0.8em;
}

h1 {
    margin-bottom: 20px;
    font-size: 2em;
}

p {
    margin-bottom: 10px;
}

a {
    color: inherit;
}

.item-list {
    list-style: none;
    padding: 0;
}

.item-list > li .essay-item {
    display: block;
    border-radius: 20px;
    margin-bottom: 20px;
    list-style: none;
    padding: 16px;
    border-radius: 16px;
    border-width: 2px;
    border-style: dotted;
    border-color: var(--secondary);
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-list > li .essay-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 20px -3px var(--black-shadow), 0 6px 8px -4px var(--black-shadow);
    cursor: pointer;
}

.item-list > li .fiction-item {
    display: block;
    border-radius: 20px;
    margin-bottom: 20px;
    list-style: none;
    padding: 16px;
    border-radius: 16px;
    border-width: 2px;
    border-style: dashed;
    border-color: var(--secondary);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.item-list > li .fiction-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    cursor: pointer;
}

/* Stretched link - makes whole card clickable */
.stretched-link::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Ensure essay/fiction items have position relative for stretched link containment */
.essay-item,
.fiction-item {
    position: relative;
}

/* Keep internal links and interactive elements clickable above the stretched link */
.essay-item .post-metadata a,
.fiction-item .post-metadata a,
.essay-item .tag-list,
.fiction-item .tag-list,
.essay-item .tldr,
.fiction-item .tldr {
    position: relative;
    z-index: 2;
}

.fiction-item p {
    margin-bottom: 0;
}

.item-list h1 {
    margin-bottom: 15px;
    font-size: 1.3em;
}

.essay-item p {
    margin-bottom: 0;
}

.essay-item.has-image {
    position: relative;
    background-size: cover;
    background-position: center;
    background-origin: padding-box;
    background-clip: padding-box;
}

.essay-item.has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--white) 50%, transparent) 0%,
        color-mix(in srgb, var(--white) 70%, transparent) 100%
    );
    z-index: 0;
}

.essay-item.has-image > * {
    position: relative;
    z-index: 1;
}

.hero-image {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 24px;
}

/* Takeover Essay Styles */
.takeover-essay {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: 16px;
    min-height: 300px;
    margin-bottom: 24px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 10px 30px -5px var(--black-shadow), 0 6px 10px -5px var(--black-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.takeover-essay:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 40px -10px var(--black-shadow), 0 10px 20px -10px var(--black-shadow);
    text-decoration: none;
}

.takeover-essay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        color-mix(in srgb, var(--black) 95%, transparent) 0%,
        color-mix(in srgb, var(--black) 70%, transparent) 40%,
        color-mix(in srgb, var(--black) 20%, transparent) 70%,
        transparent 100%
    );
    z-index: 1;
}

.takeover-content {
    position: relative;
    z-index: 2;
    padding: 16px 24px;
    color: var(--white);
}

.takeover-content h2 {
    font-size: 2.5em;
    font-weight: 800;
    margin: 0;
    color: var(--white);
    line-height: 1.1;
    text-decoration: none;
}

.takeover-content.has-accent h2 {
    color: inherit;
}

.takeover-content .post-metadata {
    margin-top: -4px;
}

.takeover-content .post-metadata,
.takeover-content .post-metadata * {
    color: color-mix(in srgb, var(--white) 80%, transparent);
}

.takeover-content.has-accent .post-metadata,
.takeover-content.has-accent .post-metadata * {
    color: inherit;
}

.takeover-content .post-metadata > *:first-child::after {
    content: none;
}

.takeover-content .post-metadata .tag-list::before {
    color: var(--white);
}

.takeover-content .byline {
    font-size: 1.1em;
    font-weight: 300;
    margin-top: 4px;
    margin-bottom: 0;
    color: color-mix(in srgb, var(--white) 90%, transparent);
}

.main-content a.takeover-link,
a.takeover-link {
    color: inherit;
    text-decoration: none;
}

.main-content a.takeover-link:hover,
a.takeover-link:hover {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--white);
}

a.takeover-link.accent-link:hover {
    text-decoration-color: currentColor;
}

.takeover-content > h2 {
    margin: 0 !important;
}

.takeover-content .post-metadata .tag-list {
    margin: 0 !important;
    padding: 0 !important;
}

.takeover-content .post-metadata > p {
    margin-left: 4px !important;
}

.takeover-content {
    padding: 16px 24px !important;
}

.takeover-part-badge {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 3;
    background-color: var(--white);
    color: var(--black);
    font-size: 1.2em;
    font-weight: 800;
    padding: 8px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--black) 30%, transparent);
}

/* Series List Styles */
.series-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-content a.series-card-link,
a.series-card-link {
    text-decoration: none !important;
    color: inherit;
    display: block;
}

.main-content a.series-card-link:hover,
a.series-card-link:hover {
    text-decoration: none !important;
    color: inherit;
}

.series-card {
    background: color-mix(in srgb, var(--white) 3%, transparent);
    border: 1px solid color-mix(in srgb, var(--white) 15%, transparent);
    border-radius: 12px;
    padding: 24px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
    position: relative;
    overflow: hidden;
}

.series-card.has-image {
    background-size: cover;
    background-position: center;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    border: none;
}

.series-card.has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        color-mix(in srgb, var(--black) 95%, transparent) 0%,
        color-mix(in srgb, var(--black) 70%, transparent) 50%,
        color-mix(in srgb, var(--black) 30%, transparent) 80%,
        color-mix(in srgb, var(--black) 10%, transparent) 100%
    );
    z-index: 1;
}

.series-card.has-image .series-card-content {
    position: relative;
    z-index: 2;
}

.series-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -4px var(--black-shadow);
    border-color: color-mix(in srgb, var(--white) 30%, transparent);
    background-color: color-mix(in srgb, var(--white) 6%, transparent);
}

.series-card.has-image:hover {
    box-shadow: 0 12px 32px -4px var(--black-shadow);
}

.series-card-content h2 {
    margin: 0 0 4px 0;
    font-size: 1.5em;
    font-weight: 700;
    color: var(--white);
}

.series-count {
    margin: 0 0 8px 0;
    font-size: 0.9em;
    color: var(--secondary);
    font-weight: 400;
}

.series-description {
    margin: 0 0 12px 0;
    font-size: 0.95em;
    color: color-mix(in srgb, var(--white) 85%, transparent);
    font-weight: 300;
    line-height: 1.4;
}

.series-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.series-preview-part {
    background: color-mix(in srgb, var(--white) 8%, transparent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    color: var(--white);
}

.series-card.has-image .series-preview-part {
    background: color-mix(in srgb, var(--white) 15%, transparent);
}

.series-preview span:last-child:not(.series-preview-part) {
    color: var(--secondary);
    font-size: 0.85em;
}

/* Series Header (detail page) */
.series-header {
    margin-bottom: 32px;
}

.series-header h1 {
    margin: 0;
}

.series-header.has-image {
    position: relative;
    background-size: cover;
    background-position: center;
    min-height: 350px;
    margin: -32px -32px 24px -32px;
    padding: 48px 32px 48px 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.series-header.has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--white) 10%, transparent) 0%,
        color-mix(in srgb, var(--white) 50%, transparent) 60%,
        var(--white) 100%
    );
    z-index: 0;
}

.series-header.has-image .series-header-content {
    position: relative;
    z-index: 1;
}

.series-header-content h1 {
    color: var(--black);
    font-size: 2.5em;
    font-weight: 800;
    margin: 0 0 8px 0;
}

.series-header-description {
    color: var(--secondary);
    font-size: 1.1em;
    font-weight: 300;
    margin: 0;
    line-height: 1.4;
}

.series-header:not(.has-image) .series-header-description {
    color: var(--secondary);
    margin-top: 8px;
}

.post-hero {
    margin-bottom: 16px;
}

.post-hero + h2,
.post-hero + .summary + h2 {
    margin-top: 0;
}

.post-hero.has-image {
    position: relative;
    background-size: cover;
    background-position: center;
    background-origin: padding-box;
    background-clip: padding-box;
    padding: 48px 32px 40px 32px;
    min-height: 375px;
    border-radius: 16px 16px 0 0;
    margin: -32px -32px 24px -32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.post-hero.has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px 16px 0 0;
    background: linear-gradient(
        to bottom,
        color-mix(in srgb, var(--white) 10%, transparent) 0%,
        color-mix(in srgb, var(--white) 50%, transparent) 50%,
        var(--white) 100%
    );
    z-index: 0;
}

.post-hero.has-image > * {
    position: relative;
    z-index: 1;
}

.post-hero.post-hero-dark.has-image {
    justify-content: flex-start;
    min-height: auto;
    padding: 0;
    background: none;
    position: relative;
}

.post-hero.post-hero-dark.has-image .post-hero-img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px 16px 0 0;
    position: relative;
    z-index: 0;
}

.post-hero.post-hero-dark.has-image .post-hero-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 48px 32px;
    z-index: 2;
}

.post-hero.post-hero-dark.has-image::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        var(--black) 0%,
        color-mix(in srgb, var(--black) 50%, transparent) 30%,
        transparent 60%
    );
    border-radius: 16px 16px 0 0;
    z-index: 1;
    pointer-events: none;
}

.post-hero.post-hero-dark.has-image h1,
.post-hero.post-hero-dark.has-image .post-metadata,
.post-hero.post-hero-dark.has-image .post-metadata * {
    color: var(--white);
}

.post-hero.post-hero-dark.has-image + .summary {
    margin-top: -32px;
}

.tag-list {
    margin-top: 6px;
    margin-bottom: 6px;
    color: var(--secondary);
}

.tag-list li,
.tag {
    display: inline-block;
}

.tag-list li::after {
    content: ",";
    margin-right: 4px;
}

.tag-list::before {
    content: "#";
    font-weight: 700;
    color: var(--text);
}

.post-metadata > * {
    color: var(--secondary);
    display: inline-block;
    font-size: 1em !important;
}

.post-metadata > *::after {
    content: "|";
    margin-left: 4px;
}

.main-content > .post-metadata {
    margin-top: -16px;
    font-family: 'League Spartan', sans-serif;
}

.post-metadata > *:last-child::after {
    content: "";
    margin-right: 0;
}

.post-metadata > p {
    margin-left: 4px;
}

.tag-list li:last-child::after {
    content: "";
    margin-right: 0;
}

.main-content .byline {
    font-weight: 200;
    font-size: 1.2em;
}

li .feed-item {
    border: 1px solid var(--secondary);
    padding: 20px;
    padding-bottom: 8px;
    box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
    border-radius: 8px;
    margin-bottom: 24px;
    display: flex;
    flex-direction: row;
}

.heart-button {
    display: block;
    -webkit-mask-image: url('/svg/heart.svg');
    mask-image: url('/svg/heart.svg');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background-color: var(--secondary);
    border: none;
    width: 24px;
    height: 24px;
    margin-top: 6px;
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.3s ease;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.heart-button:hover {
    background-color: var(--accent);
    transform: scale(1.1);
}

.heart-button.liked {
    -webkit-mask-image: url('/svg/heart-filled.svg');
    mask-image: url('/svg/heart-filled.svg');
    background-color: var(--accent);
}

.heart-button.animating {
    animation: heartBeat 0.5s ease;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1.1); }
    75% { transform: scale(1.25); }
    100% { transform: scale(1.2); }
}

.feed-item img:not(.feed-avatar) {
    display: block;
    border-radius: 16px;
    max-width: 512px;
    max-height: 512px;
}

.feed-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 16px;
    border: 2px solid var(--black);
    flex-shrink: 0;
}

.feed-item {
    display: flex;
    list-style: none;
    line-height: 1.2em;
    margin-left: 0;
    font-size: 1.2em;
}

.feed-item > article {
    flex-grow: 1;
    min-height: 64px;
    position: relative;
    margin-bottom: 8px;
}

.feed {
    list-style: none;
    padding: 0 96px 0 96px;
    flex-direction: column;
    display: flex;
}

.feed-item hr {
    background-color: var(--secondary);
    height: 2px;
    border: none;
    margin-bottom: 8px;
}


.feed-item > article > p {
    line-height: 1.2em;
    font-size: 1em;
}

.feed-metadata {
    flex-direction: row;
    display: flex;
    align-items: flex-end;
    margin-bottom: 2px;
}

.feed-metadata > h2 {
    font-size: 1.3em;
    font-weight: 700;
    margin-bottom: 0;
}

.feed-metadata > .feed-date {
    font-size: 0.8em;
    font-weight: 200;
    margin-left: 8px;
    margin-bottom: 0;
    line-height: normal;
}

.feed-metadata > .tag-list {
    margin-top: 0;
    margin-bottom: 0;
    margin-left: auto;
}

.feed-metadata > .tag-list::before {
    content: "#";
    font-weight: 700;
    color: var(--text);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--black-shadow);
    font-size: 1.2em;
}

.pagination-arrow {
    min-width: 1.5rem;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination a.pagination-arrow {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.pagination a.pagination-arrow:hover {
    text-decoration: underline;
}

.pagination > span {
    color: var(--secondary);
}

.item-page .tag-list {
    display: inline-block;
}

.content {
    margin-bottom: 40px;
}

.browse-all {
    display: block;
    margin-bottom: 30px;
}

.all-tags li {
    font-size: 1.4em;
    margin-right: 10px;
    margin-bottom: 10px;
    padding: 6px 10px;
    list-style: none;
}

.all-tags .tag a {
    color: var(--secondary);
    font-weight: 700;
    text-decoration: none;
}

.all-tags .tag a:hover {
    text-decoration: underline;
}

.all-tags li::before {
    display: inline-block;
    content: "#";
    width: 0.8em;
    font-weight: 900;
    margin-left: -0.8em;
}

footer {
    color: var(--secondary);
    margin: -8px 32px 16px;
    display: flex;
    justify-content: space-between;
}

footer .left-link {
    display: flex;
    gap: 8px;
    color: var(--accent);
}

footer .left-link a:nth-child(4) {
    margin-top: 4px;
}

footer .left-link a img {
    width: 24px;
}

footer .right-link {
    display: flex;
    gap: 16px;
    margin-top: auto;
    margin-bottom: auto;
    align-items: center;
}

a.secret-link {
    text-decoration: none;
}

a.secret-link:hover {
    text-decoration: underline;
}

img[src="/svg/fleuron.svg"] {
    color: var(--secondary);
}

.main-content hr:not(.feed-hr) {
    margin-top: 16px;
    margin-bottom: 16px;
}

.main-content sup {
    font-size: 0.7em;
    line-height: normal;
    margin-top: -10px;
    margin-left: 1px;
}

.main-content .footnote {
    flex-direction: row;
    display: flex;
    align-items: flex-start;
    margin-top: 10px;
    gap: 4px;
}

/* Ensure images never overflow the content width */
.main-content > img,
.main-content > p > img {
    max-width: 100%;
    height: auto;
    display: block;
}

.main-content img + p > em:only-child {
  color: var(--secondary);
  font-size: 0.8em;
  line-height: 0.8em;
  font-style: normal;
  font-weight: 200;
}

.main-content .footnote p {
    font-weight: 200;
    line-height: 1.2em;
    font-size: 1.2em;
    text-align: justify;
    color: var(--secondary);
}

.main-content .footnote .footnote-label {
    font-weight: 300;
    color: var(--text);
}

.main-content .footnote .backlink {
    font-size: 0.65em;
    margin-bottom: -5px;
    margin-left: 5px;
    font-weight: bold;
}

.main-content > h1 {
    font-family: 'League Spartan', sans-serif;
}

@media(max-width: 900px) {
    .palette-toggle {
        display: none;
    }

    .feed {
        padding: 32px 0 32px 0;
    }

    .feed-item img:not(.feed-avatar) {
        max-width: 384px;
        max-height: 384px;
    }

    .feed-metadata {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .feed-metadata > h2 {
        font-size: 1em;
        font-weight: 700;
        margin-bottom: 0;
    }
    
    .feed-metadata > .feed-date {
        font-size: 0.6em;
        font-weight: 200;
        margin-left: 0;
        margin-bottom: 0;
        line-height: normal;
    }
    
    .feed-metadata > .tag-list {
        font-size: 0.7em;
        margin-left: 0;
    }
}

@media(max-width: 600px) {

    .feed {
        padding: 0;
    }

    .takeover-essay {
        min-height: 240px;
        margin-bottom: 20px;
        border-radius: 0;
        margin-left: -16px;
        margin-right: -16px;
        width: calc(100% + 32px);
    }

    .takeover-content {
        padding: 12px 16px;
    }

    .takeover-content h2 {
        font-size: 1.8em;
    }

    .takeover-content .byline {
        font-size: 0.9em;
    }

    .series-header.has-image {
        min-height: 220px;
        border-radius: 0;
        margin: -16px -16px 16px -16px;
        padding: 24px 16px 32px 16px;
    }

    .series-header-content h1 {
        font-size: 1.8em;
    }

    .series-header-description {
        font-size: 0.95em;
    }

    /* Remove all default styling */

    .main-content aside {
        font-size: 1.2em;
        font-weight: 200;
        line-height: 1.1em;
        color: var(--secondary);
        padding: 8px;
        margin: 8px 0 16px;
        background-color: var(--black-shadow);
        border-radius: 8px;
    }

    .main-content p {
        font-size: 1em;
        line-height: 1.2em;
    }

    .feed-item > article > p {
        line-height: 1.1em;
        font-size: 0.8em;
    }

    .main-content h1 {
        font-size: 2em;
        font-weight: 800;
        letter-spacing: 0.03em;
        margin-top: 8px;
    }

    .main-content > h2:not(.wordlist h2) {
        font-size: 1.8em;
        font-weight: 700;
        margin: 16px 0 16px;
    }

    .essay-item > h2 {
        font-size: 1.3em;
    }

    .main-content h3 {
        font-size: 1.5em;
        font-weight: 700;
        margin: 12px 0 12px;
    }

    .main-content h4 {
        font-size: 1.5em;
        font-weight: 700;
        margin: 0 0 8px;
    }

    .main-content > ul:not(.picker):not(.item-list):not(.feed) > li {
        font-size: 1.1em;
    }

    .main-content > ol:not(.series-list) > li {
        font-size: 1.1em;
    }

    .tldr {
        font-size: 0.9em;
    }

    nav {
        margin-top: 8px;
        margin-left: 0;
    }
    .wrapper {
        padding: 40px 20px;
    }
    footer .right-link > :last-child {
        display: none;
    }
    .main-content {
        margin-bottom: 16px;
        margin-left: 0;
        margin-right: 0;
        padding: 16px;
        border-radius: 0;
    }

    .feed-item img:not(.feed-avatar) {
        max-width: 192px;
        max-height: 192px;
    }

    .picker {
        margin: 16px auto 0px;
        gap: 6px;
        padding: 12px;
        border-radius: 1024px;

    }
    
    .picker a {
        font-size: 1em;
    }

    .main-content > img.mini {
        width: 100%;
        margin: 16px 16px 16px 0;
    }
    
    .main-content > .image-caption {
        width: 100%;
        font-style: italic;
        font-size: 1em;
        padding: 16px 32px 16px;
        margin-bottom: 32px;
        font-weight: 200;
        color: var(--secondary);
        text-align: center;
        box-shadow: 0 10px 15px -3px var(--black-shadow), 0 4px 6px -4px var(--black-shadow);
        background-color: var(--black-shadow);
        border-radius: 8px;
    }

    .post-metadata {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
    }
    .post-metadata > * {
        display: inline-block;
        font-size: 0.8em !important;
    }

    .post-metadata > .tag-list {
        margin-bottom: 0;
        margin-top: 0;
    }

    .post-metadata {
        margin-top: 6px;
    }

    .main-content .byline {
        font-size: 1em;
    }

    .post-hero.has-image {
        margin: -16px -16px 24px -16px;
        padding: 32px 16px 48px 16px;
        min-height: 280px;
        border-radius: 0;
    }

    .post-hero.has-image::before {
        border-radius: 0;
    }

    .post-hero.post-hero-dark.has-image .post-hero-content {
        padding: 32px 16px;
    }

    .post-hero.post-hero-dark.has-image .post-hero-img {
        border-radius: 0;
    }

    .post-hero.post-hero-dark.has-image::before {
        border-radius: 0;
    }
}

/* Reading Progress Bar */
.progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    transform-origin: left;
    transform: scaleX(0);
    z-index: 100;
    pointer-events: none;
    animation: progress-grow linear;
    animation-timeline: scroll();
}

@keyframes progress-grow {
    to { transform: scaleX(1); }
}

/* Heading Anchors */
.heading-anchor {
    opacity: 0;
    color: var(--secondary);
    text-decoration: none;
    margin-left: 0.2em;
    font-weight: 400;
    transition: opacity 0.2s;
    font-size: 0.7em;
    vertical-align: middle;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus {
    opacity: 1;
}

.main-content .heading-anchor {
    color: var(--secondary);
    font-weight: 400;
}

/* Table of Contents */
.toc {
    background-color: var(--black-shadow);
    border-radius: 8px;
    padding: 16px 20px;
    margin: 4px 0 8px;
    width: fit-content;
}

.toc ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: toc;
}

.toc > ol > li {
    counter-increment: toc;
}

.toc > ol > li:not(.toc-has-prefix) > a::before {
    content: counter(toc) ". ";
    color: var(--secondary);
    font-weight: 400;
}

.toc-prefix {
    color: var(--secondary);
    font-weight: 400;
}

.toc-prefix-ps {
    font-style: italic;
    font-weight: 300;
    color: var(--secondary);
}

.toc li {
    line-height: 1.6em;
}

.toc a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    font-size: 1em;
    transition: color 0.2s;
}

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

.toc ol ol {
    padding-left: 1.2em;
}

.toc ol ol a {
    font-weight: 300;
    font-size: 0.9em;
}

.toc ol ol ol a {
    font-size: 0.85em;
}

@media (min-width: 1500px) {
    .main-content:has(.toc) {
        position: relative;
    }

    .toc {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        left: max(12px, calc((100vw - 1100px) / 2 - 280px));
        width: 240px;
        margin: 0;
        padding: 16px;
        background: transparent;
        border-radius: 0;
        --toc-progress: 0;
    }

    .toc::before {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 2px;
        background: color-mix(in srgb, var(--secondary) 30%, transparent);
    }

    .toc::after {
        content: "";
        position: absolute;
        left: 0;
        top: 0;
        width: 2px;
        height: calc(var(--toc-progress) * 100%);
        background: var(--accent);
        transition: height 0.15s linear;
    }

    .toc a {
        font-size: 0.85em;
        color: var(--secondary);
        transition: color 0.2s, font-weight 0.1s;
        display: block;
        line-height: 1.5em;
    }

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

    .toc ol ol a {
        font-size: 0.8em;
    }

    .toc li.toc-active > a {
        color: var(--white);
        font-weight: 700;
    }

    /* Hide the top progress bar when sidebar TOC is showing */
    .progress-bar {
        display: none;
    }
}

/* Tooltip Sidenotes */
@media (min-width: 1650px) {
    .main-content.has-sidenotes {
        overflow: visible;
        position: relative;
    }

    .main-content.has-sidenotes > .post-hero.has-image {
        overflow: hidden;
    }

    .main-content.has-sidenotes > .post-hero.has-image::before {
        border-radius: 16px 16px 0 0;
    }

    .main-content.has-sidenotes > .post-hero.post-hero-dark.has-image .post-hero-img {
        border-radius: 16px 16px 0 0;
    }

    .main-content.has-sidenotes > .post-hero.post-hero-dark.has-image::before {
        border-radius: 16px 16px 0 0;
    }

    .sidenote {
        position: absolute;
        top: 0;
        width: 250px;
        font-size: 0.9rem;
        font-weight: 200;
        line-height: 1.3;
        color: var(--white);
        border-left: 2px solid var(--secondary);
        padding-left: 12px;
        transition: text-shadow 0.2s;
    }

    .sidenote.highlight {
        text-shadow: 0 0 0.5px currentColor, 0 0 0.5px currentColor;
    }

    .main-content.has-sidenotes .tooltip .tooltiptext {
        display: none;
    }
}

@media(max-width: 360px) {
    footer {
        flex-direction: column;
        gap: 8px;
        justify-content: flex-start;
    }

    .feed-item img:not(.feed-avatar) {
        max-width: 128px;
        max-height: 128px;
    }

    .picker {
        margin: 8px auto 0px;
        gap: 3px;
        padding: 6px;
        border-radius: 1024px;

    }
    
    .picker a {
        font-size: 0.8em;
    }
}
