
/* ── Custom Properties ── */
:root {
  --bg:          #ffffff;
  --bg-2:        #f8f9fa;
  --bg-3:        #eaecf0;
  --text:        #202122;
  --text-2:      #54595d;
  --border:      #a2a9b1;
  --accent:      #B8860B;
  --accent-dim:  #8B6914;
  --link:        #7a5c00;
  --link-v:      #5a4400;
  --link-h:      #B8860B;
  --header-bg:   #1a1a1a;
  --header-text: #f0f0f0;
  --infobox-bg:  #f8f9fa;
  --toc-bg:      #f8f9fa;
  --code-bg:     #f8f9fa;
  --shadow:      rgba(0,0,0,.08);
  --callout-border: #B8860B;
}

body.dark {
  --bg:         #313131;
  --bg-2:       #3d3d3d;
  --bg-3:       #494949;
  --text:       #e8e8e8;
  --text-2:     #aaaaaa;
  --border:     #555555;
  --link:       #D4A017;
  --link-v:     #c49010;
  --link-h:     #F0C040;
  --infobox-bg: #3d3d3d;
  --toc-bg:     #3d3d3d;
  --code-bg:    #272727;
  --shadow:     rgba(0,0,0,.3);
}

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Linux Libertine', Georgia, 'Times New Roman', Times, serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  transition: background .2s, color .2s;
}

/* ── Header ── */
.site-header {
  background: var(--header-bg);
  border-bottom: 3px solid var(--accent);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px var(--shadow);
}
.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.site-logo {
  font-family: 'Linux Libertine', Georgia, serif;
  font-size: 1.35rem;
  font-weight: bold;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: .03em;
  flex-shrink: 0;
}
.site-logo:hover { color: var(--link-h); }

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  flex: 1;
  overflow: hidden;
}
.section-nav a {
  color: #b0b0b0;
  text-decoration: none;
  font-family: Arial, Helvetica, sans-serif;
  font-size: .76rem;
  padding: .28rem .55rem;
  border-radius: 3px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.section-nav a:hover { background: #2a2a2a; color: #fff; }
.section-nav a.active {
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}

.header-controls { display: flex; gap: .4rem; flex-shrink: 0; }

.btn-dm, .btn-dark {
  background: transparent;
  border: 1px solid #555;
  color: #999;
  cursor: pointer;
  padding: .28rem .6rem;
  border-radius: 3px;
  font-family: Arial, sans-serif;
  font-size: .76rem;
  transition: border-color .15s, color .15s;
}
.btn-dm:hover, .btn-dark:hover { border-color: var(--accent); color: var(--accent); }
body.dm-mode .btn-dm {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(184,134,11,.12);
}

/* ── Page Layout ── */
.page-wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
}

.breadcrumb {
  font-family: Arial, sans-serif;
  font-size: .8rem;
  color: var(--text-2);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--link); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; color: var(--link-h); }

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
.content-grid.has-sidebar {
  grid-template-columns: 1fr 240px;
}

/* ── Article ── */
.article { min-width: 0; }

.article-title {
  font-size: 1.95rem;
  font-weight: normal;
  border-bottom: 1px solid var(--border);
  padding-bottom: .35rem;
  margin-bottom: .85rem;
  color: var(--text);
}

.article-body h2 {
  font-size: 1.4rem;
  font-weight: normal;
  border-bottom: 1px solid var(--border);
  padding-bottom: .2rem;
  margin: 1.8rem 0 .7rem;
  color: var(--text);
}
.article-body h3 {
  font-size: 1.15rem;
  margin: 1.4rem 0 .45rem;
  color: var(--text);
}
.article-body h4 {
  font-size: 1rem;
  font-weight: bold;
  margin: 1rem 0 .35rem;
  color: var(--text);
}

.article-body p { margin: .65rem 0; }
.article-body p:first-child { margin-top: 0; }

.article-body a { color: var(--link); text-decoration: none; }
.article-body a:visited { color: var(--link-v); }
.article-body a:hover { text-decoration: underline; color: var(--link-h); }

