/* cleoanka — writing section (/notes/). Long-form reading on top of base.css:
   a narrow left-aligned prose column, code that scrolls inside itself, asides
   that move into the right margin on wide screens, and a plain typographic
   index. Colours come only from the base.css tokens. */

:root { --note-measure: 37rem; --note-wide: 48rem; }

.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sep { display: inline-block; width: 1.3em; height: 1px; background: var(--edge); vertical-align: middle; margin: 0 .65em; }

/* ---------------------------------------------------------------- article */
main.note { padding: max(calc(var(--topbar-h, 0px) + 1.5rem), clamp(6rem, 14vh, 8.5rem)) 0 0; }
.note-article { max-width: var(--note-measure); margin: 0 auto; padding: 0 1.25rem; }
.note-article :where(p, li, dd) { overflow-wrap: break-word; }

.note-head { padding-bottom: 2.1rem; margin-bottom: 2.4rem; border-bottom: 1px solid var(--edge-soft); }
.note-section { margin: 0 0 1.1rem; font-family: var(--mono); font-size: .76rem; letter-spacing: .04em; }
.note-section a { color: var(--faint); border: 0; }
.note-section a:hover { color: var(--gold); }
.note-head h1 {
  font-size: clamp(2.05rem, 5.6vw, 3.3rem); line-height: 1.06; letter-spacing: -0.035em;
  margin: 0 0 1rem; text-wrap: balance;
}
.note-dek { margin: 0 0 1.5rem; color: var(--dim); font-size: 1.14rem; line-height: 1.55; text-wrap: pretty; }
.note-meta, .note-tags { margin: 0; font-family: var(--mono); font-size: .76rem; letter-spacing: .03em; color: var(--faint); }
.note-tags { margin-top: .35rem; }

/* prose */
.prose { font-size: 1.075rem; line-height: 1.72; }
.prose > p, .prose li { text-wrap: pretty; }
.prose p { margin: 1.1em 0; }
.prose h2 {
  font-size: var(--h2); line-height: 1.25; letter-spacing: -0.022em;
  margin: 2.9rem 0 .2rem; text-wrap: balance;
}
.prose h3 { font-size: 1.1rem; margin: 2rem 0 .2rem; letter-spacing: -0.01em; }
.prose ul, .prose ol { padding-left: 1.3rem; margin: 1.1em 0; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--faint); }
.prose code { font-size: .82em; overflow-wrap: anywhere; }
.prose blockquote { margin: 1.6rem 0; padding-left: 1.1rem; border-left: 2px solid var(--gold); color: var(--bright); }
@media (max-width: 34rem) { .prose { hyphens: auto; -webkit-hyphens: auto; } }

/* asides: in the flow on small screens, in the right margin on wide ones */
.prose .aside-note {
  margin: 1.4rem 0; padding: .1rem 0 .1rem 1rem; border-left: 2px solid var(--edge);
  color: var(--dim); font-size: .93rem; line-height: 1.6;
}
.prose .aside-note p { margin: .5em 0; }
@media (min-width: 78rem) {
  .prose .aside-note {
    float: right; clear: right; width: 14rem; margin: .35rem -17rem 1rem 0;
    padding: .1rem 0 .1rem .9rem; font-size: .86rem;
  }
}

/* code: wider than the text on big screens, always scrolls inside itself */
.prose figure.code {
  clear: both;
  margin: 2rem 0;
  width: min(calc(100vw - 2.5rem), var(--note-wide));
  position: relative; left: 50%; transform: translateX(-50%);
}
@media (max-width: 40rem) { .prose figure.code { width: 100%; left: 0; transform: none; } }
.prose pre {
  margin: 0; padding: .95rem 1.1rem; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  font-family: var(--mono); font-size: .8rem; line-height: 1.6; tab-size: 4; color: var(--text);
}
.prose pre:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.prose pre code { font-size: inherit; background: none; border: 0; padding: 0; color: inherit; overflow-wrap: normal; white-space: pre; }
.prose pre .c { color: var(--faint); }
.prose figure.code figcaption, .prose figure.diagram figcaption {
  font-family: var(--mono); font-size: .72rem; line-height: 1.55; color: var(--faint); padding: .55rem .15rem 0; letter-spacing: .02em;
}
.prose figcaption a { color: var(--dim); border-bottom-color: var(--edge); }
.prose figcaption a:hover { color: var(--gold); }
.prose figcaption code { font-size: 1em; background: none; border: 0; padding: 0; color: inherit; }

/* static diagrams (inline SVG, coloured by tokens) */
.prose figure.diagram {
  clear: both; margin: 2.2rem 0;
  width: min(calc(100vw - 2.5rem), var(--note-wide));
  position: relative; left: 50%; transform: translateX(-50%);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px; padding: 1rem 1rem .7rem;
}
@media (max-width: 40rem) { .prose figure.diagram { width: 100%; left: 0; transform: none; padding: .7rem .6rem .5rem; } }
.diagram svg { display: block; width: 100%; max-width: 38rem; height: auto; margin: 0 auto; overflow: visible; }
.diagram svg text { font-family: var(--mono); fill: var(--dim); }
.diagram svg .t-strong { fill: var(--bright); }
.diagram svg .t-gold { fill: var(--gold); }
.diagram svg .t-faint { fill: var(--faint); }
.diagram svg .t-rust { fill: var(--rust); }
.dg-edge { stroke: var(--edge); fill: none; }
.dg-line { stroke: var(--faint); fill: none; }
.dg-gold { stroke: var(--gold); fill: none; }
.dg-rust { stroke: var(--rust); fill: none; }
.dg-fill { fill: color-mix(in srgb, var(--gold) 12%, transparent); stroke: var(--gold); }
.dg-dot { fill: var(--gold); }
.dg-hollow { fill: var(--bg); stroke: var(--faint); }
.dg-bg { fill: var(--bg); stroke: var(--edge); }

