/* Lanterns: a dusk sky, pale lilac ink, one typeface.
   The WebGL sky (lanterns.js) paints over the gradient when it can. */

:root {
  --ink: #f1ebf7;
  --ink-soft: #e2daee;
  --rule: rgba(241, 235, 247, .38);
  --hair: rgba(241, 235, 247, .16);
  --sky-top: #2f3d88;
  --sky-mid: #5257a0;
  --sky-low: #7d4f6c;
  --panel: rgba(16, 17, 52, .6);
  --panel-inline: rgba(16, 17, 52, .42);
  --gutter: 7vw;
  --measure: 36rem;
  --serif: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--sky-top);
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.3rem;
  line-height: 1.55;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* The sky, as a fixed layer (background-attachment: fixed is ignored on iOS). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 62%, var(--sky-low) 100%);
  pointer-events: none;
}

::selection { background: rgba(241, 235, 247, .86); color: var(--sky-top); }

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 1.6s ease;
  touch-action: pan-y;
}
.ready #sky { opacity: 1; }
#sky.grab { cursor: grab; }
#sky.grabbing { cursor: grabbing; }
.nogl #sky { display: none; }

main, .masthead, .colophon { position: relative; z-index: 1; }

/* Inner pages: keep the footer at the bottom of short pages */
body.inner { display: flex; flex-direction: column; }
body.inner main { flex: 1 0 auto; }
.masthead, .inner main, .colophon { width: 100%; }

/* Links: hairline underlines that firm up on hover */
a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
  text-decoration-color: var(--rule);
}
a:hover { text-decoration-color: currentColor; }
a:focus-visible, input:focus-visible, pre:focus-visible, table:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 4px;
  border-radius: 2px;
  text-decoration-color: currentColor;
}

h1, h2, h3, h4 { text-wrap: balance; }

h1 {
  margin: 0;
  font-weight: 300;
  font-style: italic;
  font-size: clamp(3.4rem, 5.9vw, 5.6rem);
  line-height: .92;
  letter-spacing: -.012em;
  text-shadow: 0 0 40px rgba(20, 16, 60, .35);
}

h2 {
  margin: 0 0 1.1rem;
  font-weight: 400;
  font-style: italic;
  font-size: 1.85rem;
  line-height: 1.1;
}

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

/* Lists of posts: title, then the date beneath */
.entries, .talks, .terms, .projects { list-style: none; margin: 0; padding: 0; }
.entries li { margin: 0 0 1.05rem; }
.entries a { font-size: 1.36rem; line-height: 1.3; }
.entries time, .entries .snippet {
  display: block;
  margin-top: .12rem;
  font-size: 1.02rem;
  font-style: italic;
  color: var(--ink-soft);
}

.more { font-style: italic; color: var(--ink-soft); }
.name { font-weight: 500; }


/* ============ Home ============ */

.home main {
  width: calc(min(38vw, 33rem) + var(--gutter));
  padding: 13vh 0 16vh var(--gutter);
}

.doors ul { list-style: none; margin: 2.6rem 0 0; padding: 0; }
.doors li { margin: 0 0 .35rem; }
.doors a {
  font-size: clamp(2.1rem, 2.9vw, 2.75rem);
  font-weight: 400;
  line-height: 1.12;
  text-decoration: none;
  background-image: linear-gradient(var(--rule), var(--rule));
  background-size: 100% 1px;
  background-position: 0 92%;
  background-repeat: no-repeat;
}
.doors a:hover { background-image: linear-gradient(var(--ink), var(--ink)); }

.aside {
  margin: 2.2rem 0 0;
  max-width: 27rem;
  font-size: 1.18rem;
  color: var(--ink-soft);
}

.hint {
  margin: 2.6rem 0 0;
  font-style: italic;
  font-size: 1.08rem;
  color: var(--ink-soft);
}
.nogl .hint, .stillframe .hint, html:not(.js) .hint { display: none; }

.block { margin-top: 16vh; max-width: 30rem; }
.intro + .block { margin-top: 22vh; }
.block p { margin: 0 0 .8rem; }

.talks li { margin: 0 0 1.4rem; }
.talks .name { font-size: 1.36rem; line-height: 1.3; }
.talks li > span { display: block; margin-top: .2rem; color: var(--ink-soft); font-size: 1.15rem; }
.talks li > span p { display: inline; margin: 0; }

