/* Jargon File stylesheet. Mobile first; light and dark themes via custom properties. */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f2f0ea;
  --text: #1d2127;
  --muted: #5b636d;
  --border: #dad6cc;
  --accent: #1f56c4;
  --accent-soft: #e3ebfa;
  --on-accent: #ffffff;
  --in: #2b7a57;
  --out: #1f56c4;
  --code-bg: #f3f1ec;
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 18px rgba(0, 0, 0, .08);
  --radius: 10px;
  --hh: 3.5rem;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15181c;
    --surface: #1d2127;
    --surface-2: #252a31;
    --text: #e8e6e1;
    --muted: #a3abb5;
    --border: #353b44;
    --accent: #8db4ff;
    --accent-soft: #26334d;
    --on-accent: #0b1020;
    --in: #6fcf9f;
    --out: #8db4ff;
    --code-bg: #1a1e23;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #15181c;
  --surface: #1d2127;
  --surface-2: #252a31;
  --text: #e8e6e1;
  --muted: #a3abb5;
  --border: #353b44;
  --accent: #8db4ff;
  --accent-soft: #26334d;
  --on-accent: #0b1020;
  --in: #6fcf9f;
  --out: #8db4ff;
  --code-bg: #1a1e23;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }
html:not(.js) .js-only { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: clamp(16px, .92rem + .25vw, 19px);
  scroll-padding-top: calc(var(--hh) + 3.25rem);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.6 var(--sans);
  overflow-wrap: break-word;
}

body.is-index { --hh: 3.5rem; }

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.25rem clamp(1rem, 4vw, 2rem) 2.5rem;
}

