:root {
    --bg: #fafafa;
    --fg: #2e2e2e;
    --heading: #111111;
    --muted: #888888;
    --surface-1: #f0f0f0;
    --surface-2: #ffffff;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171717;
        --fg: #a1a1a1;
        --heading: #dfdfdf;
        --muted: #888888;
        --surface-1: #1a1a1a;
        --surface-2: #000000;
        --border: rgba(255, 255, 255, 0.1);
        --border-strong: rgba(255, 255, 255, 0.2);
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    color: var(--fg);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background 0.15s ease;
    padding-top: 16px;
    opacity: 0;
    animation: fade-in-up 0.5s ease-out 50ms forwards;
}

@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-from-bottom {
    0% {
        opacity: 0;
        transform: translateY(24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-in-from-top {
    0% {
        opacity: 0;
        transform: translateY(-24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-out-to-top {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-24px);
    }
}

@keyframes slide-out-to-bottom {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(24px);
    }
}

/* --- top pill nav --- */
nav {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--surface-1);
    border: 0.5px solid var(--border);
    border-radius: 999px;
    padding: 6px;
}
nav .pill-bg {
    position: absolute;
    top: 6px;
    left: 6px;
    height: calc(100% - 12px);
    border-radius: 999px;
    background: var(--surface-2);
    border: 0.5px solid var(--border-strong);
    transition:
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 0;
}
nav a {
    position: relative;
    z-index: 1;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 14px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 400;
    border: 0.5px solid transparent;
    cursor: pointer;
    transition:
        color 0.2s ease,
        font-weight 0.2s ease;
}
nav a.active {
    color: var(--heading);
    font-weight: 500;
}
nav a:not(.active):hover {
    color: var(--heading);
}

/* --- main content --- */
main {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 24px;
}

[hidden] {
    display: none !important;
}

.view-fade {
    opacity: 0;
    animation: fade-in-up 0.5s ease-out forwards;
}

#writing-content.slide-out-up {
    animation: slide-out-to-top 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
}
#writing-content.slide-out-down {
    animation: slide-out-to-bottom 0.25s cubic-bezier(0.4, 0, 1, 1) forwards;
}
#writing-content.slide-in-up {
    opacity: 0;
    animation: slide-in-from-bottom 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
#writing-content.slide-in-down {
    opacity: 0;
    animation: slide-in-from-top 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.profile {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 64px;
    max-width: 850px;
    text-align: left;
}

.profile img {
    width: 300px;
    aspect-ratio: 4 / 4.5;
    flex-shrink: 0;
    margin: 0;
    border-radius: 24px;
    object-fit: cover;
    object-position: top;
}

.profile-text {
    flex: 1;
    font-size: 21px;
    line-height: 34px;
    color: var(--muted);
    text-wrap: pretty;
}

h1 {
    font-size: 36px;
    line-height: 42px;
    font-weight: 700;
    color: var(--heading);
    margin: 0 0 28px;
}

.lede {
    margin: 0 0 28px;
}
.lede:last-child {
    margin-bottom: 0;
}

.profile-links {
    margin-top: 28px;
    display: flex;
    gap: 24px;
    font-size: 21px;
}

.profile-text a,
.profile-links a {
    position: relative;
    color: var(--heading);
    text-decoration: none;
    font-weight: 400;
}
.profile-text a::after,
.profile-links a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition:
        width 0.3s ease,
        opacity 0.2s ease;
}
.profile-text a:hover::after,
.profile-links a:hover::after {
    width: 100%;
    opacity: 1;
}

/* --- responsive breakpoints, mirroring charliedeets.com --- */
@media screen and (min-width: 1360px) {
    .profile {
        max-width: 935px;
        gap: 92px;
    }
}

@media screen and (max-width: 940px) {
    .profile {
        gap: 48px;
    }
    .profile img {
        width: 240px;
    }
}

@media screen and (max-width: 880px) {
    main {
        padding: 0 24px;
    }
    .profile {
        flex-direction: column;
        gap: 32px;
    }
    .profile img {
        width: 40%;
        min-width: 180px;
        border-radius: 16px;
    }
    .profile-text {
        font-size: 21px;
        line-height: 34px;
    }
}

@media screen and (max-width: 720px) {
    .profile-text {
        font-size: 19px;
        line-height: 30px;
    }
    h1 {
        font-size: 32px;
        line-height: 40px;
    }
    .profile-links {
        font-size: 19px;
    }
}

@media screen and (max-width: 480px) {
    body {
        padding-top: 12px;
    }
    nav a {
        padding: 8px 14px;
        font-size: 13px;
    }
    main {
        padding: 0 16px;
    }
    .writing-list a {
        font-size: 18px;
        line-height: 26px;
    }
    .writing-list .excerpt {
        font-size: 15px;
        line-height: 22px;
    }
    .profile {
        gap: 20px;
    }
    .profile img {
        width: 32%;
        min-width: 140px;
        border-radius: 14px;
    }
    .profile-text {
        font-size: 16px;
        line-height: 24px;
    }
    h1 {
        font-size: 26px;
        line-height: 32px;
        margin-bottom: 16px;
    }
    .lede {
        margin-bottom: 16px;
    }
    .profile-links {
        margin-top: 16px;
        font-size: 16px;
    }
}

