/* Shared stylesheet for the generated pages under /posts/ (one letter per post,
   year and topic pages) — written by hand, linked by scripts/build-site.py.
   Tokens are the site's own (index.html :root); the letter / polaroid / topbar
   rules are ported from posts/index.html so a letter looks the same everywhere. */

/* Self-hosted fonts, latin subset — canonical copy at /fonts/fonts.css
   (Caveat: OFL 1.1; Special Elite: Apache-2.0; licences in /fonts/).
   Declared here so the generated pages need no extra stylesheet request. */
@font-face {
    font-family: "Caveat";
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url(/fonts/caveat-600-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Caveat";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url(/fonts/caveat-600-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Special Elite";
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url(/fonts/special-elite-400-latin.woff2) format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

* { box-sizing: border-box; }

:root {
    --paper: #F3ECDC;
    --paper-light: #FAF5EA;
    --card: #FFFDF8;
    --ink: #2A241B;
    --ink-soft: #5C5344;
    --muted: #8A7E6B;
    --line: #E2D9C6;
    --red: #B23A2E;
    --tape: rgba(240, 197, 80, 0.55);
    --tape-edge: rgba(200, 155, 40, 0.28);
    --shadow-warm: 0 1px 2px rgba(88, 66, 35, 0.08), 0 10px 26px rgba(88, 66, 35, 0.10);
    --type: "Special Elite", "Courier New", monospace;
    --hand: "Caveat", "Segoe Script", cursive;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
    background: radial-gradient(1400px 900px at 50% -200px, var(--paper-light), var(--paper) 70%);
    background-color: var(--paper);
    margin: 0;
    padding: 30px 20px;
    min-height: 100vh;
    color: var(--ink);
}

a:focus-visible { outline: 3px dashed var(--red); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: 800px; margin: 0 auto; }

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 18px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    color: var(--muted);
    font-family: var(--type);
}
.topbar a { color: var(--ink-soft); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar a:hover { color: var(--red); text-decoration: underline; }
.topbar-mid { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.topbar-site { font-size: 13px; opacity: 0.85; white-space: nowrap; }
/* On a narrow phone the address is just noise — the links matter. */
@media (max-width: 480px) { .topbar-site { display: none; } }

/* --- Header (year / topic pages) --- */
.header { padding: 10px 0 4px; margin-bottom: 22px; text-align: center; }
.header h1 {
    font-family: var(--type);
    font-weight: 400;
    letter-spacing: 0.02em;
    margin: 0 0 4px;
    color: var(--ink);
    font-size: clamp(24px, 4.5vw, 32px);
}
.header .subtitle {
    font-family: var(--hand);
    font-weight: 600;
    color: var(--ink-soft);
    margin: 0 0 12px;
    font-size: 22px;
    transform: rotate(-0.6deg);
}
.header .meta {
    font-family: var(--type);
    color: var(--muted);
    font-size: 11.5px;
    letter-spacing: 0.05em;
    margin: 0;
}
.header .meta a { color: var(--red); text-decoration: none; }
.header .meta a:hover { text-decoration: underline; }

/* --- A letter --- */
.post {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px 24px;
    margin-bottom: 18px;
    box-shadow: var(--shadow-warm);
}
.post.letter { padding: 28px 30px 26px; }
@media (min-width: 600px) {
    .post.letter { transform: rotate(-0.35deg); }
    .mini-list .post:nth-child(odd) { transform: rotate(0.3deg); }
    .mini-list .post:nth-child(even) { transform: rotate(-0.3deg); }
}

.post-date {
    font-family: var(--type);
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 10px;
}
.post-date a { color: inherit; text-decoration: none; }
.post-date a:hover { text-decoration: underline; }
.post-eng { margin-left: 8px; color: var(--ink-soft); text-transform: none; white-space: nowrap; }
.post-mediatag { margin-left: 8px; color: var(--red); }

.post-title {
    font-family: var(--type);
    font-weight: 400;
    font-size: clamp(21px, 3.6vw, 27px);
    line-height: 1.25;
    letter-spacing: 0.01em;
    margin: 0 0 16px;
    color: var(--ink);
    text-wrap: balance;
}
.post-title a { color: inherit; text-decoration: none; }
.post-title a:hover { color: var(--red); }
.mini .post-title { font-size: 18px; margin: 0 0 8px; }

.post-text {
    color: var(--ink);
    line-height: 1.65;
    font-size: 15.5px;
    word-wrap: break-word;
    margin: 0 0 14px;
}
.post-text p { margin: 0 0 14px; }
.post-text p:last-child { margin-bottom: 0; }
.post-text a { color: var(--red); word-break: break-all; }
.letter .post-text { max-width: 66ch; margin-bottom: 18px; }
.mini .post-text { font-size: 14.5px; color: var(--ink-soft); }

/* --- Polaroids --- */
.post-gallery { margin: 4px 0 18px; display: flex; flex-wrap: wrap; gap: 16px 14px; }
.post-thumb {
    position: relative;
    display: block;
    width: 168px;
    margin: 0;
    padding: 8px 8px 24px;
    border: none;
    border-radius: 2px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(88, 66, 35, 0.20);
    text-decoration: none;
    transform: rotate(var(--pr, 0deg));
}
.post-thumb::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 50%;
    width: 68px;
    height: 20px;
    transform: translateX(-50%) rotate(-3deg);
    background:
        repeating-linear-gradient(45deg, var(--tape-edge) 0 5px, transparent 5px 10px),
        var(--tape);
    border-radius: 2px;
    pointer-events: none;
}
.post-thumb picture { display: block; }
.post-thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: #E9E1CE;
    transition: filter 0.15s ease;
}
.post-gallery.cols-1 .post-thumb { width: min(100%, 440px); }
.post-gallery.cols-1 .post-thumb img { aspect-ratio: auto; max-height: 520px; object-fit: contain; background: #fff; }
.post-thumb:hover img { filter: brightness(0.94); }
@media (prefers-reduced-motion: no-preference) {
    .post-thumb { transition: transform 0.15s ease; }
    .post-thumb:hover { transform: rotate(0deg) scale(1.03); }
}
.post-thumb-type {
    position: absolute;
    top: calc(50% - 8px);
    left: 50%;
    transform: translate(-50%, -50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    pointer-events: none;
}

/* Compact cards on year / topic pages: one small polaroid beside the text. */
.mini { display: flex; gap: 18px; align-items: flex-start; }
.mini .post-body { flex: 1 1 0; min-width: 0; }
.mini .post-gallery { margin: 6px 0 0; flex: 0 0 auto; }
.mini .post-thumb { width: 104px; padding: 6px 6px 16px; }
.mini .post-thumb::before { width: 44px; height: 14px; top: -7px; }

/* --- Topics, actions --- */
.post-topics { margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.post-topic {
    font-family: var(--type);
    font-size: 11px;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 4px 10px 2px;
    border-radius: 999px;
    text-decoration: none;
}
.post-topic:hover { color: var(--red); border-color: var(--red); }
.post-actions { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.post-link {
    font-family: var(--type);
    font-size: 13px;
    letter-spacing: 0.04em;
    color: var(--red);
    text-decoration: none;
}
.post-link:hover { text-decoration: underline; }

/* --- Older / newer --- */
.post-nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px 18px;
    align-items: center;
    margin: 26px 4px 10px;
    font-family: var(--type);
    font-size: 13px;
    letter-spacing: 0.03em;
}
.post-nav a { color: var(--ink-soft); text-decoration: none; }
.post-nav a:hover { color: var(--red); text-decoration: underline; }
.post-nav a[rel="prev"] { grid-column: 1; text-align: left; }
.post-nav .post-nav-year { grid-column: 2; text-align: center; color: var(--red); }
.post-nav a[rel="next"] { grid-column: 3; text-align: right; }
.post-nav .post-nav-all { grid-column: 1 / -1; text-align: center; margin-top: 8px; color: var(--muted); }

/* --- "More letters like this": up to three neighbours picked by shared LLM tags,
   keywords and entities (scripts/build-site.py). Plain on the desk, like .post-nav —
   the paper card above it has already ended. --- */
.related { margin: 26px 4px 0; }
.related h2 {
    font-family: var(--type);
    font-weight: normal;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0 0 10px;
}
.related-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.related-list a { display: block; color: var(--ink-soft); text-decoration: none; }
.related-list a:hover { color: var(--red); }
.related-list a:hover .related-title { text-decoration: underline; }
.related-date {
    display: block;
    font-family: var(--type);
    font-size: 12px;
    letter-spacing: 0.03em;
    color: var(--muted);
}
.related-title { font-size: 15.5px; line-height: 1.4; }

/* --- Lightbox: click a polaroid on a letter page to see the photo full-size.
   Wired up by /posts/page.js; same look as the desk and the archive. --- */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}
.lightbox[hidden] { display: none; }

.lb-img {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 4px;
    -webkit-user-drag: none;
    user-select: none;
}

.lb-nav, .lb-close {
    position: absolute;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}
.lb-nav { top: 50%; transform: translateY(-50%); width: 48px; height: 48px; font-size: 30px; }
.lb-prev { left: 14px; }
.lb-next { right: 14px; }
.lb-close { top: 16px; right: 18px; width: 40px; height: 40px; font-size: 24px; }
.lb-nav:hover, .lb-close:hover { background: rgba(0, 0, 0, 0.75); }
.lb-nav[hidden] { display: none; }

.lb-counter {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 13px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 12px;
    border-radius: 999px;
}
.lb-counter[hidden] { display: none; }

@media (max-width: 480px) {
    .lb-nav { width: 40px; height: 40px; font-size: 26px; }
}

/* --- Video modal: click a video poster on a letter page to play the post via
   LinkedIn's own embed. Facade pattern — nothing of LinkedIn's loads until the
   click, and the iframe is unloaded again on close. --- */
.videobox {
    position: fixed;
    inset: 0;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.videobox[hidden] { display: none; }

.vb-frame {
    position: relative;
    width: min(94vw, 504px);
    height: min(86vh, 640px);
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.vb-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}
.vb-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--red);
    font-size: 14px;
    background: #fff;
}
.vb-loading[hidden] { display: none; }

.vb-close {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 40px;
    height: 40px;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.45);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    line-height: 1;
}
.vb-close:hover { background: rgba(0, 0, 0, 0.75); }

@media (max-width: 600px) {
    body { padding: 22px 14px; }
    .post { padding: 18px 18px; }
    .post.letter { padding: 22px 20px; }
    .post-gallery { gap: 14px 10px; }
    .post-gallery .post-thumb { width: calc(50% - 5px); padding: 6px 6px 18px; transform: none; }
    .post-gallery .post-thumb:hover { transform: none; }
    .post-gallery.cols-1 .post-thumb { width: 100%; }
    .mini { flex-direction: column-reverse; gap: 12px; }
    .mini .post-gallery .post-thumb { width: 104px; transform: rotate(var(--pr, 0deg)); }
    .post-nav { grid-template-columns: 1fr; text-align: left; }
    .post-nav a[rel="prev"], .post-nav a[rel="next"], .post-nav .post-nav-year { grid-column: 1; text-align: left; }
}
