/* ==========================================================================
   heind.nl, paper edition
   Cream paper, ink, tape and a bit of stop-motion.

   1. Tokens          5. Home            9. Photos
   2. Base            6. Blog            10. 404
   3. Header/footer   7. Article         11. Motion
   4. Shared bits     8. Post content    12. Responsive / reduced motion
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    --paper: #f2ecdf;
    --paper-2: #e9e2d3;
    --card: #fbf8f1;
    --ink: #22201c;
    --pencil: #6a6357;
    --line: #cbc0ab;
    --dot: #d5cab5;
    --red: #c23b1f;
    --blue: #2445b0;
    --green: #2c6e46;
    --hl: #f5d94e;
    --tape: rgba(226, 207, 150, 0.72);
    --sticky: #f6e27f;
    --sticky-ink: #2a2516;
    --peg: #c49a63;
    --shadow: rgba(70, 52, 20, 0.22);
    --grain-opacity: 0.45;
    --grain-blend: multiply;

    --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
    --mono: "Courier Prime", "Courier New", ui-monospace, monospace;
    --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;

    --max: 1040px;
    --gutter: clamp(16px, 4vw, 40px);
    --lift: 0 1px 1px rgba(0, 0, 0, 0.06), 0 14px 22px -16px var(--shadow);
    --stamp-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='70'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' seed='7'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 2.35'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #1d1b18;
        --paper-2: #24211d;
        --card: #292622;
        --ink: #ece5d6;
        --pencil: #a69e8f;
        --line: #4b453c;
        --dot: #36322c;
        --red: #ff8159;
        --blue: #9db2ff;
        --green: #7fcf9c;
        --hl: rgba(245, 217, 78, 0.32);
        --tape: rgba(190, 175, 130, 0.38);
        --sticky: #4f4626;
        --sticky-ink: #f1e8c8;
        --peg: #8d6c43;
        --shadow: rgba(0, 0, 0, 0.55);
        --grain-opacity: 0.12;
        --grain-blend: screen;
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --paper: #1d1b18;
    --paper-2: #24211d;
    --card: #292622;
    --ink: #ece5d6;
    --pencil: #a69e8f;
    --line: #4b453c;
    --dot: #36322c;
    --red: #ff8159;
    --blue: #9db2ff;
    --green: #7fcf9c;
    --hl: rgba(245, 217, 78, 0.32);
    --tape: rgba(190, 175, 130, 0.38);
    --sticky: #4f4626;
    --sticky-ink: #f1e8c8;
    --peg: #8d6c43;
    --shadow: rgba(0, 0, 0, 0.55);
    --grain-opacity: 0.12;
    --grain-blend: screen;
    color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--serif);
    font-size: clamp(17px, 1.05rem + 0.2vw, 19px);
    line-height: 1.6;
    color: var(--ink);
    background-color: var(--paper);
    background-image: radial-gradient(var(--dot) 1.1px, transparent 1.4px);   /* dot-grid notebook */
    background-size: 24px 24px;
    background-position: 12px 12px;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
}

body::after {   /* paper grain */
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    opacity: var(--grain-opacity);
    mix-blend-mode: var(--grain-blend);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .45 0 0 0 0 .38 0 0 0 0 .28 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E");
}

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

a {
    color: var(--blue);
    text-decoration: underline wavy;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    text-decoration-color: color-mix(in srgb, var(--blue) 45%, transparent);
}
a:hover { text-decoration-color: var(--blue); }