.wiki-missing {
  color: #aa0000;
  text-decoration: underline dotted;
  cursor: not-allowed;
}
body.dark .wiki-missing { color: #ff6060; }

.article-body ul, .article-body ol { margin: .5rem 0 .5rem 1.6rem; }
.article-body li { margin: .18rem 0; }

.article-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: .9rem;
  overflow-x: auto;
  display: block;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: .35rem .65rem;
  text-align: left;
  vertical-align: top;
}
.article-body th {
  background: var(--bg-2);
  font-weight: bold;
  white-space: nowrap;
}
.article-body tr:nth-child(even) td { background: var(--bg-2); }

.article-body code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .1rem .35rem;
  font-size: .86em;
  font-family: 'Courier New', Courier, monospace;
}
.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}
.article-body pre code { background: none; border: none; padding: 0; }

.article-body blockquote {
  border-left: 3px solid var(--accent);
  padding: .5rem 1rem;
  margin: 1rem 0;
  background: var(--bg-2);
  color: var(--text-2);
}

.article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.article-body strong { font-weight: bold; }
.article-body em { font-style: italic; }

/* ── Infobox ── */
.infobox {
  float: right;
  margin: 0 0 1rem 1.5rem;
  min-width: 200px;
  max-width: 280px;
  border: 1px solid var(--border);
  background: var(--infobox-bg);
  font-size: .87rem;
  clear: right;
}
.infobox th {
  padding: .3rem .6rem;
  font-weight: bold;
  background: var(--bg-3);
  border: 1px solid var(--border);
  white-space: nowrap;
  color: var(--text);
}
.infobox td {
  padding: .3rem .6rem;
  border: 1px solid var(--border);
  color: var(--text);
}

/* ── TOC ── */
.toc {
  background: var(--toc-bg);
  border: 1px solid var(--border);
  padding: .7rem 1rem;
  display: inline-block;
  min-width: 180px;
  max-width: 320px;
  margin: 0 0 1.4rem 0;
  font-size: .87rem;
}
.toc-title {
  font-weight: bold;
  font-family: Arial, sans-serif;
  margin-bottom: .4rem;
}
.toc ol { margin: 0; padding-left: 1.2rem; }
.toc li { margin: .12rem 0; }
.toc a { color: var(--link); text-decoration: none; }
.toc a:hover { text-decoration: underline; color: var(--link-h); }

/* Sidebar TOC */
.sidebar { grid-column: 2; }
.sidebar-sticky {
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.sidebar .toc {
  margin: 0;
  max-width: 100%;
  width: 100%;
  display: block;
}

/* Yggy browse panel in sidebar */
.yggy-browse-panel {
  border: 1px solid var(--border);
  background: var(--toc-bg);
  padding: .7rem;
  font-size: .87rem;
}
.browse-panel-title {
  font-weight: bold;
  font-family: Arial, sans-serif;
  margin-bottom: .6rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--border);
  color: var(--accent);
}
.yggy-cards-grid { display: flex; flex-direction: column; gap: .25rem; }
.yggy-card {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .45rem;
  border-radius: 3px;
  text-decoration: none;
  color: var(--link);
  transition: background .12s;
  font-size: .85rem;
}
.yggy-card:hover { background: var(--bg-3); color: var(--link-h); }
.yggy-card-icon { font-size: 1rem; flex-shrink: 0; }
.yggy-card-label { flex: 1; }
.yggy-card-count {
  font-size: .75rem;
  color: var(--text-2);
  background: var(--bg-3);
  padding: .1rem .35rem;
  border-radius: 10px;
}

/* ── Tag Pills ── */
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .85rem;
}
.tag-pill {
  font-family: Arial, sans-serif;
  font-size: .72rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .1rem .5rem;
  color: var(--text-2);
  text-transform: lowercase;
}

/* ── Callouts ── */
.callout {
  border-left: 4px solid var(--accent);
  background: var(--bg-2);
  padding: .7rem 1rem;
  margin: 1rem 0;
  border-radius: 0 4px 4px 0;
}
.callout-title {
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--accent);
  margin-bottom: .35rem;
}
.callout-body p:first-child { margin-top: 0; }
.callout-body p:last-child  { margin-bottom: 0; }

