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

* {
    margin: 0;
    padding: 0;
}

:root {
    --color-bg: #f6f4ed;
    --color-text: #21201c;
    --color-accent: #00693e;
    --color-muted: #77746a;
    --color-hairline: #e4e1d6;
    --color-surface: #fdfcf8;
    --color-surface-strong: #eeeadf;
    --color-shine: rgba(0, 105, 62, 0.48);
    --font-mono: "Courier Prime", "Courier New", Courier, monospace;
    --font-serif: "IBM Plex Serif", Georgia, serif;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --container: 680px;
}

html.dark-mode {
    --color-bg: #141412;
    --color-text: #d6d3c9;
    --color-accent: #5aba7a;
    --color-muted: #8b8878;
    --color-hairline: #2a2a26;
    --color-surface: #1b1b18;
    --color-surface-strong: #24241f;
    --color-shine: rgba(90, 186, 122, 0.38);
}

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

html {
    min-height: 100%;
    scrollbar-gutter: stable;
}

body {
    min-height: 100%;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 16px;
    line-height: 1.6;
    transition: background-color 0.2s ease, color 0.2s ease;
}

body.home {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
}

a {
    color: var(--color-accent);
    text-decoration: none;
    text-underline-offset: 0.18em;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

img {
    max-width: 100%;
    height: auto;
}

.container {
    width: 100%;
    max-width: var(--container);
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
}

body.home .container {
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
}

header {
    flex: 0 0 auto;
    margin-bottom: var(--space-8);
}

main {
    flex: 1 1 auto;
}

footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-hairline);
    padding: 12px 0;
    color: var(--color-muted);
    font-size: 0.8rem;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
}

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

#footer-email {
    color: var(--color-muted);
}

.footer-email:hover,
.footer-email:focus-visible {
    color: var(--color-accent);
}

.built-in {
    color: var(--color-muted);
    white-space: nowrap;
}

#built-in-text {
    color: var(--color-muted);
}

.footer-location {
    position: relative;
    display: inline-block;
    overflow: hidden;
    cursor: default;
}

.footer-location::before {
    content: "> ";
    color: var(--color-accent);
}

.footer-location::after {
    content: "";
    position: absolute;
    top: 0;
    left: -70%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--color-shine), transparent);
    transform: skewX(-15deg);
    pointer-events: none;
}

.footer-location:hover::after {
    animation: shine 0.7s ease forwards;
}

@keyframes shine {
    from {
        left: -70%;
    }

    to {
        left: 150%;
    }
}

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

.back-link {
    display: inline-block;
    margin-bottom: var(--space-5);
    color: var(--color-muted);
    font-size: 0.9rem;
    line-height: 1.2;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--color-accent);
}

.site-name {
    min-height: 1.1em;
    color: var(--color-text);
    font-size: clamp(2.2rem, 9vw, 3.15rem);
    font-weight: 400;
    line-height: 1.05;
}

#site-name {
    overflow-wrap: anywhere;
}

.page-title {
    color: var(--color-text);
    font-size: 1.6rem;
    font-weight: 400;
    line-height: 1.2;
}

.cursor {
    animation: blink 1s step-end infinite;
    color: var(--color-accent);
}

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

    51%,
    100% {
        opacity: 0;
    }
}

section {
    margin-bottom: var(--space-10);
}

h2 {
    margin-bottom: var(--space-3);
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.3;
    text-transform: uppercase;
}

p {
    color: var(--color-text);
    line-height: 1.75;
}

ul {
    list-style: none;
}

li {
    margin-bottom: var(--space-3);
    color: var(--color-text);
}

