/* ==========================================================================
   Personal Encyclopedia — Wikipedia (Vector 2022) inspired theme
   Light is the default. Dark/auto are opt-in via the Appearance panel.
   ========================================================================== */

/* ---------- Color tokens ---------- */
:root {
  --bg: #ffffff;
  --text: #202122;
  --muted: #54595d;
  --subtle: #72777d;
  --link: #3366cc;
  --link-visited: #6a60b0;
  --link-new: #d73333;
  --border: #a2a9b1;
  --border-soft: #c8ccd1;
  --soft: #eaecf0;
  --panel: #f8f9fa;
  --infohead: #cedff2;
  --accent: #3366cc;
  --accent-text: #ffffff;
  --mark: #fef6e7;
  --notice: #fef6e7;
  --notice-border: #fc3;
  --shadow: rgba(0, 0, 0, .15);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101418;
  --text: #eaecf0;
  --muted: #a2a9b1;
  --subtle: #8b9096;
  --link: #88a3e8;
  --link-visited: #a799e0;
  --link-new: #fd7865;
  --border: #54595d;
  --border-soft: #404244;
  --soft: #27292d;
  --panel: #1b1f23;
  --infohead: #233554;
  --accent: #6d8af0;
  --accent-text: #101418;
  --mark: #3d3416;
  --notice: #2e2a1a;
  --notice-border: #a58a1e;
  --shadow: rgba(0, 0, 0, .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #101418;
    --text: #eaecf0;
    --muted: #a2a9b1;
    --subtle: #8b9096;
    --link: #88a3e8;
    --link-visited: #a799e0;
    --link-new: #fd7865;
    --border: #54595d;
    --border-soft: #404244;
    --soft: #27292d;
    --panel: #1b1f23;
    --infohead: #233554;
    --accent: #6d8af0;
    --accent-text: #101418;
    --mark: #3d3416;
    --notice: #2e2a1a;
    --notice-border: #a58a1e;
    --shadow: rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ---------- Focus ring ----------
   One source of truth. Any element that clips (overflow other than visible)
   must reserve --focus-bleed of inline padding so rings, radio/checkbox edges
   and other things drawn outside their box are never cut off. */
:root {
  --focus-width: 2px;
  --focus-offset: 1px;
  --focus-bleed: calc(var(--focus-width) + var(--focus-offset) + 2px);
  --header-h: 3.5rem;
}

/* ---------- Text size (Appearance → Text) ---------- */
:root { --fs: 1rem; }
:root[data-text="small"] { --fs: .875rem; }
:root[data-text="large"] { --fs: 1.125rem; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Lato, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word; /* long URLs/words wrap instead of overflowing narrow columns */
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a:visited { color: var(--link-visited); }
a.new, a.new:visited { color: var(--link-new); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
img { max-width: 100%; height: auto; }
:focus-visible { outline: var(--focus-width) solid var(--accent); outline-offset: var(--focus-offset); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--bg); padding: .5rem 1rem; border: 1px solid var(--border);
}
.skip-link:focus { left: 1rem; top: .5rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  height: var(--header-h);
  display: flex; align-items: center; gap: .75rem;
  padding: 0 1.5rem;
  max-width: 100%;
}
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 1px; background: var(--border-soft);
}
.icon-btn {
  width: 2.25rem; height: 2.25rem; border-radius: 2px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.icon-btn:hover { background: var(--soft); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--text); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.logo { display: flex; align-items: center; gap: .55rem; color: var(--text) !important; text-decoration: none !important; min-width: 0; }
.logo-mark {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  border: 1.5px solid var(--text); display: grid; place-items: center;
  font: 700 1.15rem/1 Georgia, "Linux Libertine", serif; flex: none;
}
.logo-text { font-family: "Linux Libertine", Georgia, "Times New Roman", serif; font-size: 1.2rem; line-height: 1; letter-spacing: .04em; white-space: nowrap; }
.logo-text small { display: block; font: .68rem/1.2 sans-serif; letter-spacing: 0; color: var(--muted); margin-top: 3px; }

.search { flex: 1; max-width: 32rem; display: flex; margin-left: 1rem; }
.search-field { position: relative; flex: 1; }
.search input {
  width: 100%; height: 2.25rem;
  border: 1px solid var(--border); border-right: 0; border-radius: 2px 0 0 2px;
  padding: 0 .75rem 0 2.2rem;
  background: var(--bg); color: var(--text); font: inherit; font-size: .9rem;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.search-field svg { position: absolute; left: .65rem; top: .6rem; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search button {
  height: 2.25rem; padding: 0 .85rem; border: 1px solid var(--border);
  border-radius: 0 2px 2px 0; background: var(--panel); font-weight: 700; font-size: .9rem;
}
.search button:hover { background: var(--bg); }

.header-tools { display: flex; align-items: center; gap: .25rem; margin-left: auto; }

/* Main menu dropdown */
.menu {
  display: none; position: absolute; top: 3.25rem; left: 1rem; z-index: 50;
  min-width: 12rem; max-width: calc(100vw - 2rem); background: var(--bg); border: 1px solid var(--border);
  box-shadow: 0 2px 6px var(--shadow); padding: .5rem 0; font-size: .9rem;
}
.menu.open { display: block; }
.menu-title { font-size: .75rem; font-weight: 700; color: var(--muted); padding: .25rem 1rem; margin: 0; border-bottom: 1px solid var(--soft); }
.menu a { display: block; padding: .35rem 1rem; }

/* ---------- Layout ---------- */
.page {
  display: grid;
  grid-template-columns: 15.5rem minmax(0, 1fr) 11rem;
  gap: 0 2rem;
  max-width: 99.75rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}
:root[data-width="standard"] .page-main { max-width: 60rem; }
:root[data-width="wide"] .page-main { max-width: none; }

/* Side panels scroll vertically. Note: overflow-y:auto forces overflow-x to
   clip as well, so the panel reserves --focus-bleed on each side and pulls
   itself back out by the same amount: content stays aligned to the grid while
   rings and radio edges get room to render. */
.page-toc, .page-tools {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin;
  padding: 1.5rem var(--focus-bleed) 1rem;
  margin-inline: calc(-1 * var(--focus-bleed));
  font-size: .875rem;
}
.panel-heading {
  display: flex; justify-content: space-between; align-items: baseline;
  font-weight: 700; font-size: .875rem; margin: 0 0 .4rem;
  padding-bottom: .3rem; border-bottom: 1px solid var(--soft);
}

/* TOC */
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a { display: block; padding: .25rem 0 .25rem .5rem; border-left: 2px solid transparent; color: var(--link); line-height: 1.35; }
.toc a.active { color: var(--text); font-weight: 700; }
.toc .toc-sub a { padding-left: 1.4rem; font-size: .85rem; }

/* Appearance */
.appearance fieldset { border: 0; margin: 0 0 .9rem; padding: 0; }
.appearance legend { font-weight: 700; font-size: .8rem; padding: 0; margin-bottom: .25rem; }
.appearance label { display: flex; align-items: center; gap: .5rem; padding: .15rem 0; cursor: pointer; }
.appearance input { accent-color: var(--accent); margin: 0; width: 1rem; height: 1rem; flex: none; /* never squeezed by long labels */ }
.appearance .hint { color: var(--muted); font-size: .75rem; margin: .2rem 0 0; }

/* ---------- Article header ---------- */
.page-main { min-width: 0; font-size: var(--fs); }
.firstHeading {
  font-family: "Linux Libertine", Georgia, "Times New Roman", Times, serif;
  font-weight: 400; font-size: 1.8em; line-height: 1.375;
  margin: 1rem 0 0; padding: 0 0 .1rem;
  display: flex; align-items: center; gap: .5rem;
}
.toc-toggle { display: none; }

.tabs {
  display: flex; justify-content: space-between; flex-wrap: wrap;
  border-bottom: 1px solid var(--border); font-size: .875rem;
}
.tabs ul { list-style: none; display: flex; margin: 0; padding: 0; }
.tabs li { margin: 0; }
.tabs a, .tabs span {
  display: block; padding: .45rem .6rem .35rem; color: var(--link);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs .selected a, .tabs .selected span { color: var(--text); border-bottom-color: var(--text); }
.tabs a:hover { text-decoration: none; border-bottom-color: var(--link); }

.tagline { color: var(--muted); font-size: .875em; margin: .6rem 0 .5rem; }

/* ---------- Article body ---------- */
.content { padding-bottom: 2rem; }
.content h2 {
  font-family: "Linux Libertine", Georgia, "Times New Roman", Times, serif;
  font-weight: 400; font-size: 1.5em; line-height: 1.375;
  border-bottom: 1px solid var(--border); margin: 1.1em 0 .25em; padding: 0;
}
.content h3 { font-size: 1.2em; font-weight: 700; line-height: 1.6; margin: .9em 0 .3em; }
.content h4 { font-size: 1em; font-weight: 700; margin: .9em 0 .3em; }
.content p { margin: .5em 0 1em; }
.content ul, .content ol { margin: .3em 0 .8em 1.6em; padding: 0; }
.content li { margin-bottom: .1em; }
.content blockquote { margin: 1em 2em; padding: 0 1em; border-left: 4px solid var(--soft); }

.hatnote { padding-left: 1.6em; font-style: italic; margin: 0 0 .8em; }

sup.reference { font-size: .75em; line-height: 0; font-style: normal; white-space: nowrap; }

/* Infobox */
.infobox {
  float: right; clear: right; width: 22em;
  margin: .5em 0 1em 1.4em; padding: .2em;
  border: 1px solid var(--border); background: var(--panel);
  font-size: 88%; line-height: 1.5; border-spacing: 3px;
}
.infobox-title { text-align: center; font-weight: 700; font-size: 125%; padding: .2em .4em; margin: 0 0 .2em; line-height: 1.3; }
.infobox-image { text-align: center; margin: .3em 0; padding: 0 .3em; }
.infobox-image img, .image-placeholder {
  width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block;
  background: var(--soft); border: 0;
}
.image-placeholder { display: grid; place-items: center; color: var(--muted); font-size: .85em; padding: 1rem; }
.image-placeholder svg { width: 45%; fill: var(--border); margin: 0 auto .4rem; display: block; }
.infobox-caption { font-size: 95%; padding: .25em 0 .1em; }
.infobox table { width: 100%; border-collapse: separate; border-spacing: 0 3px; }
.infobox th { text-align: left; vertical-align: top; padding: .1em .6em .1em .3em; width: 36%; font-weight: 700; }
.infobox td { vertical-align: top; padding: .1em .3em; }
.infobox .infobox-header { text-align: center; background: var(--infohead); padding: .2em; width: auto; }

.infobox-image img { aspect-ratio: auto; height: auto; }

/* Thumbnails (Wikipedia "thumb" figures) */
.thumb {
  float: right; clear: right; width: 222px;
  margin: .5em 0 1.2em 1.4em; padding: 3px;
  border: 1px solid var(--border-soft); background: var(--panel);
}
.thumb.left { float: left; clear: left; margin: .5em 1.4em 1.2em 0; }
.thumb.wide { width: 302px; }
.thumb img { display: block; width: 100%; height: auto; background: var(--soft); }
.thumb figcaption { font-size: .85em; line-height: 1.45; padding: .35em .2em .15em; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 1em calc(-1 * var(--focus-bleed)); padding: var(--focus-bleed); }
table.wikitable { border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); font-size: .95em; }
.wikitable caption { font-weight: 700; padding: .2em; text-align: center; }
.wikitable th, .wikitable td { border: 1px solid var(--border); padding: .25em .6em; text-align: left; }
.wikitable th { background: var(--soft); text-align: center; }

/* References */
.references { font-size: 90%; column-width: 30em; column-gap: 2em; margin-left: 1.8em !important; }
.references li { break-inside: avoid; margin-bottom: .3em; }
.references li:target { background: var(--mark); }
.references .backlink { font-weight: 700; margin-right: .25em; }

/* Notices (e.g. protection / private) */
.notice {
  display: flex; gap: .9rem; align-items: center;
  border: 1px solid var(--border); border-left: 10px solid var(--notice-border);
  background: var(--notice); padding: .6rem 1rem; margin: 1rem 0; font-size: .9em;
}
.notice svg { width: 2.2rem; height: 2.2rem; flex: none; fill: none; stroke: var(--text); stroke-width: 1.6; }

/* Categories */
.catlinks {
  clear: both; border: 1px solid var(--border); background: var(--panel);
  padding: .4em .8em; margin-top: 2rem; font-size: .875em;
}
.catlinks ul { display: inline; list-style: none; margin: 0 !important; padding: 0; }
.catlinks li { display: inline; padding: 0 .5em; border-left: 1px solid var(--border-soft); margin: 0; }
.catlinks li:first-child { border-left: 0; }

/* Search hit flash */
.search-hit { background: var(--mark); transition: background 1.5s ease; }

/* ---------- Lock screen (pvt.html) ---------- */
.lock-form { max-width: 24rem; margin: 2rem 0; border: 1px solid var(--border); background: var(--panel); padding: 1.2rem; }
.lock-form label { font-weight: 700; font-size: .9rem; }
.lock-form input {
  width: 100%; height: 2.4rem; margin: .4rem 0 .6rem;
  border: 1px solid var(--border); border-radius: 2px;
  background: var(--bg); color: var(--text); padding: 0 .6rem; font: inherit;
}
.btn { background: var(--accent); color: var(--accent-text); padding: .45rem 1rem; border-radius: 2px; font-weight: 700; font-size: .9rem; }
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .6; cursor: progress; }
.lock-error { color: var(--link-new); min-height: 1.4em; font-size: .85rem; margin: .5rem 0 0; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 99.75rem; margin: 0 auto; padding: 1.25rem 1.5rem 2.5rem;
  font-size: .75rem; color: var(--text);
}
.site-footer .footer-inner { border-top: 1px solid var(--border-soft); padding-top: 1rem; margin-left: 17.5rem; }
.site-footer p { margin: 0 0 .5rem; }
.site-footer ul { list-style: none; margin: .75rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .page { grid-template-columns: 15.5rem minmax(0, 1fr); }
  .page-tools {
    display: none; position: fixed; top: 3.25rem; right: 1rem; z-index: 50;
    width: min(14rem, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem); max-height: calc(100dvh - 4rem);
    padding: .8rem 1rem; margin: 0;
    background: var(--bg); border: 1px solid var(--border); box-shadow: 0 2px 6px var(--shadow);
  }
  .page-tools.open { display: block; }
}
@media (min-width: 1201px) {
  .appearance-btn { display: none; }
}
@media (max-width: 1000px) {
  .page { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
  .site-header { padding: 0 1rem; }
  .page-toc {
    display: none; position: fixed; top: 3.25rem; left: 1rem; z-index: 50;
    width: min(20rem, calc(100vw - 2rem));
    max-height: calc(100vh - 5rem); max-height: calc(100dvh - 5rem);
    background: var(--bg); border: 1px solid var(--border); box-shadow: 0 2px 6px var(--shadow);
    padding: .8rem 1rem; margin: 0;
  }
  .page-toc.open { display: block; }
  .toc-toggle { display: inline-flex; }
  .site-footer { padding: 1.25rem 1rem 2rem; }
  .site-footer .footer-inner { margin-left: 0; }
}
@media (max-width: 720px) {
  .logo-text small { display: none; }
  .search { margin-left: .25rem; }
  .search button { display: none; }
  .search input { border-right: 1px solid var(--border); border-radius: 2px; }
  .infobox { float: none; width: 100%; margin: .5em 0 1em; }
  .thumb, .thumb.left, .thumb.wide { float: none; width: auto; max-width: 22rem; margin: 1em auto; }
}
@media (max-width: 520px) {
  .site-header { gap: .35rem; padding: 0 .5rem; }
  .logo-text { display: none; }
  .firstHeading { font-size: 1.6em; }
  .tabs a, .tabs span { padding: .45rem .45rem .35rem; }
}

/* ---------- Print ---------- */
@media print {
  .site-header, .page-toc, .page-tools, .tabs, .skip-link, .catlinks { display: none !important; }
  .page { display: block; padding: 0; }
  a { color: inherit; }
  .infobox { border-color: #000; }
}