/* callout-info floats right as a Wikipedia-style infobox */
.callout-info {
  float: right;
  clear: right;
  margin: 0 0 1.2rem 1.5rem;
  width: 240px;
  min-width: 180px;
  max-width: 260px;
  border: 1px solid var(--border);
  border-top: 3px solid #4a9eff;
  border-left: 1px solid var(--border);
  background: var(--infobox-bg);
  border-radius: 0 0 4px 4px;
  padding: 0;
  font-size: .86rem;
}
.callout-info .callout-title {
  color: #4a9eff;
  text-align: center;
  padding: .4rem .6rem;
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  margin: 0;
}
.callout-info .callout-body {
  padding: .4rem .5rem;
}
.callout-info .callout-body p {
  margin: 0 0 .4rem;
}
/* Image inside infobox */
.callout-img {
  width: 100%;
  display: block;
  border-bottom: 1px solid var(--border);
  margin-bottom: .4rem;
}
/* Table inside callout-info infobox */
.callout-info table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
  display: table;
  overflow-x: visible;
  margin: 0;
}
.callout-info thead { display: none; }
.callout-info th, .callout-info td {
  border: none;
  border-bottom: 1px solid var(--bg-3);
  padding: .18rem .3rem;
  vertical-align: top;
  text-align: left;
  white-space: normal;
}
.callout-info th {
  background: none;
  font-weight: normal;
  color: var(--text-2);
  width: 42%;
}
.callout-info tr:last-child th,
.callout-info tr:last-child td { border-bottom: none; }