.note {
    display: block;
    margin-top: 2px;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.date,
.writing-date {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.writing-list {
    display: grid;
    gap: var(--space-3);
}

.writing-item {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: baseline;
    gap: var(--space-4);
    margin: 0;
}

.home-main {
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.home-nav {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(18px, 4.4vh, 34px);
    padding: var(--space-5) 0;
}

.index-section {
    margin: 0;
}

.index-section h2 {
    margin: 0;
    font-size: 0.98rem;
    letter-spacing: 0.06em;
}

.index-section a {
    color: var(--color-accent);
}

.about-row {
    display: flex;
    align-items: flex-start;
    gap: var(--space-6);
}

.profile-photo {
    width: 160px;
    flex: 0 0 auto;
    border: 1px solid var(--color-hairline);
    border-radius: 4px;
    filter: grayscale(100%);
}

.about-text {
    line-height: 1.8;
}

@media (max-width: 680px) {
    .about-row {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .container {
        padding-right: 18px;
        padding-left: 18px;
    }

    .footer-content {
        align-items: flex-start;
        flex-direction: column;
        gap: var(--space-1);
    }

    .built-in {
        white-space: normal;
    }

    .writing-item {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

.scraps-page .container {
    max-width: 920px;
}

.scraps-page header.scraps-header {
    margin-bottom: var(--space-6);
}

.scraps-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-3) var(--space-4);
}

.scraps-title-main {
    display: inline-block;
    transform: rotate(-1.2deg);
}

.scraps-title-xout {
    position: relative;
    color: var(--color-muted);
    font-size: 0.85rem;
    font-weight: 400;
    letter-spacing: 0.04em;
    text-transform: lowercase;
    opacity: 0.7;
}

a.scraps-title-xout {
    cursor: pointer;
}

a.scraps-title-xout:hover,
a.scraps-title-xout:focus-visible {
    text-decoration: none;
}

.scraps-title-xout::after {
    content: "";
    position: absolute;
    left: -4%;
    top: 52%;
    width: 108%;
    height: 2px;
    background: var(--color-accent);
    transform: rotate(-6deg);
    opacity: 0.85;
}

.scraps-lede {
    margin-top: var(--space-3);
    max-width: 36em;
    color: var(--color-muted);
    font-size: 0.95rem;
    line-height: 1.55;
    transform: rotate(0.4deg);
}

.scraps-desk {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-5) var(--space-4);
    padding: var(--space-2) 0 var(--space-8);
    align-items: start;
}

.scrap {
    position: relative;
    min-width: 0;
    /* --nudge and --tilt are set per-card by assets/scraps.js. The fallbacks
       (0) keep things sane if the script hasn't run. */
    margin: var(--nudge, 0) 0 0;
    padding: var(--space-4) var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-hairline);
    border-radius: 2px;
    box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.04);
    transform: rotate(var(--tilt, 0deg));
    transition: transform 0.18s ease, border-color 0.15s ease, box-shadow 0.18s ease;
}

/* A card that takes a whole row on its own — a visual breather. */
.scrap--wide {
    grid-column: 1 / -1;
}

.scrap--wide-center {
    max-width: 72%;
    justify-self: center;
}

.scrap--wide-right {
    max-width: 85%;
    justify-self: end;
}

.scrap:hover,
.scrap:focus-within {
    z-index: 2;
    border-color: var(--color-accent);
    box-shadow: 2px 6px 0 rgba(0, 0, 0, 0.06);
    transform: rotate(0deg) translateY(-3px);
}

.scrap--tape::before {
    content: "";
    position: absolute;
    top: -8px;
    left: 50%;
    width: 42%;
    height: 16px;
    background: color-mix(in srgb, var(--color-accent) 22%, var(--color-surface-strong));
    border: 1px solid color-mix(in srgb, var(--color-accent) 35%, transparent);
    transform: translateX(-50%) rotate(-2deg);
    opacity: 0.9;
    pointer-events: none;
}

.scrap--dashed {
    border-style: dashed;
    border-color: var(--color-muted);
    background: transparent;
}

.scrap--quote {
    background: var(--color-surface-strong);
    border-left: 3px solid var(--color-accent);
}

.scrap--music {
    border-style: dashed;
}

.scrap--thought {
    border-style: dashed;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 27px,
            color-mix(in srgb, var(--color-hairline) 80%, transparent) 28px
        );
    background-color: var(--color-surface);
}

.scrap--sm {
    padding: var(--space-3) var(--space-4);
    font-size: 0.95rem;
}

.scrap--tall {
    padding-bottom: var(--space-8);
}

.scrap-tag {
    display: inline-block;
    margin-bottom: var(--space-2);
    padding: 1px 7px;
    border: 1px solid var(--color-hairline);
    border-radius: 999px;
    background: var(--color-bg);
    color: var(--color-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: lowercase;
    transform: rotate(-3deg);
}

.scrap-title {
    display: block;
    color: var(--color-text);
    font-size: 1.05rem;
    font-weight: 400;
    line-height: 1.35;
    word-break: break-word;
}

a.scrap-title {
    color: var(--color-accent);
}

a.scrap-title:hover,
a.scrap-title:focus-visible {
    text-decoration: underline;
}

.scrap--quote .scrap-title {
    font-size: 1.15rem;
    font-style: italic;
}

.scrap-note {
    margin-top: var(--space-2);
    color: var(--color-muted);
    font-size: 0.85rem;
    font-style: italic;
    line-height: 1.5;
}

.scrap-ghost-link {
    display: inline-block;
    margin-top: var(--space-3);
    color: var(--color-muted);
    font-size: 0.8rem;
}

.scrap-ghost-link:hover,
.scrap-ghost-link:focus-visible {
    color: var(--color-accent);
}

html.dark-mode .scrap {
    box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.25);
}

html.dark-mode .scrap:hover,
html.dark-mode .scrap:focus-within {
    box-shadow: 2px 6px 0 rgba(0, 0, 0, 0.35);
}

html.dark-mode .scrap--tape::before {
    background: color-mix(in srgb, var(--color-accent) 28%, var(--color-surface-strong));
    border-color: color-mix(in srgb, var(--color-accent) 40%, transparent);
}

@media (max-width: 680px) {
    .scraps-page .container {
        max-width: var(--container);
    }

    .scraps-desk {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    /* One column on mobile: full width, no vertical nudge, and only a soft
       tilt (40% of the desktop value) so the stack stays readable. */
    .scrap {
        max-width: none;
        margin-top: 0;
        justify-self: stretch;
        transform: rotate(calc(var(--tilt, 0deg) * 0.4));
    }

    .scrap--wide {
        grid-column: auto;
    }

    .scrap:hover,
    .scrap:focus-within {
        transform: rotate(0deg) translateY(-2px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .scrap {
        transition: none;
    }

    .scrap:hover,
    .scrap:focus-within {
        transform: none;
        box-shadow: 1px 2px 0 rgba(0, 0, 0, 0.04);
    }
}
