/* Aegis Blanc hub — shared base for every page and language: night sky, mono type, header, language menu, footer.
   Sizes are in rem and the root grows on 2K/4K screens, so pages scale instead of shrinking to a strip.
   Directions use logical properties (inline-start/end), so Arabic (dir="rtl") mirrors without separate rules. */
@font-face { font-family: Plex; src: url(/assets/fonts/ibm-plex-mono-500.woff2) format('woff2'); font-weight: 500; font-display: swap; }
:root { --sky: #05060d; --line: rgba(220,228,255,.16); --txt: #e9ecf7; --dim: #9aa0b6; --body: #c9cde0;
  --mono: Plex, ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
/* Scripts the mono face doesn't cover: Latin parts stay in the mono face, the rest falls to the system's best face.
   (Cyrillic falls back to the system monospace through the default stack.) */
html:lang(zh-Hant) { --mono: Plex, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
html:lang(zh-Hans) { --mono: Plex, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
html:lang(ja) { --mono: Plex, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif; }
html:lang(hi) { --mono: Plex, "Kohinoor Devanagari", "Noto Sans Devanagari", "Nirmala UI", Mangal, sans-serif; }
html:lang(bn) { --mono: Plex, "Kohinoor Bangla", "Noto Sans Bengali", "Nirmala UI", Vrinda, sans-serif; }
html:lang(ar) { --mono: Plex, "Geeza Pro", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif; }
* { box-sizing: border-box; }
html { font-size: clamp(16px, calc(10px + .3125vw), 22px); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--sky); }
body { margin: 0; background: var(--sky); color: var(--txt); font: 400 1rem/1.6 var(--mono); -webkit-font-smoothing: antialiased; }
html:is(:lang(zh-Hant), :lang(zh-Hans), :lang(ja), :lang(hi), :lang(bn), :lang(ar)) body { line-height: 1.8; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 60% 45% at 70% 30%, rgba(77,63,160,.22), transparent 70%), radial-gradient(ellipse 50% 40% at 15% 80%, rgba(20,110,140,.18), transparent 70%); }
a { color: inherit; }
:focus-visible { outline: 2px solid #c9b8ff; outline-offset: 4px; }
.wrap { position: relative; max-width: 88rem; margin: 0 auto; padding: 1.4rem clamp(1rem, 3vw, 2.5rem) 2.5rem; }

/* the header (and its language menu) always sits above the page: the phone orbit lifts planets to z-index 200 */
header { position: relative; z-index: 400; display: flex; align-items: center; gap: 1rem; font-size: .75rem; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); }
.mark { display: flex; align-items: center; gap: .75rem; color: var(--txt); letter-spacing: .32em; font-size: .8125rem; text-decoration: none; min-height: 2.75rem; margin-inline-end: auto; }
.mark svg { width: 1.625rem; height: 1.875rem; }
header nav a, header a.back { display: inline-block; text-decoration: none; margin-inline-start: 1.1rem; padding: .7rem .2rem; color: var(--dim); }
header nav a:hover, header a.back:hover { color: var(--txt); }

/* language menu: a <details>, so it works without script and from the keyboard */
.lang { position: relative; margin-inline-start: .6rem; text-transform: none; letter-spacing: .06em; }
.lang summary { list-style: none; display: flex; align-items: center; gap: .45rem; min-height: 2.75rem; padding: 0 .75rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; color: var(--txt); white-space: nowrap; }
.lang summary::-webkit-details-marker { display: none; }
.lang summary svg { width: 1rem; height: 1rem; }
.lang[open] summary, .lang summary:hover { border-color: rgba(233,236,247,.45); }
.lang ul { position: absolute; inset-inline-end: 0; top: calc(100% + .4rem); z-index: 10; list-style: none; margin: 0; padding: .35rem; min-width: 12rem; max-height: min(70vh, 34rem); overflow-y: auto; background: #0b0d18; border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 1rem 2.5rem rgba(0,0,0,.5); }
.lang li a { display: block; padding: .55rem .8rem; border-radius: .5rem; text-decoration: none; color: var(--body); font-size: .9rem; }
.lang li a:hover, .lang li a[aria-current] { background: rgba(233,236,247,.08); color: var(--txt); }
.lang li a[aria-current]::after { content: " ✓"; color: var(--dim); }

footer { margin-top: 2.25rem; display: flex; justify-content: space-between; align-items: center; gap: .75rem 1.5rem; flex-wrap: wrap; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
footer a { display: inline-block; text-decoration: none; padding: .6rem 0; } footer a:hover { color: var(--txt); }

/* Chinese and Japanese don't need the wide tracking used for Latin capitals */
html:is(:lang(zh-Hant), :lang(zh-Hans), :lang(ja)) :is(header nav, header a.back, footer, .count, .tag, .notes h2, h2) { letter-spacing: .06em; }
html:is(:lang(zh-Hant), :lang(zh-Hans), :lang(ja)) h1 { letter-spacing: .02em; }
/* Arabic, Devanagari and Bengali join or stack letters: any extra tracking breaks them, so none at all */
html:is(:lang(ar), :lang(hi), :lang(bn)) :is(body, header, .mark, nav, .lang, footer, .count, .tag, .tag b, .notes h2, h1, h2, p) { letter-spacing: 0; }

@media (max-width: 820px) { header nav { display: none; } }

/* headings and short paragraphs: no single-character last lines; Japanese breaks at phrase boundaries */
.core h1, h1 { text-wrap: balance; }
.core p, .notes p { text-wrap: pretty; }
html:lang(ja) :is(h1, h2, p, .tag) { word-break: auto-phrase; }