:focus-visible { outline: 2px dashed var(--red); outline-offset: 4px; border-radius: 2px; }
::selection { background: var(--hl); color: var(--ink); }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.hand { font-family: var(--hand); font-weight: 500; }
.mono { font-family: var(--mono); }
.boil { filter: url(#boil); }
.loading { color: var(--pencil); font-size: 1.5rem; list-style: none; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.skip {
    position: absolute;
    left: 12px;
    top: -60px;
    z-index: 200;
    background: var(--card);
    padding: 8px 12px;
    font-family: var(--mono);
}
.skip:focus { top: 12px; }

main { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- 3. Header / footer ---------- */
.top {
    max-width: var(--max);
    margin: 0 auto;
    padding: 22px var(--gutter) 0;
    display: flex;
    align-items: baseline;
    gap: 12px 28px;
    flex-wrap: wrap;
    font-family: var(--mono);
    font-size: 15px;
    position: relative;
    z-index: 5;
}
.logo {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 20px;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.logo span { color: var(--red); animation: blink 1.1s steps(1) infinite; }

.top nav { display: flex; flex-wrap: wrap; gap: 4px 18px; flex: 1; }
.top nav a { color: var(--ink); text-decoration: none; position: relative; }
.top nav a::after {
    content: "";
    position: absolute;
    left: -2px; right: -2px; bottom: 1px;
    height: 7px;
    background: var(--hl);
    z-index: -1;
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s steps(4);
}
.top nav a:hover::after, .top nav a:focus-visible::after, .top nav a[aria-current="page"]::after { transform: scaleX(1); }

.lights {
    font: inherit;
    font-size: 14px;
    color: var(--pencil);
    background: none;
    border: 1.5px dashed var(--line);
    padding: 2px 10px;
    cursor: pointer;
    border-radius: 3px;
}
.lights:hover { color: var(--ink); border-color: var(--pencil); }

.foot {
    max-width: var(--max);
    margin: 60px auto 0;
    padding: 26px var(--gutter) 40px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--pencil);
    text-align: center;
}
.foot p { margin: 4px 0; }

/* ---------- 4. Shared bits ---------- */
.section { padding: 24px 0 40px; scroll-margin-top: 20px; }

.sec-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 26px; }
.sec-head h2, .postcard h2, .page-head h1 {
    font-weight: 500;
    font-size: clamp(2rem, 1.4rem + 2.4vw, 2.9rem);
    line-height: 1.1;
    margin: 0;
    letter-spacing: -0.015em;
}
.sec-num {
    font-family: var(--mono);
    font-size: 0.42em;
    color: var(--red);
    vertical-align: 0.55em;
    margin-right: 4px;
}

.page-head { padding: clamp(36px, 6vw, 70px) 0 30px; }
.page-head h1 { font-size: clamp(2.6rem, 1.6rem + 4.2vw, 4.4rem); line-height: 1.02; letter-spacing: -0.025em; }
.page-head p { margin: 12px 0 0; color: var(--pencil); }
.page-head .hand { font-size: 1.6rem; color: var(--pencil); transform: rotate(-1.5deg); transform-origin: left; }

/* "cut here" divider */
.cut {
    max-width: var(--max);
    margin: 30px auto;
    border-top: 2px dashed var(--line);
    position: relative;
    height: 0;
}
.cut span {
    position: absolute;
    left: 8%;
    top: -0.78em;
    font-size: 22px;
    line-height: 1;
    color: var(--pencil);
    background: var(--paper);
    padding: 0 6px;
    font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif;
}
.cut.in span { animation: snip 1.6s steps(8) 1 both; }

/* polaroid + tape */
.polaroid {
    margin: 0;
    background: var(--card);
    padding: 12px 12px 10px;
    box-shadow: var(--lift);
    transform: rotate(var(--r, 0deg));
    position: relative;
    max-width: 340px;
}
.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; filter: saturate(0.85) contrast(1.03); }
.polaroid figcaption { text-align: center; font-family: var(--hand); font-size: 1.6rem; padding-top: 6px; color: var(--ink); line-height: 1.2; }

.taped::before, .polaroid::before, .card::before {
    content: "";
    position: absolute;
    top: -13px;
    left: var(--tx, 50%);
    width: 96px;
    height: 26px;
    margin-left: -48px;
    background: var(--tape);
    transform: rotate(var(--ta, -3deg));
    clip-path: polygon(0 8%, 4% 0, 9% 10%, 15% 0, 100% 0, 96% 12%, 100% 26%, 95% 44%, 100% 60%, 96% 78%, 100% 100%, 8% 100%, 3% 88%, 0 72%, 5% 55%, 0 38%, 4% 22%);
    z-index: 2;
    pointer-events: none;
}

/* sticky note */
.sticky {
    position: relative;
    max-width: 250px;
    background: var(--sticky);
    color: var(--sticky-ink);
    padding: 16px 18px;
    font-family: var(--hand);
    font-size: 1.32rem;
    line-height: 1.2;
    transform: rotate(var(--r, -3deg));
    box-shadow: 0 16px 18px -14px var(--shadow);
    z-index: 3;
}
.sticky::after {   /* curled corner */
    content: "";
    position: absolute;
    right: 0; bottom: 0;
    width: 26px; height: 26px;
    background: linear-gradient(135deg, var(--sticky) 45%, color-mix(in srgb, var(--sticky) 70%, #000) 50%, var(--paper) 56%);
}
.sticky a { color: inherit; text-decoration-color: currentColor; }

/* stamp-style filter chips */
.filters { display: flex; flex-wrap: wrap; gap: 10px 12px; margin-bottom: 34px; }
.chip {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--pencil);
    background: transparent;
    border: 2px solid currentColor;
    border-radius: 3px;
    padding: 4px 10px;
    cursor: pointer;
    transform: rotate(var(--r, -1deg));
}
.chip:nth-child(2) { --r: 1.2deg; }
.chip:nth-child(3) { --r: -0.6deg; }
.chip:nth-child(4) { --r: 1.6deg; }
.chip:hover { color: var(--ink); }
.chip.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* rubber stamp */
.stamp {
    position: absolute;
    top: 22px;
    right: 6px;
    z-index: 3;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 2px 7px;
    border: 2.5px solid currentColor;
    border-radius: 4px;
    background: color-mix(in srgb, var(--card) 82%, transparent);
    transform: rotate(var(--sr, -7deg));
    -webkit-mask-image: var(--stamp-mask);
    mask-image: var(--stamp-mask);
    -webkit-mask-size: 140px 70px;
    mask-size: 140px 70px;
}
.stamp[data-type="human"] { color: var(--blue); }
.stamp[data-type="partial-ai"] { color: var(--green); }
.stamp[data-type="full-ai"] { color: var(--red); }

.tag {
    display: inline-block;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--pencil);
    border: 1.5px dashed var(--line);
    border-radius: 3px;
    padding: 0 6px;
    margin: 0 6px 6px 0;
}

/* chunky printed button */
.btn, .more {
    font-family: var(--mono);
    font-weight: 700;
    font-size: 15px;
    color: var(--ink);
    background: var(--card);
    border: 2px solid var(--ink);
    border-radius: 4px;
    padding: 9px 18px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    box-shadow: 3px 3px 0 var(--ink);
    transition: transform 0.12s steps(2), box-shadow 0.12s steps(2);
}
.btn:hover, .more:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active, .more:active { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.btn-small { font-size: 13px; padding: 5px 12px; box-shadow: 2px 2px 0 var(--ink); }

/* plain text button (looks like a link) */
.textbtn {
    font: inherit;
    font-family: var(--mono);
    font-size: 14px;
    color: var(--blue);
    background: none;
    border: 0;
    padding: 2px 0;
    cursor: pointer;
    text-decoration: underline wavy;
    text-decoration-color: color-mix(in srgb, var(--blue) 45%, transparent);
    text-underline-offset: 3px;
}
.textbtn:hover { text-decoration-color: var(--blue); }

/* table of contents list (home + related posts) */
.toc { list-style: none; margin: 0; padding: 0; max-width: 820px; counter-reset: toc; }
.toc li { padding: 14px 0; border-bottom: 1px solid var(--line); counter-increment: toc; }
.toc li:first-child { border-top: 1px solid var(--line); }
.toc a { display: flex; align-items: baseline; gap: 10px; color: var(--ink); text-decoration: none; }
.toc a::before {
    content: counter(toc, decimal-leading-zero);
    font-family: var(--mono);
    font-size: 13px;
    color: var(--red);
    flex: none;
}
.toc-title {
    font-size: 1.28rem;
    line-height: 1.25;
    background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 85% / 0% 40%;
    transition: background-size 0.3s steps(5);
}
.toc a:hover .toc-title, .toc a:focus-visible .toc-title { background-size: 100% 40%; }
.toc-dots { flex: 1; min-width: 20px; border-bottom: 2px dotted var(--line); transform: translateY(-5px); }
.toc time { font-family: var(--mono); font-size: 13px; color: var(--pencil); white-space: nowrap; flex: none; }

/* ---------- 5. Home ---------- */
.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 40px 56px;
    align-items: center;
    padding: clamp(40px, 7vw, 80px) 0 30px;
    position: relative;
}
h1 {
    font-weight: 500;
    font-size: clamp(2.6rem, 1.6rem + 4.6vw, 4.9rem);
    line-height: 1.02;
    letter-spacing: -0.025em;
    margin: 0 0 26px;
}
.name { position: relative; white-space: nowrap; display: inline-block; }
.scribble {
    position: absolute;
    left: -2%;
    bottom: -0.18em;
    width: 104%;
    height: 0.32em;
    overflow: visible;
}
.scribble path {
    fill: none;
    stroke: var(--red);
    stroke-width: 4;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 420;
    stroke-dashoffset: 420;
    animation: draw 0.9s steps(9) 0.7s forwards;
}

.lede { font-size: 1.22em; max-width: 34ch; margin: 0 0 22px; }

.hl {
    color: inherit;
    background: linear-gradient(100deg, transparent 0.4%, var(--hl) 1.5%, var(--hl) 97%, transparent 99%);
    background-repeat: no-repeat;
    background-size: 0% 72%;
    background-position: 0 70%;
    padding: 0 2px;
    animation: marker 0.8s steps(8) 1.3s forwards;
}

.mood { font-size: 2rem; margin: 0; transform: rotate(-2deg); transform-origin: left; }
.mood-word { color: var(--blue); font-weight: 700; position: relative; display: inline-block; }
.mood-word::after {   /* the strike-through pen line */
    content: "";
    position: absolute;
    left: -4px;
    right: -4px;
    top: 54%;
    height: 3px;
    background: var(--red);
    border-radius: 2px;
    transform: scaleX(0) rotate(-3deg);
    transform-origin: left;
}
.mood-word.striking::after { animation: strike 0.45s steps(5) forwards; }
.mood-word.writing { animation: write 0.7s steps(7) both; }

.hero-side { position: relative; padding-top: 6px; }
.hero-photo { margin-left: auto; }
.hero-side .sticky { margin: 18px 0 0 -14px; max-width: 220px; }
.sticky-title { margin: 0 0 6px; font-weight: 700; font-size: 1.5rem; }
.sticky ul { margin: 0; padding: 0; list-style: none; }
.sticky li { padding-left: 18px; position: relative; margin: 4px 0; }
.sticky li::before { content: "~"; position: absolute; left: 0; font-weight: 700; }

/* project cards */
.cards {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
    gap: 46px 30px;
}
.card {
    position: relative;
    background: var(--card);
    padding: 12px 12px 18px;
    box-shadow: var(--lift);
    transform: rotate(var(--r, 0deg));
    transition: transform 0.24s steps(3), box-shadow 0.24s steps(3);
    display: flex;
    flex-direction: column;
}
.card:hover, .card:focus-within {
    transform: rotate(0deg) translateY(-6px);
    box-shadow: 0 1px 1px rgba(0,0,0,0.06), 0 22px 30px -18px var(--shadow);
    z-index: 4;
}
.card::before { width: 78px; margin-left: -39px; height: 22px; top: -11px; }

.shot { display: block; position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--paper); }
.shot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: saturate(0.7) sepia(0.14) contrast(1.02);
    transition: filter 0.3s steps(3);
}
.card:hover .shot img { filter: none; }
.noimg { background: repeating-linear-gradient(-45deg, var(--line) 0 2px, transparent 2px 9px) !important; }