/* Fonts not yet in: hold the landing text briefly so it never flashes in a fallback */
.js body.home:not(.fonts) main { opacity: 0; }
.home main { transition: opacity .8s ease; }


/* ============ Inner pages ============ */


.masthead, .inner main, .colophon {
  max-width: calc(var(--measure) + 2 * var(--pad, 20px));
  margin: 0 auto;
  padding-left: var(--pad, 20px);
  padding-right: var(--pad, 20px);
  --pad: max(20px, 5vw);
}

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .4rem 1.6rem;
  padding-top: 2.2rem;
}
.sig {
  font-style: italic;
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.2;
  text-decoration: none;
}
.sig:hover { text-decoration: underline; text-decoration-color: var(--rule); }
.masthead ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .2rem 1.3rem;
  font-size: 1.12rem;
}
.masthead a[aria-current] { text-decoration-color: currentColor; }

.inner main { padding-top: 11vh; padding-bottom: 6rem; }

.page-head { margin-bottom: 3rem; }
.page-head h1 {
  font-size: clamp(2.6rem, 4.4vw, 3.9rem);
  line-height: 1.02;
  letter-spacing: -.008em;
}
.meta {
  margin: 1.1rem 0 0;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-soft);
}
.meta.tags { margin-top: .25rem; }
.lede {
  margin: 1.3rem 0 0;
  font-size: 1.42rem;
  line-height: 1.5;
}

/* --- Long-form prose --- */
.prose {
  font-weight: 400;
  font-size: 1.32rem;
  line-height: 1.62;
  overflow-wrap: break-word;
  hanging-punctuation: first;
  font-variant-numeric: lining-nums;
}
.prose > :first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol, .prose blockquote, .prose table, .prose dl, .prose figure { margin: 0 0 1.15em; }
.prose strong, .prose b { font-weight: 600; }
.prose em { font-style: italic; }

.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 {
  margin: 2.2em 0 .6em;
  line-height: 1.15;
  text-shadow: none;
  letter-spacing: 0;
}
.prose h1, .prose h2 { font-size: 1.62em; font-weight: 400; font-style: italic; }
.prose h3 { font-size: 1.28em; font-weight: 500; font-style: italic; margin-top: 1.9em; }
.prose h4, .prose h5, .prose h6 { font-size: 1.06em; font-weight: 600; font-style: normal; margin-top: 1.7em; }
.prose h1 + h2, .prose h2 + h3, .prose h3 + h4 { margin-top: .4em; }

.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 0 0 .35em; padding-left: .15em; }
.prose li > ul, .prose li > ol { margin: .35em 0 0; }
.prose li::marker { color: var(--ink-soft); }
.prose ol > li::marker { font-style: italic; }

.prose blockquote {
  padding: .1em 0 .1em 1.1em;
  border-left: 1px solid var(--rule);
  font-style: italic;
  color: var(--ink-soft);
}
.prose blockquote > :last-child { margin-bottom: 0; }

.prose hr {
  border: 0;
  height: 1px;
  width: 5rem;
  margin: 2.6em 0;
  background: var(--rule);
}

.prose img, .prose video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em 0 .6em;
  border-radius: 4px;
  box-shadow: 0 12px 40px -18px rgba(12, 10, 40, .7);
}
.prose p > img:only-child { margin: 0; }
.prose p:has(> img:only-child) { margin: 1.8em 0 1.15em; }
.prose p:has(> img:only-child) + p > em:only-child { display: block; margin-top: -.5em; font-size: .86em; color: var(--ink-soft); }
.prose figure img { margin: 0; }
.prose figcaption { margin-top: .6em; font-size: .86em; font-style: italic; color: var(--ink-soft); }

.prose iframe { max-width: 100%; border: 0; border-radius: 4px; }
.prose div:has(> iframe) { margin: 1.8em 0; border-radius: 4px; overflow: hidden; }

.prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: .9em;
  font-variant-numeric: lining-nums tabular-nums;
}
.prose th, .prose td {
  padding: .45em 1.1em .45em 0;
  border-bottom: 1px solid var(--hair);
  text-align: left;
  vertical-align: top;
}
.prose th { font-weight: 600; border-bottom-color: var(--rule); }

