/* ============================================================
   site.css — shared by every page except cv.html
   A maths department shelf: white ground, black type, bindings
   in series colours. Yellow is a highlighter, never text.
   Pages are one screen; panels scroll inside themselves.
   ============================================================ */
/* A change of light (L / D / T, or the clock) is a time-lapse, not a cut: the theme's
   colours and the room's light are registered properties, so they ease from one setting
   to the next; the window's sun travels (its patch slides along the wall, its angle and
   strength change), the skylight fades, the lamps come up; shelf.js follows them frame
   by frame. The page's colours take 1.6 s, the room 2.6 s. */
@property --bg { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --text { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --muted { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --dim { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --border { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --rule { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --accent-ink { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --mark { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --secondary { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --red { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --shelf { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --window { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --room-sky { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --room-floor { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --room-key { syntax: '<color>'; inherits: true; initial-value: transparent; }
@property --sun { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --room { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --wall { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --lamp { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --shadow { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-x { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-y { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-dx { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-dy { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sun-k { syntax: '<number>'; inherits: true; initial-value: 0; }
@property --sky-k { syntax: '<number>'; inherits: true; initial-value: 0; }
html { transition: --bg 1.6s var(--ease-io), --text 1.6s var(--ease-io), --muted 1.6s var(--ease-io), --dim 1.6s var(--ease-io), --border 1.6s var(--ease-io), --rule 1.6s var(--ease-io), --accent-ink 1.6s var(--ease-io), --mark 1.6s var(--ease-io), --secondary 1.6s var(--ease-io), --red 1.6s var(--ease-io), --shelf 1.6s var(--ease-io), --window 2.6s var(--ease-io), --room-sky 2.6s var(--ease-io), --room-floor 2.6s var(--ease-io), --room-key 2.6s var(--ease-io), --sun 2.6s var(--ease-io), --room 2.6s var(--ease-io), --wall 2.6s var(--ease-io), --lamp 2.6s var(--ease-io), --shadow 2.6s var(--ease-io), --sun-x 2.6s var(--ease-io), --sun-y 2.6s var(--ease-io), --sun-dx 2.6s var(--ease-io), --sun-dy 2.6s var(--ease-io), --sun-k 2.6s var(--ease-io), --sky-k 2.6s var(--ease-io); }
html.settling { transition: none; }
:root,
[data-theme="day"] {
    --bg: #f5f4f0;
    --text: #2b2a27;
    --muted: #6f6d68;
    --dim: #a5a39d;
    --border: #e2e0da;
    --rule: #3a3935;
    --accent: #f0cd4c;
    --accent-ink: #2b2a27;
    --mark: #f0cd4c;              /* the highlighter's resting band under a link */
    --secondary: #2b2a27;
    --red: #b5443f;
    --page: #fbfaf7;
    --shelf: #eceae4;
    --shadow: 0.1;
    /* the shelf's room: light through the window, its strength, the room's own light */
    --window: #fff0b6;            /* lemony: sunlight is never quite white */
    --sun: 1;
    --room: 0.72;                 /* a room lit by its window, not by itself */
    --wall: 0.7;
    --lamp: 0;
    --room-sky: #fffdf8;          /* the room's own light: fill from above, bounce from below, the key */
    --room-floor: #e6e3dc;
    --room-key: #ffffff;
    color-scheme: light;
}
/* night: the same ink and paper turned over; moonlight in the window */
[data-theme="night"] {
    --bg: #1d1c1a;
    --text: #ebe8e1;
    --muted: #9d9990;
    --dim: #6b6862;
    --border: #34322e;
    --rule: #d8d4ca;
    --accent: #f0cd4c;
    --accent-ink: #1d1c1a;
    --mark: #6e5a1c;              /* under light text, the highlighter goes deep amber */
    --secondary: #ebe8e1;
    --red: #d0625c;
    --shelf: #34322e;
    --shadow: 0.35;
    --window: #aebfe8;
    --sun: 0.6;
    --room: 0.6;
    --wall: 0.8;
    --lamp: 1;
    --room-sky: #ffc68c;          /* lamplight, not daylight turned down */
    --room-floor: #5a4130;
    --room-key: #ffb36e;
    color-scheme: dark;
}
/* the reader's pages are always paper, whatever the hour */
:root {
    --page-ink: #2b2a27;
    --page-muted: #6f6d68;
    --page-rule: #e5e2db;
}

@view-transition { navigation: auto; }
/* Between pages, three things carry over (cv.html repeats this; it has no site.css):
   - divider: the column rule, one per page, slides from where this page splits to
     where the next one does; a page with no split keeps it just off the left edge;
   - heading: each page's big heading flies to the next one's;
   - sheet: paper (the writing page's preview, an article, the CV) grows or shrinks
     into the next page's paper. Everything else cross-fades. */
.divider { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--rule); view-transition-name: divider; pointer-events: none; }
.divider.off { position: fixed; left: -2px; }
::view-transition-group(divider), ::view-transition-group(sheet), ::view-transition-group(heading) { animation-duration: .5s; animation-timing-function: var(--ease); }
/* a sheet with no sheet to come from rises onto the desk; one with nowhere to go sinks off it */
::view-transition-new(sheet):only-child { animation: sheet-in .5s var(--ease) both; }
::view-transition-old(sheet):only-child { animation: sheet-out .3s var(--ease-io) both; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(48px); } }
@keyframes sheet-out { to { opacity: 0; transform: translateY(48px); } }
::view-transition-group(root) { animation-duration: .3s; }
/* What a page fills in after it has drawn (a list from its data, a cover) comes up into place
   rather than popping, whether or not a page transition is still running over it */
@keyframes arrive { from { opacity: 0; transform: translateY(6px); } }
@keyframes appear { from { opacity: 0; } }
.arrive { animation: arrive .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
::view-transition-old(root), ::view-transition-new(root) { animation-timing-function: var(--ease-io); }
@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
    *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }   /* states still change, just without the travel */
}

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

html {
    font-size: clamp(14px, 0.2vw + 12px, 16px);
    -webkit-text-size-adjust: 100%;
    --gutter: clamp(16px, 2.6vw, 44px);
    --sans: 'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --second: 'Instrument Sans', Geist, system-ui, sans-serif;
    --mono: 'Geist Mono', ui-monospace, Menlo, monospace;
    /* the site's two curves: --ease arrives fast and settles (hovers, things coming in);
       --ease-io glides out and in (fades, slides, a change of light) */
    --ease: cubic-bezier(.2, .8, .2, 1);
    --ease-io: cubic-bezier(.37, 0, .63, 1);   /* sine in-out */
}
/* anything you can point at eases between states, unless it has its own say */
a, button, [role="radio"], [role="tab"] {
    transition: color .25s var(--ease), background-color .25s var(--ease), border-color .25s var(--ease), opacity .25s var(--ease), outline-color .25s var(--ease);
}
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    word-break: keep-all;          /* Korean breaks between words, not inside them */
    overflow-wrap: break-word;     /* …unless a word alone is wider than its line */
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { max-width: 100%; display: block; }
::selection { background: color-mix(in srgb, var(--accent) 42%, var(--bg)); color: var(--text); }   /* the highlighter, lightly: selecting isn't marking */
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.second { font-family: var(--second); font-style: italic; font-weight: 400; }
.label {
    font-family: var(--mono);
    font-size: 0.7rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}
/* The highlighter, everywhere. It marks words, never their box: put it on an
   inline element (.hl inside a heading or grid cell), and each wrapped line gets
   its own stroke. A link, or the marked entry of a list, carries a band under
   its words; pointed at, the stroke rises out of the band over them. Band and
   fill are two layers, so the rise animates even where (at night) they differ. */
.hl, .link, .post-content a {
    background-image: linear-gradient(var(--accent), var(--accent)), linear-gradient(var(--mark), var(--mark));
    background-repeat: no-repeat;
    background-position: 0 100%, 0 88%;
    background-size: 100% 0, 0 0.34em;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
    transition: background-size .3s var(--ease), color .2s var(--ease);
}
.link, .post-content a, .on .hl, .hl.on { background-size: 100% 0, 100% 0.34em; }
.link:hover, .post-content a:hover, a:hover .hl, a.hl:hover, a:focus-visible .hl, a.hl:focus-visible {
    background-size: 100% 100%, 100% 0.34em;
    color: var(--accent-ink);
}
.links { display: flex; gap: 1.1em; flex-wrap: wrap; }

/* ---- one-screen pages: the body never scrolls, panels do ---- */
.screen { height: 100svh; overflow: hidden; display: flex; flex-direction: column; }
.scroll { position: relative; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--dim) transparent; min-height: 0; }
.scroll::-webkit-scrollbar { width: 6px; }
.scroll::-webkit-scrollbar-thumb { background: var(--dim); }

/* ---- top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    gap: 1.8rem;
    padding: 0 var(--gutter);
    height: 56px;
    flex: none;
    border-bottom: 1px solid var(--rule);
}
.topbar .home { font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.14em; text-transform: uppercase; margin-right: auto; }
.topbar .nav { display: flex; align-items: center; gap: 1.6rem; font-size: 0.9rem; }
@media (max-width: 480px) {          /* the name, three links and the switch on one line */
    .topbar { gap: 0.8rem; }
    .topbar .home { letter-spacing: 0.08em; white-space: nowrap; }
    .topbar .nav { gap: 0.9rem; }
}
.topbar .nav a { color: var(--muted); }
.topbar .nav a:hover, .topbar .nav a[aria-current] { color: var(--text); }
.theme-slot { display: flex; align-items: center; }

/* ---- covers: a report's first page, or a cloth binding ---- */
.plate { width: 100%; height: 100%; object-fit: contain; }
.cover {
    position: relative;
    aspect-ratio: 3 / 4;
    width: 100%;
    display: flex;
    align-items: flex-end;
    padding: 9%;
    background: linear-gradient(var(--band), var(--band)) 0 12% / 100% 7% no-repeat, var(--cloth);
    color: var(--ink);
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08);
}
.cover span { font-weight: 600; font-size: 1.05rem; line-height: 1.1; letter-spacing: -0.02em; }

@media print {
    .topbar { display: none; }
    .screen { height: auto; overflow: visible; }
}

/* ---- an article, as post.html sets it (the writing page shows the same type on its first pages) ---- */
.post-content { font-size: 1.06rem; line-height: 1.72; hyphens: auto; }
.post-content > * { max-width: 40em; }
.post-content p { margin-bottom: 1rem; }
.post-content h1, .post-content h2, .post-content h3, .post-content h4, .post-content h5 {
    font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; margin-top: 2.4rem; margin-bottom: 0.8rem;
}
.post-content h1 { font-size: 1.8rem; }
.post-content h2 { font-size: 1.5rem; }
.post-content h3 { font-size: 1.22rem; }
.post-content h4, .post-content h5 { font-size: 1.05rem; }
.post-content .sec-num { font-family: var(--mono); font-weight: 400; font-size: 0.75em; color: var(--muted); margin-right: 0.6rem; }
.post-content strong { font-weight: 600; }
.post-content .tex-sc { font-variant: small-caps; }
.post-content ul, .post-content ol { padding-left: 1.4rem; margin-bottom: 1rem; }
.post-content li { margin-bottom: 0.35rem; }
.post-content li > ul, .post-content li > ol { margin: 0.35rem 0 0; }
.post-content dl { margin-bottom: 1rem; }
.post-content dt { font-weight: 600; }
.post-content dd { margin: 0.1rem 0 0.6rem 1.4rem; }
.post-content blockquote { font-family: var(--second); font-style: italic; font-size: 1.3em; line-height: 1.3; border-left: 2px solid var(--rule); padding-left: 1.2rem; margin-bottom: 1rem; }
.post-content code { font-family: var(--mono); font-size: 0.86em; }
.post-content pre { font-size: 0.84rem; line-height: 1.55; background: rgba(0,0,0,.05); padding: 1rem 1.2rem; overflow-x: auto; margin-bottom: 1.2rem; }
.post-content img { max-width: 100%; height: auto; margin: 0 auto; }
.post-content figure { margin: 2rem auto; text-align: center; }
.post-content figcaption { margin-top: 0.6rem; font-size: 0.9rem; color: var(--muted); text-align: left; }
.post-content hr { border: 0; border-top: 1px solid var(--border); margin: 2.4rem auto; width: 30%; }
.post-content table { border-collapse: collapse; margin: 0 auto 1.2rem; font-size: 0.92em; display: block; overflow-x: auto; width: fit-content; max-width: 100%; }
.post-content th, .post-content td { border-bottom: 1px solid var(--border); padding: 0.45rem 0.8rem; text-align: left; }
.post-content th { border-bottom-color: var(--rule); font-weight: 600; }

/* math */
.post-content .katex { font-size: 1.06em; }
.post-content .katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.3rem 0; margin: 0; }
.post-content .eq-block { position: relative; margin-bottom: 1rem; }
.post-content .eq-block .eqno { position: absolute; right: 0; top: 50%; transform: translateY(-50%); color: var(--muted); font-family: var(--mono); font-size: 0.8em; }
.post-content p > .katex-display { margin: 0.4rem 0; }

/* TeX blocks */
.post-content .tex-abstract { margin: 0 auto 2rem; padding: 1.2rem 1.4rem; background: rgba(0,0,0,.04); }
.post-content .tex-abstract-label { display: block; font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.4rem; }
.post-content .tex-theorem { border-left: 3px solid var(--accent); padding-left: 1.2rem; margin-bottom: 1rem; }
.post-content .tex-proof { margin-bottom: 1rem; }
.post-content .tex-qed { float: right; }
.post-content .tex-center { text-align: center; margin-bottom: 1rem; }
.post-content .tex-cite a, .post-content .fn-ref a, .post-content .tex-ref { text-decoration: none; }
.post-content .tex-ref-missing { color: var(--red); }
.post-content .post-footnotes, .post-content .post-refs { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.9em; }
.post-content .post-refs h2 { font-size: 1.1rem; margin: 0 0 0.8rem; }
.post-content .fn-back { text-decoration: none; color: var(--muted); }