/* signal chain (HTML diagram so it reflows on phones) */
.prose ol.chain {
  list-style: none; padding: 0; margin: 2rem 0; display: grid; gap: .55rem;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); counter-reset: step;
}
.chain li {
  position: relative; margin: 0; padding: .7rem .8rem; background: var(--panel); border: 1px solid var(--edge); border-radius: 8px;
  font-size: .86rem; line-height: 1.45; color: var(--dim);
}
.chain li { counter-increment: step; }
.chain li b::before { content: counter(step) "  "; color: var(--faint); white-space: pre; }
.chain li b { display: block; font-family: var(--mono); font-weight: 500; font-size: .78rem; color: var(--bright); margin-bottom: .2rem; letter-spacing: .01em; }
.chain li.rt { border-color: color-mix(in srgb, var(--gold) 55%, var(--edge)); }
.chain-key { font-family: var(--mono); font-size: .72rem; color: var(--faint); margin: -1.2rem 0 2rem; }
.chain-key i { display: inline-block; width: .9em; height: .9em; border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--edge)); border-radius: 3px; vertical-align: -0.1em; margin-right: .4em; }

/* end matter */
.note-end { margin-top: 3.6rem; padding-top: 1.6rem; border-top: 1px solid var(--edge-soft); clear: both; }
.note-end h2 { font-size: 1.05rem; letter-spacing: -0.01em; margin: 0 0 .8rem; }
.note-end h2 + p { margin-top: 0; }
.note-end h2:not(:first-child) { margin-top: 2.4rem; }
.note-links { margin: 0; }
.note-links > div { display: grid; grid-template-columns: 5.5rem 1fr; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--edge-soft); }
.note-links dt { font-family: var(--mono); font-size: .76rem; color: var(--faint); padding-top: .2rem; }
.note-links dd { margin: 0; color: var(--dim); }
.note-files-lede { font-size: .92rem; color: var(--dim); }
.note-files-lede code { font-size: .78em; }
.note-files { list-style: none; padding: 0; margin: .4rem 0 0; }
.note-files li { margin: .3rem 0; }
.note-files a { border: 0; }
.note-files code { font-size: .76rem; color: var(--dim); overflow-wrap: anywhere; }
.note-files a:hover code { color: var(--gold); border-color: var(--gold); }
@media (max-width: 30rem) { .note-links > div { grid-template-columns: 1fr; gap: .1rem; } }

main.note > .pager { max-width: var(--note-measure); margin: 3.2rem auto 0; padding: 0 1.25rem; }
.pager b { text-wrap: balance; }
@media (max-width: 34rem) { main.note > .pager { flex-direction: column; } main.note > .pager .next { margin-left: 0; text-align: left; } }

/* ---------------------------------------------------------------- index */
main.notes-index { max-width: 50rem; margin: 0 auto; padding: max(calc(var(--topbar-h, 0px) + 1.5rem), clamp(6.5rem, 16vh, 9.5rem)) 1.25rem 0; }
.notes-head { max-width: 38rem; margin: 0 auto clamp(2.6rem, 7vh, 4rem); text-align: center; } /* centred like the other index pages */
.notes-head h1 { font-size: clamp(2.6rem, 8vw, 4.6rem); line-height: 1; letter-spacing: -0.045em; margin: 0 0 1.2rem; }
.notes-lede { font-size: 1.17rem; line-height: 1.55; color: var(--dim); margin: 0 0 1.2rem; text-wrap: pretty; }
.notes-feed { font-family: var(--mono); font-size: .76rem; color: var(--faint); margin: 0; }
.notes-feed > span { margin-left: .5em; }

.notes-year h2 {
  font-family: var(--mono); font-weight: 400; font-size: .8rem; letter-spacing: .06em; color: var(--faint);
  margin: 0; padding-bottom: .6rem; border-bottom: 1px solid var(--edge);
}
.notes-list { list-style: none; margin: 0; padding: 0; }
.notes-item { display: grid; grid-template-columns: 9.5rem 1fr; gap: 1.6rem; padding: 1.9rem 0; border-bottom: 1px solid var(--edge-soft); }
.ni-date { margin: .45rem 0 0; font-family: var(--mono); font-size: .76rem; color: var(--faint); font-variant-numeric: tabular-nums; }
.ni-body h3 { margin: 0 0 .5rem; font-size: clamp(1.4rem, 3vw, 1.85rem); line-height: 1.15; letter-spacing: -0.028em; text-wrap: balance; }
.ni-body h3 a { color: var(--bright); border: 0; }
.ni-body h3 a:hover { color: var(--gold); }
.ni-sum { margin: 0 0 .8rem; color: var(--dim); text-wrap: pretty; }
.ni-meta { margin: 0; font-family: var(--mono); font-size: .74rem; color: var(--faint); line-height: 1.9; }
.ni-meta a { color: var(--dim); border: 0; }
.ni-meta a:hover { color: var(--gold); }
@media (max-width: 40rem) {
  .notes-item { grid-template-columns: 1fr; gap: .2rem; padding: 1.5rem 0; }
  .ni-date { margin: 0; }
}

@media print {
  .prose pre { white-space: pre-wrap; overflow: visible; }
  .prose .aside-note { float: none; width: auto; margin: 1rem 0; }
}
