/* Reset, type, page transitions. */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }  /* JS shows and hides with the attribute */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--fg);
  font: 15px/1.5 var(--font-ui); font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv05";  /* Inter: l with a tail, so l, I and 1 differ */
}
::selection { background: var(--accent-soft); }

h1, h2, h3 { font-family: var(--font-read); font-weight: 560; letter-spacing: -0.01em; line-height: 1.2;
  margin: 0; text-wrap: balance; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-md); }
p { margin: 0 0 0.75em; text-wrap: pretty; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; }
button { font: inherit; color: inherit; }
kbd { display: inline-block; min-width: 1.5em; padding: 0.05em 0.4em; font: 500 0.72rem/1.4 var(--font-mono);
  text-align: center; color: var(--muted); background: var(--sunken); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 5px; vertical-align: 0.1em; }
code { font: 0.9em var(--font-mono); background: var(--sunken); border: 1px solid var(--line);
  border-radius: 4px; padding: 0.05em 0.3em; }
hr { border: 0; border-top: 1px solid var(--line); }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.error { color: var(--err); font-weight: 600; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Reading text: card faces, previews, editors. KaTeX's Computer Modern sits a
   little small next to Literata, so it gets a nudge up. */
.reading { font-family: var(--font-read); font-optical-sizing: auto; line-height: 1.55; }
.katex { font-size: 1.12em; }
.katex-display { margin: 0.6em 0; overflow-x: auto; overflow-y: hidden; padding: 0.15em 0; }

.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; stroke-width: 1.8; }

/* Whole-page navigation cross-fades; the sidebar stays put. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: vt-out var(--dur-2) var(--ease-in) both; }
::view-transition-new(root) { animation: vt-in var(--dur-3) var(--ease-out) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }
::view-transition-group(sidebar) { animation-duration: 0s; }
::view-transition-old(sidebar), ::view-transition-new(sidebar) { animation: none; }

@keyframes rise-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; scroll-behavior: auto !important; }
}