/* --- writing list --- */
.writing-list {
    max-width: 680px;
    width: 100%;
}

.writing-list h1 {
    margin-bottom: 28px;
}

.writing-list ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.writing-list li {
    margin-bottom: 28px;
}
.writing-list li:last-child {
    margin-bottom: 0;
}

.writing-list a {
    position: relative;
    display: inline-block;
    font-size: 21px;
    line-height: 30px;
    color: var(--heading);
    text-decoration: none;
    font-weight: 400;
}
.writing-list a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 0;
    height: 1px;
    background: currentColor;
    opacity: 0;
    transition:
        width 0.3s ease,
        opacity 0.2s ease;
}
.writing-list a:hover::after {
    width: 100%;
    opacity: 1;
}

.writing-list .date {
    display: block;
    font-size: 15px;
    line-height: 22px;
    color: var(--muted);
    margin-top: 6px;
    margin-bottom: 4px;
    font-family:
        ui-monospace, "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono",
        Menlo, monospace;
}

.writing-list .excerpt {
    margin: 6px 0 0;
    font-size: 17px;
    line-height: 26px;
    color: var(--muted);
}

/* --- post preview overlay (Arc-style peek) --- */
.preview-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.preview-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.preview-card {
    width: 88vw;
    height: 88vh;
    max-width: 920px;
    background: var(--surface-2);
    border: 0.5px solid var(--border-strong);
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.preview-overlay.open .preview-card {
    transform: scale(1) translateY(0);
}
.preview-toolbar {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--border);
    flex-shrink: 0;
}
.stoplight {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: filter 0.15s ease;
}
.stoplight-red {
    background: #ff5f57;
}
.stoplight-yellow {
    background: #febc2e;
}
.stoplight-green {
    background: #28c840;
}
.stoplight:hover {
    filter: brightness(0.9);
}
.stoplight:active {
    filter: brightness(0.8);
}
.stoplight::before {
    content: "";
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: 7px 7px;
    opacity: 0;
    transition: opacity 0.1s ease;
}
.preview-toolbar:hover .stoplight-red::before {
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2.5 2.5l5 5M7.5 2.5l-5 5' stroke='rgba(0,0,0,0.6)' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.preview-toolbar:hover .stoplight-yellow::before {
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M1 5h8' stroke='rgba(0,0,0,0.6)' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
}
.preview-toolbar:hover .stoplight-green::before {
    opacity: 1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Cpath d='M2 8L8 2M8 6V2H4' stroke='rgba(0,0,0,0.6)' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.preview-body {
    flex: 1;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 40px 56px;
    color: var(--fg);
    font-size: 17px;
    line-height: 1.6;
}
.preview-body h1,
.preview-body h2,
.preview-body h3 {
    color: var(--heading);
}
.preview-body a {
    position: relative;
    color: var(--heading);
    text-decoration: none;
    font-weight: 500;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition:
        background-size 0.3s ease,
        color 0.2s ease;
}
.preview-body a:hover {
    color: var(--muted);
    background-size: 100% 1px;
}
.preview-body sup a,
.preview-body sup a:hover {
    background-image: none;
    color: var(--muted);
    font-size: 0.7em;
    font-weight: 600;
    padding: 0 2px;
}
.preview-body sup a:hover {
    color: var(--heading);
}
.preview-body ol.footnotes {
    margin-top: 24px;
    padding-top: 8px;
    font-size: 14px;
    color: var(--muted);
}
.preview-body ol.footnotes li {
    margin-bottom: 10px;
}

@media screen and (max-width: 720px) {
    .preview-card {
        width: 94vw;
        height: 90vh;
    }
    .preview-body {
        padding: 24px 20px;
    }
}

/* --- right-side month nav, desktop only --- */
.month-nav {
    position: fixed;
    right: 48px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}
.month-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.month-nav li a {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    line-height: 1;
    color: var(--muted);
    text-decoration: none;
    font-weight: 400;
    white-space: nowrap;
    transition:
        color 0.2s ease,
        font-weight 0.2s ease;
}
.month-nav li a::before {
    content: "";
    display: inline-block;
    width: 16px;
    height: 1px;
    background: currentColor;
    transition:
        width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        height 0.2s ease,
        background 0.2s ease;
}
.month-nav li a.active {
    color: var(--heading);
    font-weight: 600;
    font-size: 14px;
}
.month-nav li a.active::before {
    width: 32px;
    height: 2px;
    background: var(--heading);
}
.month-nav li a:not(.active):hover {
    color: var(--heading);
}

@media screen and (max-width: 880px) {
    .month-nav {
        display: none !important;
    }
}

@media screen and (max-width: 720px) {
    .writing-list a {
        font-size: 19px;
        line-height: 28px;
    }
    .writing-list .excerpt {
        font-size: 16px;
        line-height: 24px;
    }
}

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