.card h3 { font-weight: 500; font-size: 1.42rem; line-height: 1.15; margin: 14px 0 6px; letter-spacing: -0.01em; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card h3 a::after { content: ""; position: absolute; inset: 0; z-index: 1; }   /* whole card is clickable */
.card p { margin: 0; }
.card-desc {
    color: var(--pencil);
    font-size: 0.95em;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    margin-top: auto !important;
    padding-top: 14px;
    font-family: var(--mono);
    font-size: 13px;
    color: var(--pencil);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.card-links { display: flex; gap: 14px; position: relative; z-index: 2; }
.card-links a { font-weight: 700; }

.more-wrap { text-align: center; margin: 44px 0 0; }
.all-posts { margin: 22px 0 0; font-family: var(--mono); font-size: 15px; }

/* about */
.about {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 40px 56px;
    align-items: start;
}
.letter {
    background: var(--card);
    padding: 28px 30px 24px 52px;
    position: relative;
    box-shadow: var(--lift);
    transform: rotate(-0.6deg);
    background-image:   /* red margin + ruled lines */
        linear-gradient(90deg, transparent 34px, color-mix(in srgb, var(--red) 45%, transparent) 34px, color-mix(in srgb, var(--red) 45%, transparent) 35.5px, transparent 35.5px),
        repeating-linear-gradient(transparent 0 29px, color-mix(in srgb, var(--blue) 14%, transparent) 29px 30px);
    background-position: 0 0, 0 14px;
    line-height: 30px;
}
.letter p { margin: 0 0 30px; }
.letter .sign { font-size: 2.2rem; color: var(--blue); margin: -6px 0 0; transform: rotate(-4deg); display: inline-block; }

.pencilcase h3 { font-size: 1.9rem; margin: 0 0 16px; color: var(--ink); line-height: 1.1; transform: rotate(-1deg); }
.tools { list-style: none; margin: 0; padding: 0; }
.tools li {
    display: grid;
    grid-template-columns: 96px 1fr;
    column-gap: 14px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--line);
}
.tool-name { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.tool-bar { height: 12px; position: relative; border: 1.5px solid var(--pencil); border-radius: 2px 6px 3px 5px; }
.tool-bar span {
    position: absolute;
    inset: 1.5px auto 1.5px 1.5px;
    width: 0;
    max-width: calc(100% - 3px);
    background: repeating-linear-gradient(-58deg, var(--red) 0 2px, transparent 2px 5px);
    transition: width 0.9s steps(9);
}
.pencilcase.in .tool-bar span { width: var(--p); }

/* postcard */
.postcard {
    background: var(--card);
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    padding: clamp(22px, 4vw, 40px);
    gap: 28px clamp(22px, 4vw, 44px);
    box-shadow: 0 1px 1px rgba(0,0,0,0.06), 0 22px 34px -20px var(--shadow);
    transform: rotate(0.7deg);
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    border: 8px solid transparent;   /* airmail edge */
    border-image: repeating-linear-gradient(-45deg, var(--red) 0 12px, var(--card) 12px 22px, var(--blue) 22px 34px, var(--card) 34px 44px) 8;
}
.pc-message .btn { margin-top: 22px; }
.pc-address { border-left: 2px solid var(--line); padding-left: clamp(18px, 3vw, 36px); position: relative; padding-top: 118px; }
.pc-stamp {
    position: absolute;
    top: 0;
    right: 0;
    width: 82px;
    height: 98px;
    padding: 6px;
    background: var(--paper);
    outline: 4px dotted var(--card);   /* perforated edge */
    outline-offset: -2px;
    box-shadow: 0 6px 10px -6px var(--shadow);
    transform: rotate(4deg);
}
.pc-stamp-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: var(--red);
    color: var(--card);
    font-family: var(--mono);
    font-weight: 700;
    font-size: 15px;
}
.pc-stamp-inner span { color: var(--hl); }
.pc-stamp-inner small { font-size: 11px; margin-top: 6px; letter-spacing: 0.2em; }
.postmark { position: absolute; top: 34px; right: 70px; width: 120px; height: 70px; transform: rotate(-12deg); opacity: 0.75; }
.postmark circle, .postmark path { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.pc-lines { list-style: none; margin: 0; padding: 0; }
.pc-lines li { border-bottom: 1.5px solid var(--line); padding: 10px 0 4px; display: flex; gap: 12px; align-items: baseline; min-width: 0; }
.pc-lines .mono { font-size: 12px; color: var(--pencil); text-transform: uppercase; letter-spacing: 0.1em; width: 38px; flex: none; }
.pc-lines a { overflow-wrap: anywhere; }

/* ---------- 6. Blog ---------- */
.posts { list-style: none; margin: 0; padding: 0; display: grid; gap: 44px; max-width: 900px; }
.post {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px 34px;
    align-items: start;
    position: relative;
}
.post-shot {
    display: block;
    background: var(--card);
    padding: 8px 8px 22px;
    box-shadow: var(--lift);
    transform: rotate(var(--r, -1.5deg));
    position: relative;
    transition: transform 0.24s steps(3);
}
.post-shot::before { width: 70px; margin-left: -35px; height: 20px; top: -10px; }
.post-shot img { aspect-ratio: 4 / 3; width: 100%; object-fit: cover; filter: saturate(0.75) sepia(0.12); }
.post:hover .post-shot { transform: rotate(0deg) translateY(-4px); }
.post-date { font-family: var(--mono); font-size: 13px; color: var(--pencil); margin: 0; }
.post h2 { font-weight: 500; font-size: clamp(1.45rem, 1.2rem + 1vw, 1.9rem); line-height: 1.15; margin: 4px 0 8px; letter-spacing: -0.01em; }
.post h2 a { color: var(--ink); text-decoration: none; background: linear-gradient(var(--hl), var(--hl)) no-repeat 0 88% / 0% 38%; transition: background-size 0.3s steps(5); }
.post h2 a::after { content: ""; position: absolute; inset: 0; }
.post:hover h2 a, .post h2 a:focus-visible { background-size: 100% 38%; }
.post-ex { margin: 0 0 12px; color: var(--pencil); }
.rss { font-family: var(--mono); font-size: 14px; }

/* ---------- 7. Article ---------- */
.article { max-width: 760px; margin: 0 auto; }
.article-head { padding: clamp(30px, 5vw, 60px) 0 26px; }
.crumbs { font-family: var(--mono); font-size: 14px; margin: 0 0 22px; }
.article-head h1 { font-size: clamp(2.2rem, 1.5rem + 3vw, 3.6rem); line-height: 1.06; margin: 0 0 18px; }
.article-meta { font-family: var(--mono); font-size: 13px; color: var(--pencil); display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 14px; }
.article-cover { max-width: none; margin: 10px 0 34px; padding: 10px 10px 12px; --r: -0.8deg; }
.article-cover img { aspect-ratio: 16 / 9; }

.article-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: start;
    justify-content: space-between;
    gap: 10px 20px;
    margin-bottom: 26px;
    font-family: var(--mono);
    font-size: 14px;
}
.contents summary { cursor: pointer; color: var(--blue); list-style: none; }
.contents summary::-webkit-details-marker { display: none; }
.contents summary::before { content: "+ "; color: var(--red); }
.contents[open] summary::before { content: "- "; }
.contents ol { margin: 10px 0 0; padding: 12px 18px 12px 36px; background: var(--card); box-shadow: var(--lift); font-family: var(--serif); font-size: 16px; }
.contents li { margin: 4px 0; }
.contents li.sub { margin-left: 16px; list-style: circle; }
.contents a.active { background: var(--hl); color: var(--ink); }
.size-ctrl { display: flex; gap: 6px; align-items: center; color: var(--pencil); }
.size-ctrl button { font: inherit; font-weight: 700; color: var(--ink); background: var(--card); border: 1.5px solid var(--line); border-radius: 3px; width: 34px; padding: 2px 0; cursor: pointer; }
.size-ctrl button:hover { border-color: var(--ink); }

.article-end { margin-top: 50px; display: grid; gap: 34px; }
.author { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 20px; align-items: center; }
.author .polaroid { padding: 6px 6px 18px; --r: -4deg; }
.author .polaroid::before { width: 50px; margin-left: -25px; height: 16px; top: -8px; }
.author h3 { margin: 0; font-family: var(--hand); font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.author p { margin: 4px 0 0; color: var(--pencil); font-size: 0.95em; }
.series, .related { border-top: 2px dashed var(--line); padding-top: 22px; }
.series h3, .related h3, .share h3 { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--pencil); margin: 0 0 12px; font-weight: 700; }
.series ol { margin: 0; padding-left: 22px; }
.series li { margin: 4px 0; }
.series li.current { font-weight: 500; }
.share { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.share h3 { margin: 0; }
.article-missing { text-align: center; padding: 80px 0; }

/* ---------- 8. Post content ---------- */
.article-text { font-size: var(--article-size, 1.06em); line-height: 1.7; }
.article-text > *:first-child { margin-top: 0; }
.article-text p, .article-text ul, .article-text ol { margin: 0 0 1.1em; }
.article-text h2, .article-text h3, .article-text h4 { font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; scroll-margin-top: 24px; }
.article-text h2 { font-size: 1.8em; margin: 1.8em 0 0.5em; }
.article-text h3 { font-size: 1.45em; margin: 1.6em 0 0.4em; }
.article-text h4 { font-size: 1.15em; margin: 1.4em 0 0.3em; }
.article-text li { margin: 0.25em 0; }
.article-text li::marker { color: var(--red); }
.article-text strong, .article-text b { font-weight: 600; }
.article-text .fas, .article-text .far, .article-text .fab, .article-text .box-icon { display: none; }   /* icon font isn't loaded */
.article-text sup { line-height: 0; }

.article-intro { font-size: 1.2em; line-height: 1.55; }
.article-intro::first-letter { font-size: 3.3em; float: left; line-height: 0.82; margin: 0.06em 0.08em 0 0; color: var(--red); }

.article-divider { border: 0; border-top: 2px dashed var(--line); margin: 2.4em 0; }

.article-text figure, .article-image {
    margin: 2em auto;
    background: var(--card);
    padding: 10px 10px 8px;
    box-shadow: var(--lift);
    transform: rotate(-0.6deg);
    max-width: 100%;
    width: fit-content;
}
.article-text figure:nth-of-type(even) { transform: rotate(0.6deg); }
.article-text figure img { max-height: 520px; width: auto; margin: 0 auto; }
.article-text figcaption { font-family: var(--hand); font-size: 1.35rem; line-height: 1.2; text-align: center; padding: 8px 6px 2px; }
.image-subtext { display: block; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--pencil); padding-bottom: 4px; }

.article-info-box, .article-warning-box {
    margin: 2em 0;
    padding: 18px 22px;
    background: var(--sticky);
    color: var(--sticky-ink);
    box-shadow: 0 16px 18px -14px var(--shadow);
    transform: rotate(-0.5deg);
}
.article-warning-box { background: var(--card); border: 2.5px solid var(--red); color: var(--ink); transform: rotate(0.4deg); }
.box-content strong:first-child { display: block; font-family: var(--hand); font-size: 1.55rem; font-weight: 700; line-height: 1.1; margin-bottom: 4px; }
.article-warning-box .box-content strong:first-child { color: var(--red); }
.box-content p:last-child { margin-bottom: 0; }
.article-info-box a { color: inherit; }

.quote-highlight { margin: 2.2em 0; padding: 4px 0 4px 26px; border-left: 3px solid var(--red); position: relative; }
.quote-highlight p { font-size: 1.2em; font-style: italic; margin: 0 0 6px; }
.quote-highlight cite { font-family: var(--mono); font-style: normal; font-size: 13px; color: var(--pencil); }

.article-text pre, .code-block-wrapper pre {
    background: var(--paper-2);
    border: 1.5px dashed var(--line);
    padding: 16px 18px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.55;
    margin: 0;
}
.article-text code { font-family: var(--mono); font-size: 0.9em; background: var(--paper-2); padding: 1px 4px; border-radius: 2px; }
.article-text pre code { background: none; padding: 0; font-size: inherit; }
.code-block-wrapper { position: relative; margin: 1.6em 0; }
.code-copy-btn { position: absolute; top: 8px; right: 8px; }

.collapsible-section { margin: 1.6em 0; border: 1.5px solid var(--line); background: var(--card); }
.collapsible-header {
    cursor: pointer;
    padding: 12px 16px;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    user-select: none;
}
.collapsible-header::before { content: "+"; display: inline-block; width: 1.3em; color: var(--red); }
.collapsible-header.active::before { content: "-"; }
.collapsible-content { display: none; padding: 0 16px 16px; }
.collapsible-content.active { display: block; }

.code-playground { border: 2px solid var(--ink); background: var(--card); margin: 1em 0; }
.playground-tabs { display: flex; border-bottom: 2px solid var(--ink); align-items: stretch; }
.playground-tab {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    background: none;
    border: 0;
    border-right: 1.5px solid var(--line);
    color: var(--pencil);
    cursor: pointer;
}
.playground-tab.active { background: var(--ink); color: var(--paper); }
.playground-run { margin-left: auto; font-family: var(--mono); font-size: 13px; font-weight: 700; background: var(--hl); color: var(--ink); border: 0; border-left: 2px solid var(--ink); padding: 6px 14px; cursor: pointer; }
.playground-code {
    display: none;
    width: 100%;
    min-height: 200px;
    border: 0;
    resize: vertical;
    padding: 14px;
    font-family: var(--mono);
    font-size: 14px;
    line-height: 1.5;
    background: var(--paper-2);
    color: var(--ink);
    tab-size: 2;
}
.playground-code.active { display: block; }
.playground-result:not(:empty) { border-top: 2px solid var(--ink); }
.playground-result iframe { display: block; }

.animated-chart { height: 300px; margin: 2em 0; padding: 14px; background: var(--card); box-shadow: var(--lift); position: relative; }
.mermaid-diagram { margin: 2em 0; padding: 18px; background: var(--card); box-shadow: var(--lift); text-align: center; overflow-x: auto; font-family: var(--hand); }
.mermaid-diagram:not([data-processed]) { white-space: pre; text-align: left; font-family: var(--mono); font-size: 13px; color: var(--pencil); }

.article-map { margin: 2em 0; background: var(--card); padding: 10px; box-shadow: var(--lift); transform: rotate(0.5deg); }
.article-map iframe { display: block; width: 100%; border: 0; filter: sepia(0.25) saturate(0.8); }
.map-header { font-family: var(--hand); font-size: 1.45rem; padding: 0 4px 8px; }
.map-footer { font-family: var(--mono); font-size: 13px; padding: 8px 4px 0; }

.footnote-ref a, a.footnote-ref, .footnote-ref { font-family: var(--mono); font-size: 0.72em; }
.article-footnotes { margin-top: 3em; padding-top: 16px; border-top: 2px dashed var(--line); font-size: 0.88em; color: var(--pencil); }
.article-footnotes h4, .article-footnotes h3 { font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 8px; }
.article-footnotes li:target { background: var(--hl); color: var(--ink); }

/* ---------- 9. Photos ---------- */
.photos-intro { max-width: 52ch; }
.line-wrap {
    position: relative;
    overflow: hidden;
    padding: 34px 0 30px;
    touch-action: pan-y;
    cursor: grab;
    width: 100vw;
    margin-left: calc(50% - 50vw);
}
.line-wrap:focus-visible { outline-offset: -6px; }
.clothesline { position: absolute; left: 0; right: 0; top: 30px; width: 100%; height: 26px; pointer-events: none; }
.clothesline path { fill: none; stroke: var(--pencil); stroke-width: 2; vector-effect: non-scaling-stroke; }
.photos-wrapper { display: flex; gap: clamp(26px, 5vw, 60px); width: max-content; will-change: transform; user-select: none; }
.photos-wrapper.dragging { cursor: grabbing; }
.photo-item { flex: none; width: min(330px, 68vw); transform-origin: 50% 0; }
.photo-swing { position: relative; padding-top: 6px; }
.photo-clip {   /* wooden peg */
    position: absolute;
    top: -14px;
    left: 50%;
    width: 14px;
    height: 44px;
    margin-left: -7px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--peg) 80%, #000) 0 2px, var(--peg) 2px calc(50% - 1px), color-mix(in srgb, var(--peg) 70%, #000) calc(50% - 1px) calc(50% + 1px), var(--peg) calc(50% + 1px));
    border-radius: 3px 3px 2px 2px;
    z-index: 3;
    box-shadow: 0 3px 4px -2px var(--shadow);
}
.photo-frame { background: var(--card); padding: 10px 10px 4px; box-shadow: var(--lift); cursor: zoom-in; }
.photo-frame img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; pointer-events: none; }
.photo-caption { font-family: var(--hand); font-size: 1.5rem; text-align: center; padding: 6px 0 2px; }

