/* Preview 12 · The Working Copy
   A LaTeX-style paper an economist is actively annotating. The document is
   the layout; the red editor's pen is the motion. Annotations draw themselves
   on scroll; handwritten margin notes follow each stroke.
   Theme: light, locked. Accent: pen red, locked. Radii: 0, locked. */

:root {
    color-scheme: light;
    --desk: #e9e6df;
    --paper: #faf7f0;
    --ink: #1d1a16;
    --soft: #5f594e;
    --pen: #c33d1d;
    --pencil: #8d8678;
    --rule: rgba(29, 26, 22, 0.14);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    --colw: 660px;
    --margin: 230px;
}

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

body {
    min-height: 100dvh;
    background: var(--desk);
    color: var(--ink);
    font: 400 1.0625rem/1.7 "STIX Two Text", Georgia, serif;
    padding: 2.5rem 1rem 4rem;
}

a { color: inherit; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:where(a):focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }
[id] { scroll-margin-top: 2rem; }
h1, h2, h3 { text-wrap: balance; }
.mono { font-family: "IBM Plex Mono", monospace; }

.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;
}

.skip-link {
    position: absolute; left: 1rem; top: -3rem; z-index: 30;
    background: var(--pen); color: #fff;
    padding: 0.5rem 1rem; text-decoration: none;
    transition: top 150ms var(--ease-out);
}
.skip-link:focus-visible { top: 1rem; }

.gallery-link {
    position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 30;
    font-size: 0.8125rem; font-family: "IBM Plex Mono", monospace;
    color: var(--soft); text-decoration: none;
    background: var(--paper); border: 1px solid var(--rule);
    padding: 0.4rem 0.8rem;
}
.gallery-link:hover, .gallery-link:focus-visible { color: var(--ink); }

/* ---- The sheet ---- */
.sheet {
    max-width: calc(var(--colw) + var(--margin) + 8rem);
    margin: 0 auto;
    background: var(--paper);
    box-shadow: 0 1px 2px rgba(29, 26, 22, 0.10), 0 14px 44px rgba(29, 26, 22, 0.12);
    padding: 3rem 3.5rem 3.5rem;
}

.head {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 1.5rem; flex-wrap: wrap;
    padding-bottom: 1rem; border-bottom: 1px solid var(--rule);
}
.head__stamp { font-size: 0.75rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pencil); }
.head__nav { display: flex; gap: 1.4rem; }
.head__nav a {
    font-family: "IBM Plex Mono", monospace; font-size: 0.8125rem;
    color: var(--soft); text-decoration: none;
    transition: color 140ms var(--ease-out);
}
.head__nav a:hover, .head__nav a:focus-visible { color: var(--pen); }

/* ---- Title block: a paper's title page ---- */
.titleblock { text-align: center; padding: 4.5rem 0 3.5rem; }
.titleblock h1 {
    font-size: clamp(2.25rem, 5.5vw, 3.5rem);
    font-weight: 600; letter-spacing: -0.02em; line-height: 1.1;
}
.titleblock__affil { margin-top: 1rem; font-style: italic; color: var(--soft); }
.titleblock__date { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--pencil); }

/* ---- Content column with a working margin ---- */
main { position: relative; max-width: var(--colw); }

.abstract, .refs, .secs, .quoteblock, .corr { position: relative; padding: 1.5rem 0; }

.abstract {
    margin: 0 auto; padding: 1.25rem 2rem 2.5rem;
}
.abstract__label {
    font-size: 0.95rem; font-weight: 600; text-align: center;
    margin-bottom: 0.8rem; letter-spacing: 0.04em;
}
.abstract p { font-size: 1rem; }

h2 {
    font-size: 1.2rem; font-weight: 600;
    margin-bottom: 1.2rem;
}
.sect-sub { font-weight: 400; font-style: italic; font-size: 0.95rem; color: var(--soft); margin-left: 0.5rem; }

/* References: numbered entries, hanging indent */
.refs ol { list-style: none; counter-reset: ref; padding: 0; }
.refs li {
    counter-increment: ref; margin-bottom: 1.3rem;
    position: relative; padding-left: 2.4rem;
}
.refs li::before {
    content: "[" counter(ref) "]";
    position: absolute; left: 0; top: 0.15rem;
    font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; color: var(--pencil);
}
.refs li a { display: block; text-decoration: none; }
.refs__title { font-weight: 600; transition: color 150ms var(--ease-out); }
.refs li a:hover .refs__title { color: var(--pen); }
.refs__meta { font-size: 0.8rem; color: var(--soft); margin-left: 0.5rem; }
.refs__excerpt {
    display: block; text-indent: 0; padding-left: 0;
    margin-top: 0.3rem; font-size: 0.95rem; color: var(--soft);
}
.refs__more { font-size: 0.95rem; }
.refs__more a { color: var(--soft); }
.refs__more a:hover { color: var(--pen); }

