/* Base: the encyclopedia's variables remapped onto the house tokens, reset,
   typography, the page ground, focus, icons, utilities, reduced motion, print. */

/* The encyclopedia's own variable names, remapped onto the house tokens
   (tokens.css), so every component follows both themes from one place.
   Its green "accent" (done, correct, positive) is the house --ok: the house
   --accent is the indigo pen, which the encyclopedia calls "primary".
   --surface, --surface-2, --surface-3, --warn, --warn-soft and --ease share the
   house names and values. */
:root {
  --font: var(--font-body);
  --mono: var(--font-mono);

  --bg: var(--paper);
  --glass: color-mix(in srgb, var(--paper) 75%, transparent);
  --text: var(--ink);
  --text-2: var(--ink-2);
  --muted: var(--ink-3);
  --border: var(--rule);
  --border-2: var(--rule-strong);

  --primary: var(--accent);
  --primary-2: var(--accent-hover);
  --primary-soft: var(--accent-soft);
  --primary-text: var(--accent);
  --on-primary: var(--accent-ink);

  --warn-text: var(--warn);
  --on-warn: light-dark(#ffffff, #060913);
  /* Brighter amber for small fills: the partial-progress dot and the favourite star. */
  --amber: light-dark(#d97706, #fbbf24);

  --danger: var(--bad);
  --danger-soft: var(--bad-soft);
  --danger-text: var(--bad);

  /* Information wears the house teal (the site's cyan family). */
  --info: var(--teal);
  --info-soft: var(--teal-soft);
  --info-text: var(--teal);
  --on-info: light-dark(#ffffff, #060913);

  --shadow-sm: var(--shadow-1);
  --shadow: var(--shadow-2);
  --shadow-lg: 0 28px 60px -24px light-dark(rgb(15 23 42 / 0.3), rgb(0 0 0 / 0.8)), 0 4px 12px light-dark(rgb(15 23 42 / 0.08), rgb(0 0 0 / 0.45));
  /* Focus ring drawn inside the box, for controls that fill a clipped parent. */
  --focus-ring-inset: inset 0 0 0 3px light-dark(rgb(14 116 144 / 0.55), rgb(34 211 238 / 0.6));

  --radius: var(--r-lg);
  --radius-sm: var(--r-md);
  --radius-xs: var(--r-sm);

  --sidebar-w: 292px;
  --header-h: var(--topbar-height);
  --content-w: 1120px;
}

/* ------------------------------------------------------------------ reset & type */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.8;
  font-feature-settings: "tnum" 1, "kern" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.25s var(--ease), color 0.25s var(--ease);
}

/* Two soft glows behind the top of every page, as on the main site. */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 900px;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38rem 26rem at 12% 8%, var(--glow-1), transparent 70%),
    radial-gradient(34rem 24rem at 88% 22%, var(--glow-2), transparent 70%);
}

h1,
h2,
h3,
h4 {
  margin: 0 0 0.5em;
  color: var(--text);
  font-weight: 700;
  line-height: var(--lh-tight);
  text-wrap: balance;
}

/* Headings use the display face (Noto Kufi Arabic); Kufi needs tall leading and no tracking. */
h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: var(--weight-display);
  letter-spacing: var(--tracking-display);
}

h1 {
  font-size: 1.9rem;
  line-height: var(--lh-display);
}

h2 {
  font-size: 1.45rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1.02rem;
}

p {
  margin: 0 0 0.9em;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--primary-text);
  text-decoration: none;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  padding-inline-start: 1.4em;
  margin: 0.4em 0 0.9em;
}

li {
  margin-bottom: 0.3em;
}

li::marker {
  color: var(--muted);
}

strong {
  font-weight: 700;
  color: var(--text);
}

code {
  display: inline-block;
  padding: 0 0.4em;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--primary-text);
  font-family: var(--mono);
  font-size: 0.86em;
  line-height: 1.55;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

img,
svg {
  max-width: 100%;
}

::selection {
  background: var(--selection);
}

/* ------------------------------------------------------------------ focus */

/* The house focus ring (cyan). The transparent outline keeps focus visible in forced-colours mode. */
:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

a:not([class]):focus-visible,
.tl:focus-visible {
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  inset-inline-start: 12px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.skip-link:hover {
  color: var(--accent-ink);
  text-decoration: none;
}

/* ------------------------------------------------------------------ icons */

.ic {
  width: 20px;
  height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -4px;
}

.ic-sm {
  width: 16px;
  height: 16px;
}

.ic-lg {
  width: 26px;
  height: 26px;
}

.ic-xl {
  width: 34px;
  height: 34px;
}

/* The <symbol> sprite the icons <use>; hidden without an inline style (CSP). */
.icon-sprite {
  display: none;
}

/* ------------------------------------------------------------------ utilities */

[hidden] {
  display: none !important;
}

.ltr {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
}

.num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.88rem;
}

.center {
  text-align: center;
}

.flush {
  margin: 0;
}

/* Gradient ink for the one phrase a page is about (the site's name treatment). */
.grad-text {
  background-image: var(--text-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* ------------------------------------------------------------------ motion & print */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .sidebar,
  .topbar,
  .site-foot,
  .term-nav,
  .btn,
  .overlay,
  .skip-link {
    display: none !important;
  }

  .shell {
    grid-template-columns: 1fr;
  }

  .panel-b {
    display: block !important;
  }
}