.callout-warning { border-color: #ff9500; }
.callout-warning .callout-title { color: #ff9500; }
.callout-danger  { border-color: #ff3b30; }
.callout-danger  .callout-title { color: #ff3b30; }
.callout-note    { border-color: var(--accent); }
.callout-note    .callout-title { color: var(--accent); }
.callout-dm-only { border-color: var(--accent); background: rgba(184,134,11,.08); }
.callout-dm-only .callout-title { color: var(--accent); }

@media (max-width: 700px) {
  .callout-info {
    float: none;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
  }
}

/* ── DM Only ── */
.dm-only         { display: none !important; }
span.dm-only     { display: none !important; }
body.dm-mode .dm-only      { display: block  !important; }
body.dm-mode span.dm-only  { display: inline !important; }

.dm-page-badge {
  display: inline-block;
  background: rgba(184,134,11,.12);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: Arial, sans-serif;
  font-size: .8rem;
  padding: .35rem .8rem;
  border-radius: 4px;
  margin-bottom: .9rem;
}

/* ── Section Notice ── */
.section-notice {
  background: #fff8e6;
  border: 1px solid #e6c34a;
  border-left: 4px solid #cc9900;
  color: #5a4200;
  font-family: Arial, sans-serif;
  font-size: .83rem;
  padding: .5rem .85rem;
  border-radius: 0 4px 4px 0;
  margin-bottom: 1rem;
}
body.dark .section-notice {
  background: rgba(200,160,0,.08);
  border-color: #8a6800;
  border-left-color: #b88f00;
  color: #d4a800;
}

/* ── Index Section Lists ── */
.index-list-heading {
  font-family: Arial, sans-serif;
  font-size: .85rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin: 1.5rem 0 .5rem;
  padding-bottom: .25rem;
  border-bottom: 1px solid var(--border);
}
.index-list {
  list-style: none;
  padding: 0;
  columns: 2;
  column-gap: 2rem;
}
.index-list li {
  padding: .25rem 0;
  border-bottom: 1px solid var(--bg-3);
  break-inside: avoid;
  font-size: .93rem;
}
.index-list a { color: var(--link); text-decoration: none; }
.index-list a:hover { text-decoration: underline; color: var(--link-h); }

/* ── Dataview Notice (fallback) ── */
.dataview-notice {
  background: var(--bg-2);
  border: 1px dashed var(--border);
  padding: .5rem 1rem;
  border-radius: 4px;
  color: var(--text-2);
  font-family: Arial, sans-serif;
  font-size: .83rem;
  margin: 1rem 0;
}

/* ── Dataview Tables ── */
.dataview-table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: .9rem;
  overflow-x: auto;
  display: block;
}
.dataview-table th, .dataview-table td {
  border: 1px solid var(--border);
  padding: .32rem .6rem;
  text-align: left;
  vertical-align: top;
}
.dataview-table th {
  background: var(--bg-3);
  font-weight: bold;
  font-family: Arial, sans-serif;
  font-size: .82rem;
  white-space: nowrap;
}
.dataview-table tr:nth-child(even) td { background: var(--bg-2); }

/* ── Dataview Lists ── */
.dataview-list {
  list-style: none;
  padding: 0;
  margin: .5rem 0 1rem;
  columns: 2;
  column-gap: 2rem;
}
.dataview-list li {
  padding: .22rem 0;
  border-bottom: 1px solid var(--bg-3);
  break-inside: avoid;
  font-size: .93rem;
}
.dataview-list a { color: var(--link); text-decoration: none; }
.dataview-list a:hover { text-decoration: underline; color: var(--link-h); }

/* ── Dataview Grouped ── */
.dataview-group {
  margin: 1.2rem 0;
}
.dataview-group-header {
  font-family: Arial, sans-serif;
  font-size: .82rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: .25rem;
  margin-bottom: .4rem;
}
.dataview-group-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .1rem .8rem;
}
.dataview-group-list li { font-size: .9rem; }
.dataview-group-list a { color: var(--link); text-decoration: none; }
.dataview-group-list a:hover { text-decoration: underline; color: var(--link-h); }

/* ── Campaign Status Badges ── */
.dv-status {
  font-family: Arial, sans-serif;
  font-size: .82rem;
  white-space: nowrap;
}
.dv-status-active    { color: #22a027; }
.dv-status-completed { color: #c0392b; }
.dv-status-paused    { color: #cc8800; }
.dv-status-planned   { color: var(--text-2); }
body.dark .dv-status-active    { color: #4dc452; }
body.dark .dv-status-completed { color: #e05c52; }

@media (max-width: 700px) {
  .dataview-list { columns: 1; }
}

/* ── Athenaeum Archive Header (world index) ── */
.ath-header {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  background: var(--bg-2);
  padding: .6rem 1rem;
  margin-bottom: 1.2rem;
  font-family: Arial, sans-serif;
  border-radius: 0 4px 4px 0;
}
.ath-institution {
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-2);
  opacity: .75;
  margin-bottom: .15rem;
}
.ath-entry {
  font-size: .92rem;
  font-weight: bold;
  color: var(--accent);
  margin-bottom: .2rem;
}
.ath-meta {
  font-size: .76rem;
  color: var(--text-2);
}

/* Scholar's field-note opener */
.ath-note {
  border-left: 3px solid var(--border);
  padding: .5rem 1rem;
  margin: 0 0 1.4rem;
  color: var(--text-2);
  font-size: .9rem;
  font-style: italic;
  background: var(--bg-2);
}

/* Scholar's closing signature */
.ath-signature {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: Arial, sans-serif;
  font-size: .82rem;
  color: var(--text-2);
  text-align: right;
  font-style: italic;
}

/* ── Footer ── */
.site-footer {
  margin-top: 3rem;
  padding: 1.2rem 1.25rem 1.6rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: .8rem;
  color: var(--text-2);
}
.site-footer a { color: var(--link); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer-nav { margin-bottom: .6rem; }
.site-footer-legal {
  font-size: .68rem;
  color: var(--text-2);
  max-width: 700px;
  margin: 0 auto;
  line-height: 1.6;
  opacity: .75;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .content-grid.has-sidebar { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .section-nav { display: none; }
  .infobox { float: none; max-width: 100%; margin: 0 0 1rem; }
  .index-list { columns: 1; }
}
@media (max-width: 600px) {
  .article-title { font-size: 1.5rem; }
  .header-inner  { gap: .5rem; }
}

/* ── Scroll transition (wiki pages) ── */
@keyframes scroll-appear {
  from { opacity: 0; transform: translateY(10px); filter: blur(3px); }
  to   { opacity: 1; transform: translateY(0);    filter: blur(0); }
}
.page-wrap {
  animation: scroll-appear .35s ease forwards;
}
body.leaving .page-wrap {
  transition: opacity .22s ease, transform .22s ease, filter .22s ease;
  opacity: 0;
  transform: translateY(-8px);
  filter: blur(3px);
  pointer-events: none;
}