/* Numbered sections */
.sec { margin-bottom: 2.2rem; }
.sec h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.4rem; }
.sec__status { font-size: 0.8rem; color: var(--soft); margin-bottom: 0.6rem; }
.sec p { color: var(--ink); }
.rewrite {
    font-family: "Caveat", cursive; font-size: 1.2rem; color: var(--pen);
    margin-left: 0.4rem;
}

/* About: block quote with a margin brace */
.quoteblock { padding-left: 2.2rem; }
.quoteblock blockquote p { font-style: italic; font-size: 1.05rem; color: var(--ink); }
.quoteblock__more { margin-top: 1rem; font-size: 0.95rem; }
.quoteblock__more a { color: var(--soft); }
.quoteblock__more a:hover { color: var(--pen); }
.pen--brace {
    position: absolute; left: 0.2rem; top: 1.4rem; bottom: 3.2rem;
    width: 14px; height: calc(100% - 4.6rem);
}

/* Correspondence */
.corr { border-top: 1px solid var(--rule); margin-top: 1rem; padding-top: 2.2rem; }
.corr p { max-width: 38rem; }
.corr__mail { margin-top: 1.4rem; font-size: 1.35rem; }
.corr__mail a { text-decoration: none; font-weight: 600; }
.corr__links { margin-top: 1.4rem; display: flex; gap: 1.4rem; font-size: 0.95rem; }
.corr__links a { color: var(--soft); }
.corr__links a:hover { color: var(--pen); }

.foot {
    margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--rule);
    font-size: 0.75rem; color: var(--pencil);
}

/* ---- The pen layer ---- */
.pen-wrap { position: relative; display: inline-block; }
.pen { position: absolute; overflow: visible; pointer-events: none; }
.pen path {
    fill: none; stroke: var(--pen); stroke-width: 2.2;
    stroke-linecap: round; stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
.pen--strike path, .pen--brace path { stroke-width: 2; }

.pen-wrap--circle .pen { left: -10px; right: -12px; top: -7px; bottom: -7px; width: calc(100% + 22px); height: calc(100% + 14px); }
.pen-wrap--under .pen, .pen-wrap--strike .pen, .pen-wrap--double .pen { left: 0; width: 100%; }
.pen-wrap--under .pen { bottom: -6px; height: 9px; }
.pen-wrap--strike .pen { top: 50%; height: 8px; margin-top: -4px; }
.pen-wrap--double .pen { bottom: -10px; height: 13px; }

/* Handwritten margin notes */
.mnote {
    position: absolute; left: calc(100% + 2.6rem); top: 0; width: calc(var(--margin) - 2rem);
    font-family: "Caveat", cursive; font-size: 1.25rem; line-height: 1.25;
    color: var(--pen); transform: rotate(-2deg);
}
.mnote::before { content: "→ "; }

/* Drawing choreography: only when JS arms it and motion is allowed.
   Without JS (or with reduced motion) everything renders complete. */
html.anno .pen path {
    stroke-dasharray: var(--len, 300);
    stroke-dashoffset: var(--len, 300);
}
html.anno .anno-block.draw .pen path {
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 800ms var(--ease-out);
    transition-delay: var(--d, 0ms);
}
html.anno .mnote, html.anno .rewrite {
    opacity: 0; transform: rotate(-3.5deg) translateY(5px);
}
html.anno .rewrite { transform: rotate(-2deg) translateY(4px); display: inline-block; }
html.anno .anno-block.draw .mnote, html.anno .anno-block.draw .rewrite {
    opacity: 1; transform: rotate(-2deg) translateY(0);
    transition: opacity 350ms var(--ease-out) 550ms, transform 350ms var(--ease-out) 550ms;
}

/* ---- Mobile: notes fold into the column ---- */
@media (max-width: 1100px) {
    .sheet { padding: 2rem 1.5rem 2.5rem; }
    main { max-width: 100%; }
    .mnote {
        position: static; display: block; width: auto;
        margin-top: 0.8rem; transform: rotate(-1deg);
        border-left: 2px solid var(--pen); padding-left: 0.8rem;
    }
    html.anno .anno-block.draw .mnote { transform: rotate(-1deg) translateY(0); }
}
@media (max-width: 640px) {
    body { padding: 1rem 0.5rem 3rem; }
    .head { flex-direction: column; gap: 0.6rem; }
    .titleblock { padding: 3rem 0 2.5rem; }
    .abstract { padding: 1rem 0 2rem; }
}