.gallery-nav { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 4px; font-family: var(--mono); }
.gallery-indicators { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.indicator { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--pencil); background: none; padding: 0; cursor: pointer; }
.indicator.active { background: var(--ink); border-color: var(--ink); }

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 60px var(--gutter);
    background: color-mix(in srgb, var(--paper) 94%, transparent);
}
.lightbox.active { display: flex; }
.lightbox-content { background: var(--card); padding: 12px 12px 6px; box-shadow: 0 30px 50px -20px var(--shadow); transform: rotate(-1deg); max-width: min(900px, 100%); }
.lightbox-content img { max-height: calc(100vh - 190px); width: auto; margin: 0 auto; }
.lightbox-caption { font-family: var(--hand); font-size: 1.7rem; text-align: center; padding: 6px 0 2px; }
.lightbox-close { position: absolute; top: 16px; right: var(--gutter); }
.lightbox-nav { position: absolute; bottom: 18px; }
.lightbox-prev { left: var(--gutter); }
.lightbox-next { right: var(--gutter); }

/* ---------- 10. 404 ---------- */
.lost { text-align: center; padding: clamp(50px, 10vw, 110px) var(--gutter) 40px; position: relative; }
.lost-num { font-size: clamp(7rem, 4rem + 16vw, 13rem); font-weight: 500; line-height: 0.9; letter-spacing: -0.04em; margin: 0; position: relative; display: inline-block; }
.lost-num svg { position: absolute; left: -6%; top: 30%; width: 112%; height: 40%; overflow: visible; }
.lost-num path { fill: none; stroke: var(--red); stroke-width: 5; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 900; stroke-dashoffset: 900; animation: draw 0.8s steps(8) 0.6s forwards; }
.lost h1 { font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.5rem); margin: 26px 0 8px; }
.lost p { color: var(--pencil); margin: 0 0 28px; }
.lost .lost-num { color: var(--ink); margin: 0; }
.lost-actions { display: flex; gap: 14px 24px; justify-content: center; align-items: center; flex-wrap: wrap; font-family: var(--mono); }
.plane { position: absolute; top: 18%; left: 0; width: 70px; height: 40px; animation: fly 9s steps(36) infinite; pointer-events: none; }
.plane path { fill: var(--card); stroke: var(--ink); stroke-width: 1.6; stroke-linejoin: round; }