.prose sup, .prose sub { line-height: 0; }
.prose .footnotes { margin-top: 3em; font-size: .9em; color: var(--ink-soft); }
.prose .footnotes hr { margin: 0 0 1.5em; }
.prose .footnote-ref a, .prose .footnote-backref { text-decoration: none; }

/* Code: a darker indigo panel. Sizes are in rem so the mono doesn't follow Cormorant's small x-height. */
.prose code, .prose kbd, .prose samp, .prose pre {
  font-family: var(--mono);
  font-weight: 400;
  font-variant-ligatures: none;
}
.prose :not(pre) > code {
  font-size: .82em;
  padding: .1em .35em;
  border-radius: 3px;
  background: var(--panel-inline);
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  overflow-wrap: anywhere;
}
.prose a code { text-decoration: inherit; }
.prose pre {
  margin: 1.5em 0 1.6em;
  padding: 1rem 1.2rem;
  font-size: .86rem;
  line-height: 1.6;
  color: #ebe5f4;
  background: var(--panel);
  border: 1px solid var(--hair);
  border-radius: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  tab-size: 4;
  white-space: pre;
  overflow-wrap: normal;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}
.prose pre code { font-size: inherit; padding: 0; background: none; }
.prose .highlight { margin: 1.5em 0 1.6em; }
.prose .highlight pre { margin: 0; }