a { color: var(--accent); text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

.skip { position: absolute; left: -999px; top: 0; }
.skip:focus {
  left: .5rem; top: .5rem; z-index: 100; padding: .5rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
}

/* ---------- header ---------- */

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.bar {
  display: flex; align-items: center; gap: .5rem;
  max-width: 72rem; min-height: var(--hh); margin: 0 auto;
  padding: .5rem clamp(1rem, 4vw, 2rem);
}

.brand {
  font: 700 1.2rem/1 var(--serif); letter-spacing: .01em;
  color: var(--text); text-decoration: none; white-space: nowrap; margin-right: auto;
}
.brand:hover { color: var(--accent); }

.search { position: relative; flex: 1 1 18rem; min-width: 0; max-width: 30rem; }
.q {
  display: block; width: 100%; padding: .5rem .9rem;
  font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  -webkit-appearance: none; appearance: none;
}
.q::placeholder { color: var(--muted); }

.sr {
  position: absolute; z-index: 30; top: calc(100% + .35rem); left: 0; right: 0;
  margin: 0; padding: .3rem; list-style: none;
  max-height: min(60vh, 26rem); overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.sr li a {
  display: block; padding: .45rem .65rem; border-radius: 6px;
  color: var(--text); text-decoration: none;
}
.sr li a:hover, .sr li[aria-selected="true"] a { background: var(--accent-soft); }
.sr small {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; color: var(--muted); font-size: .82rem; line-height: 1.35;
}
.sr .none { padding: .6rem .7rem; color: var(--muted); }

.btn {
  font: inherit; font-size: .9rem; color: var(--text); cursor: pointer;
  min-height: 2.4rem; padding: .35rem .85rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.btn:hover { background: var(--accent-soft); }

@media (max-width: 540px) {
  :root { --hh: 6.7rem; }
  .bar { flex-wrap: wrap; }
  .brand { order: 1; }
  #random { order: 2; }
  #theme { order: 3; }
  .search { order: 4; flex-basis: 100%; max-width: none; }
  body.is-index { --hh: 3.5rem; }
  body.is-notfound, body.is-index { --hh: 3.5rem; }
}

/* ---------- index ---------- */

.hero h1 {
  margin: .5rem 0 .25rem; font: 700 clamp(2rem, 6vw, 3.4rem)/1.1 var(--serif);
}
.lede { margin: 0 0 1rem; font-size: 1.15rem; color: var(--muted); }
.hero-search { max-width: 38rem; margin: 1rem 0; }
.hero-search .q { padding: .8rem 1.15rem; font-size: 1.1rem; }
.tools { margin: 0 0 1rem; }
.intro { max-width: 46rem; color: var(--muted); }

.eotd, .results, .popular { margin: 1.25rem 0; }
.eotd {
  padding: 1rem 1.25rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.eyebrow { margin: 0; font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.eotd h2 { margin: .15rem 0; font: 700 1.5rem/1.2 var(--serif); }
.eotd p { margin: 0; }

h2 { font: 700 1.2rem/1.3 var(--serif); }
.results h2, .popular h2 { margin: 0 0 .5rem; }

.result-list { margin: 0; padding: 0; list-style: none; }
.result-list li { padding: .55rem 0; border-bottom: 1px solid var(--border); }
.result-list a { font-weight: 600; }
.result-list p { margin: .1rem 0 0; color: var(--muted); font-size: .92rem; }

.az {
  position: sticky; top: var(--hh); z-index: 10;
  display: flex; flex-wrap: wrap; gap: .15rem;
  margin: 1rem 0 0; padding: .5rem 0;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.az a {
  min-width: 2rem; padding: .25rem .45rem; text-align: center;
  font-weight: 600; text-decoration: none; border-radius: 6px;
}
.az a:hover { background: var(--accent-soft); }

.group h2 {
  margin: 1.75rem 0 .6rem; padding-bottom: .25rem;
  border-bottom: 1px solid var(--border); font-size: 1.6rem;
}
.entries {
  margin: 0; padding: 0; list-style: none; columns: 15rem; column-gap: 2rem;
}
.entries li { break-inside: avoid; }
.entries a { display: block; padding: .18rem 0; text-decoration: none; }
.entries a:hover { text-decoration: underline; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 0; padding: 0; list-style: none; }
.chips a {
  display: inline-block; padding: .25rem .75rem; color: var(--text); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
}
.chips a:hover { background: var(--accent-soft); border-color: var(--accent); }
.chips li { display: flex; align-items: center; gap: .35rem; }
.chips.ranked .count { margin-left: -.2rem; }
.count { color: var(--muted); font: .8rem var(--sans); }

/* ---------- entry ---------- */

.entry article { max-width: 68ch; }
.entry h1 { margin: .4rem 0 .1rem; font: 700 clamp(1.9rem, 5vw, 2.9rem)/1.15 var(--serif); }
.pron { margin: .2rem 0 1.25rem; font: italic 1.05rem var(--serif); color: var(--muted); }

.text { font: 1.08rem/1.7 var(--serif); }
.text p { margin: 0 0 1rem; }
.text a.ref { text-decoration-style: dotted; text-decoration-thickness: 1px; }
.text a.ref:hover { text-decoration-style: solid; }

.sense { position: relative; padding-left: 2.3rem; border-radius: 6px; }
.sense .num {
  position: absolute; left: 0; width: 1.9rem; text-align: right;
  font: 600 .85rem/1.9 var(--sans); color: var(--muted); text-decoration: none;
}
.sense .num:hover, .sense .num:focus-visible { color: var(--accent); text-decoration: underline; }
.sense:target { background: var(--accent-soft); outline: 6px solid var(--accent-soft); }
.sense .num.copied::after {
  content: "Link copied"; position: absolute; left: 2.3rem; top: -1.6rem; white-space: nowrap;
  padding: .1rem .5rem; font: .75rem var(--sans); color: var(--on-accent); background: var(--accent);
  border-radius: 4px;
}

.text pre {
  margin: 0 0 1rem; padding: .75rem 1rem; overflow-x: auto; tab-size: 8;
  font: .86rem/1.45 var(--mono); background: var(--code-bg);
  border: 1px solid var(--border); border-radius: 8px;
  -webkit-overflow-scrolling: touch;
}
.text figure { margin: 1rem 0; }
.text img { max-width: 100%; height: auto; background: #fff; border-radius: 6px; }

.connections { margin-top: 2.5rem; }
.connections h2, .refs h2 { margin: 1.5rem 0 .25rem; }
.legend { margin: 0 0 .75rem; color: var(--muted); font-size: .92rem; }

.graph-wrap {
  padding: .5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.graph { display: block; width: 100%; height: auto; font: 13px var(--sans); }
.graph-v { display: none; max-width: 26rem; margin-inline: auto; }
@media (max-width: 600px) {
  .graph-h { display: none; }
  .graph-v { display: block; }
}
.graph .node { cursor: pointer; text-decoration: none; outline: none; }
.node rect { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.node text { fill: var(--text); text-anchor: middle; pointer-events: none; }
.node.in rect { stroke: var(--in); stroke-width: 1.5; }
.node.out rect { stroke: var(--out); stroke-width: 1.5; }
.node.both rect { stroke: var(--in); stroke-width: 1.5; stroke-dasharray: 5 2; fill: var(--accent-soft); }
.node.more rect { fill: none; stroke-dasharray: 3 3; }
.node.center rect { fill: var(--accent); stroke: none; }
.node.center text { fill: var(--on-accent); font-weight: 700; }
a.node:hover rect, a.node:focus-visible rect { fill: var(--accent-soft); stroke: var(--text); stroke-width: 2; }
.edge { fill: none; stroke: var(--muted); stroke-width: 1.2; opacity: .55; }
.mk { fill: var(--muted); }

.graph-actions { display: flex; justify-content: flex-end; margin: .5rem 0 0; }
.graph-live {
  display: block; width: 100%; height: min(70vh, 32rem); touch-action: none; user-select: none;
  background: var(--surface); border-radius: 6px;
}
.gl-edge { stroke: var(--muted); stroke-width: 1.2; opacity: .45; fill: none; }
.gl-node circle { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; cursor: grab; }
.gl-node.in circle { stroke: var(--in); }
.gl-node.out circle { stroke: var(--out); }
.gl-node.both circle { stroke: var(--in); stroke-dasharray: 4 2; }
.gl-node.far circle { opacity: .75; }
.gl-node.center circle { fill: var(--accent); stroke: none; }
.gl-node text {
  font: 12px var(--sans); fill: var(--text); text-anchor: middle; pointer-events: none;
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}
.graph-live.dim .gl-edge { opacity: .08; }
.graph-live.dim .gl-node { opacity: .35; }
.graph-live.dim .gl-edge.on { opacity: .9; stroke: var(--accent); stroke-width: 2; }
.graph-live.dim .gl-node.on { opacity: 1; }
.gl-node:focus-visible circle { stroke: var(--text); stroke-width: 3; }
.gl-node { outline: none; }
.gl-node.far text { display: none; }
.gl-node.far:hover text, .gl-node.far:focus text, .gl-node.far.on text { display: block; }

.pager {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem 1rem;
  margin-top: 2.5rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.pager a { text-decoration: none; max-width: 40%; }
.pager a:hover { text-decoration: underline; }
.pager [rel="next"] { text-align: right; }
@media (max-width: 520px) { .pager a { max-width: 100%; } }

#peek {
  position: absolute; z-index: 40; width: max-content; max-width: min(22rem, calc(100vw - 1.5rem));
  padding: .6rem .85rem; font: .88rem/1.45 var(--sans);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  pointer-events: none;
}
#peek strong { font-family: var(--serif); font-size: 1rem; }
#peek em { display: block; color: var(--muted); }
#peek span { display: block; margin-top: .2rem; }

.notfound h1 { margin-top: .5rem; font: 700 2rem/1.2 var(--serif); }
code { font: .9em var(--mono); background: var(--code-bg); padding: .1em .35em; border-radius: 4px; overflow-wrap: anywhere; }

.site-footer {
  flex-shrink: 0; margin-top: 1rem; padding: 1.25rem clamp(1rem, 4vw, 2rem);
  color: var(--muted); font-size: .85rem; text-align: center; border-top: 1px solid var(--border);
}
.site-footer p { margin: 0 auto; max-width: 60rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .site-header, .site-footer, .az, .pager, .connections, .search, .btn, .skip { display: none !important; }
  body { background: #fff; color: #000; display: block; }
  main { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .text pre { border-color: #999; background: #fff; }
}