/* ---------- 11. Motion: placed by hand, frame by frame ---------- */
.drop { animation: place 0.55s steps(4) backwards; animation-delay: calc(var(--d, 0) * 0.12s + 0.1s); }
.reveal { opacity: 0; }
.reveal.in { opacity: 1; animation: place 0.5s steps(4) backwards; }
.card.reveal.in { animation-delay: calc(var(--i, 0) * 0.07s); }

@keyframes place {
    from { opacity: 0; transform: translateY(-16px) rotate(calc(var(--r, 0deg) + 3deg)); }
    to   { opacity: 1; transform: translateY(0) rotate(var(--r, 0deg)); }
}
@keyframes draw   { to { stroke-dashoffset: 0; } }
@keyframes marker { to { background-size: 100% 72%; } }
@keyframes blink  { 50% { opacity: 0; } }
@keyframes strike { to { transform: scaleX(1) rotate(-3deg); } }
@keyframes write  { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes snip   { from { left: 4%; } to { left: 92%; } }
@keyframes wobble { 0%, 100% { transform: rotate(-0.6deg); } 50% { transform: rotate(0.6deg) translateY(-1px); } }
@keyframes fly {
    0%   { transform: translate(-90px, 20px) rotate(4deg); }
    50%  { transform: translate(50vw, -30px) rotate(-6deg); }
    100% { transform: translate(105vw, 30px) rotate(8deg); }
}

/* konami easter egg */
body.party main { filter: url(#boil); }
body.party .card, body.party .polaroid, body.party .sticky, body.party .photo-frame { animation: wobble 0.3s steps(2) infinite; }
.woot {
    position: fixed;
    top: 24px;
    left: 50%;
    z-index: 300;
    background: var(--sticky);
    color: var(--sticky-ink);
    font-family: var(--hand);
    font-size: 2.2rem;
    font-weight: 700;
    padding: 8px 22px;
    transform: translateX(-50%) rotate(-4deg);
    box-shadow: 0 14px 18px -12px var(--shadow);
}

/* ---------- 12. Responsive ---------- */
@media (max-width: 820px) {
    .hero { grid-template-columns: 1fr; padding-top: 36px; }
    .hero-side { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
    .hero-photo { margin: 0; max-width: 260px; }
    .hero-side .sticky { margin: 30px 0 0 -6px; }
    .about { grid-template-columns: 1fr; }
    .postcard { grid-template-columns: 1fr; }
    .pc-address { border-left: 0; border-top: 2px solid var(--line); padding: 24px 0 0; }
    .pc-stamp { top: -50px; right: -4px; transform: rotate(5deg) scale(0.8); }
    .postmark { display: none; }
    .post { grid-template-columns: 150px minmax(0, 1fr); gap: 14px 22px; }
}

@media (max-width: 520px) {
    .name { white-space: normal; }
    .hero-side { grid-template-columns: 1fr; }
    .hero-photo { max-width: 240px; margin: 0 auto 0 8px; }
    .hero-side .sticky { margin: -24px 0 0 auto; max-width: 200px; }
    .letter { padding: 22px 18px 18px 44px; background-position: -6px 0, 0 14px; }
    .tools li { grid-template-columns: 84px 1fr; }
    .toc a { flex-wrap: wrap; }
    .toc-dots { display: none; }
    .toc time { width: 100%; padding-left: 34px; }
    .pc-stamp { top: -46px; }
    .post { grid-template-columns: 1fr; }
    .post-shot { max-width: 260px; }
    .author { grid-template-columns: 72px minmax(0, 1fr); }
    .lightbox-content img { max-height: calc(100vh - 220px); }
}

/* ---------- Reduced motion: keep the paper, drop the stop-motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; }
    .scribble path, .lost-num path { stroke-dashoffset: 0; }
    .hl { background-size: 100% 72%; }
    .pencilcase .tool-bar span { width: var(--p); }
    .boil, body.party main { filter: url(#rough); }
    .plane { display: none; }
}