/* Syntax colours: lamp-glow strings, paper-pink keywords, moonlit names */
.chroma { color: #ebe5f4; }
.chroma .err { color: #ffa8b8; }
.chroma .hl { display: block; background: rgba(241, 235, 247, .08); }
.chroma .ln, .chroma .lnt { color: #9c95c4; margin-right: 1em; user-select: none; }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs, .chroma .cp, .chroma .cpf { color: #a8a2cf; font-style: italic; }
.chroma .cp, .chroma .cpf { font-style: normal; }
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt { color: #f2abcb; }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .s2, .chroma .se,
.chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss { color: #f5d491; }
.chroma .se, .chroma .si { color: #ffc98f; }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo { color: #ffb994; }
.chroma .nf, .chroma .fm { color: #a6d2ff; }
.chroma .nc, .chroma .nn, .chroma .ne, .chroma .nd { color: #c8b9ff; }
.chroma .nb, .chroma .bp, .chroma .na { color: #b4e2cf; }
.chroma .nt { color: #f2abcb; }
.chroma .nv, .chroma .vc, .chroma .vg, .chroma .vi, .chroma .vm { color: #e6d6ff; }
.chroma .o, .chroma .ow { color: #d8cfec; }
.chroma .p { color: #cdc4e3; }
.chroma .gd { color: #ffa8b8; }
.chroma .gi { color: #b4e2cf; }
.chroma .gh, .chroma .gu { color: #a6d2ff; font-weight: 600; }
.chroma .ge { font-style: italic; }
.chroma .gs { font-weight: 600; }
.chroma .gp { color: #a8a2cf; user-select: none; }
.chroma .go { color: #cdc4e3; }

/* --- After a post --- */
.post-foot {
  margin-top: 4rem;
  padding-top: 1.6rem;
  border-top: 1px solid var(--hair);
  font-size: 1.15rem;
}
.post-nav p { margin: 0 0 .5rem; color: var(--ink-soft); font-style: italic; }
.post-nav a { color: var(--ink); font-style: normal; }
.share { margin: 1.6rem 0 0; color: var(--ink-soft); font-style: italic; }
.share a { color: var(--ink); font-style: normal; }

/* --- Archive --- */
.year { margin-top: 3.2rem; }
.year:first-of-type { margin-top: 0; }
.year h2 { margin-bottom: 1rem; font-variant-numeric: oldstyle-nums; }

/* --- Pager --- */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem 1.6rem;
  margin-top: 3rem;
  font-size: 1.12rem;
}
.pager span { font-style: italic; color: var(--ink-soft); }

/* --- Tags --- */
.terms { columns: 2 12rem; column-gap: 2.5rem; }
.terms li { margin: 0 0 .7rem; break-inside: avoid; }
.terms a { font-size: 1.36rem; }
.terms span { display: block; font-size: 1rem; font-style: italic; color: var(--ink-soft); }

/* --- Projects --- */
.project {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 0 1.4rem;
  align-items: start;
  margin: 0 0 2.6rem;
}
.project-icon {
  width: 64px; height: 64px;
  border-radius: 14px;
  margin-top: .35rem;
  box-shadow: 0 10px 30px -12px rgba(12, 10, 40, .7);
}
.project-body { grid-column: 2; min-width: 0; }
.project h2 { margin: 0 0 .35rem; font-size: 1.85rem; font-weight: 500; }
.project p { margin: 0 0 .6rem; font-weight: 400; color: var(--ink-soft); }
.project-links { display: flex; flex-wrap: wrap; gap: .2rem 1.4rem; }
.project-links a { color: var(--ink); }

/* --- Search --- */
.search input {
  width: 100%;
  margin: 0;
  padding: .2rem 0 .45rem;
  font: italic 300 clamp(1.8rem, 3vw, 2.3rem)/1.2 var(--serif);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--ink-soft); opacity: .75; }
.search input:focus { outline: none; border-bottom-color: var(--ink); }
.search input:focus-visible { outline: none; }
.search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; display: none; }
#search-status { margin: 1.2rem 0 2rem; min-height: 1.5em; }
.results li { margin-bottom: 1.5rem; }
.results .snippet { font-style: normal; font-weight: 400; line-height: 1.45; }

/* --- Footer --- */
.colophon {
  padding-bottom: 3rem;
  font-size: 1.02rem;
  font-style: italic;
  color: var(--ink-soft);
}
.colophon p { margin: 0; padding-top: 1.4rem; border-top: 1px solid var(--hair); }


/* Wide screens: keep inner-page text in a left column clear of the lanterns (right ~35%). */
@media (min-width: 1100px) {
  .masthead, .inner main, .colophon {
    --pad: 0px;
    margin-left: var(--gutter);
    max-width: min(var(--measure), 55vw);
  }
}

/* Below that, inner pages don't load the sky at all. */
@media (max-width: 1099.98px) {
  .inner #sky { display: none; }
}

@media (max-width: 760px) {
  :root { --gutter: 20px; }
  body { font-size: 1.22rem; }

  /* Home on phones: lanterns hang across the top third, the text scrolls beneath them */
  body.home { overflow: hidden; height: 100svh; }
  .home #sky { touch-action: none; }
  .home main {
    position: fixed;
    top: 34svh;
    left: 0; right: 0; bottom: 0;
    width: auto;
    padding: 2.4rem var(--gutter) 6rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 2.2rem);
            mask-image: linear-gradient(to bottom, transparent 0, #000 2.2rem);
  }
  .nogl .home main, html:not(.js) .home main {
    position: relative; top: 0; padding-top: 12vh; overflow: visible;
    -webkit-mask-image: none; mask-image: none;
  }
  .nogl body.home, html:not(.js) body.home { overflow: auto; height: auto; }
  .home h1 { font-size: 3.1rem; }
  .doors a { font-size: 2.05rem; }
  .block, .intro + .block { margin-top: 5.5rem; }

  .masthead { padding-top: 1.4rem; }
  .sig { font-size: 1.45rem; }
  .masthead ul { gap: .1rem 1.1rem; font-size: 1.08rem; }
  .inner main { padding-top: 3.2rem; padding-bottom: 4rem; }
  .page-head { margin-bottom: 2.2rem; }
  .prose { font-size: 1.24rem; line-height: 1.6; }
  .prose pre { font-size: .8rem; padding: .85rem 1rem; margin-left: -6px; margin-right: -6px; }
  .prose .highlight pre { margin: 0 -6px; }
  .prose img { border-radius: 3px; }
  .project { grid-template-columns: 52px 1fr; gap: 0 1rem; }
  .project-icon { width: 52px; height: 52px; border-radius: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  #sky, main { transition: none; }
}

@media print {
  body::before, #sky, .masthead nav, .post-foot, .colophon { display: none; }
  body { background: #fff; color: #111; }
  a { color: inherit; }
  .prose pre { background: #f4f2f8; color: #111; border-color: #ccc; }
}
