/* HopscotchBible Wiki — v2 theme
   Established-wiki anatomy on the v1 navy palette. Content markup
   (infobox, section-images, todo list) is unchanged; only presentation. */

:root {
  --bg: #0a1128;
  --surface: #0d1730;
  --surface-2: #10193a;
  --header: #070d1f;
  --text: #dbe4ff;
  --text-dim: #8fa3d1;
  --accent: #5b8cff;
  --border: #1c2b52;
  --heading: #ffffff;
  --danger: #ff7b7b;
  --ok: #7bd88f;
  --serif: 'Linux Libertine', Georgia, 'Times New Roman', serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --header-h: 52px;
  --sidebar-w: 232px;
  color-scheme: dark;
}

/* Legacy aliases still referenced by the v1 classes */
:root { --bg-sidebar: var(--surface); --bg-code: var(--surface-2); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea { font-family: inherit; font-size: inherit; }
::selection { background: var(--accent); color: #071022; }

/* ---------- Header bar ---------- */
.wiki-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px;
  background: var(--header);
  border-bottom: 1px solid var(--border);
}
.hdr-menu {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: -8px;
  border: none; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer;
}
.hdr-menu:hover { background: var(--surface-2); }
.wordmark {
  display: flex; align-items: center; gap: 10px;
  color: var(--heading); font-family: var(--serif); font-size: 17px; font-weight: 600;
  letter-spacing: 0.01em; white-space: nowrap;
}
.wordmark:hover { text-decoration: none; }
.hdr-search-slot { flex: 1; display: flex; justify-content: center; min-width: 0; }
.hdr-actions { display: flex; align-items: center; gap: 8px; }
.hdr-btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 13px;
  border-radius: 6px; border: 1px solid var(--border);
  background: transparent; color: var(--text);
  font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.hdr-btn:hover { border-color: var(--text-dim); text-decoration: none; }
.hdr-edit { border-color: var(--accent); color: var(--accent); }
.hdr-edit:hover { background: rgba(91, 140, 255, 0.1); border-color: var(--accent); }
body.editing .hdr-edit { display: none; }

/* Docsify search plugin, relocated into the header */
.wiki-header .search {
  position: relative; width: 100%; max-width: 560px;
  margin: 0; padding: 0; border: none; border-bottom: none;
}
.wiki-header .search .input-wrap { display: flex; align-items: center; position: relative; }
.wiki-header .search input[type="search"] {
  width: 100%; height: 34px;
  padding: 0 34px 0 36px;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 20 20' fill='none' stroke='%238fa3d1' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8.5' cy='8.5' r='5'/%3E%3Cpath d='M12.7 12.7 17 17'/%3E%3C/svg%3E") no-repeat 12px center;
  color: var(--text); font-size: 13.5px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.wiki-header .search input[type="search"]::placeholder { color: var(--text-dim); opacity: 0.85; }
.wiki-header .search input[type="search"]:focus { border-color: var(--accent); }
.wiki-header .search input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.wiki-header .search .clear-button {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 20px; height: 20px; cursor: pointer; display: none;
}
.wiki-header .search .clear-button.show { display: block; }
.wiki-header .search .clear-button svg { width: 20px; height: 20px; transform: none; }
.wiki-header .search .clear-button svg circle { fill: var(--border); }
.wiki-header .search .clear-button svg line { stroke: var(--text-dim); }
.wiki-header .search .results-panel {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  max-height: min(70vh, 560px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  padding: 6px; z-index: 50; text-align: left;
}
.wiki-header .search .results-panel.show { display: block; }
.wiki-header .search .matching-post {
  display: block; padding: 8px 10px; border-radius: 6px; border: none;
  color: var(--text);
}
.wiki-header .search .matching-post:hover { background: var(--surface-2); text-decoration: none; }
.wiki-header .search .matching-post h2 {
  margin: 0 0 2px; font-family: var(--sans); font-size: 13.5px; font-weight: 600; color: var(--heading);
  border: none; padding: 0;
}
.wiki-header .search .matching-post p { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.45; }
.wiki-header .search .matching-post p:empty { display: none; }
.wiki-header .search .matching-post em, .search .matching-post .search-keyword {
  font-style: normal; color: var(--accent); background: rgba(91, 140, 255, 0.14); border-radius: 2px; padding: 0 1px;
}
.wiki-header .search .empty { padding: 12px; color: var(--text-dim); font-size: 13px; }

/* ---------- Layout ---------- */
main { display: block; padding-top: var(--header-h); }
.sidebar-toggle { display: none; }
.app-name { display: none; }

.sidebar {
  position: fixed; top: var(--header-h); bottom: 0; left: 0;
  width: var(--sidebar-w);
  overflow-y: auto; overflow-x: hidden;
  padding: 22px 13px 30px 20px;
  background: var(--bg);
  z-index: 30;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.sidebar-nav { display: flex; flex-direction: column; gap: 22px; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.sidebar-nav ul ul { display: none; }
.sidebar-nav li p { margin: 0; }
.portlet { display: flex; flex-direction: column; gap: 1px; }
.portlet-h {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); padding: 0 10px 6px; margin: 0; font-weight: 600; font-family: var(--sans);
}
.sidebar-nav li a, .portlet a {
  display: block; padding: 5px 10px; border-radius: 5px;
  font-size: 14px; color: var(--text); line-height: 1.5;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-nav li a:hover, .portlet a:hover { background: var(--surface); color: var(--accent); text-decoration: none; }
.sidebar-nav li.active > a, .portlet a.active {
  background: var(--surface); color: var(--accent); font-weight: 600;
  border: 1px solid var(--border); border-right: none;
  margin-right: -13px; border-radius: 5px 0 0 5px;
}

.content {
  margin-left: var(--sidebar-w);
  padding: 22px 32px 32px 8px;
  min-height: calc(100vh - var(--header-h));
}
.markdown-section {
  position: relative;
  max-width: 1080px; margin: 0;
  padding: 22px 36px 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 2px;
}
.markdown-section > :last-child { margin-bottom: 0; }

/* ---------- Article header ---------- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
  margin-bottom: 10px; min-height: 30px;
}
.crumb { color: var(--text-dim); font-size: 12.5px; line-height: 1.6; }
.crumb a { color: var(--text-dim); }
.crumb .sep { margin: 0 6px; opacity: 0.5; }
.crumb .cur { color: var(--text); }
.tabs { display: flex; gap: 2px; flex-shrink: 0; }
.tab {
  padding: 7px 12px; font-size: 13.5px; color: var(--text-dim);
  border: none; border-bottom: 2px solid transparent; background: transparent; cursor: pointer; line-height: 1.2;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.markdown-section h1 {
  font-family: var(--serif); font-size: 31px; font-weight: 400; line-height: 1.25;
  margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  color: var(--heading);
}
.subtitle { font-size: 12.5px; color: var(--text-dim); margin: 6px 0 18px; }
.markdown-section h2 {
  font-family: var(--serif); font-size: 22px; font-weight: 400; line-height: 1.3;
  margin: 26px 0 12px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
  color: var(--heading);
}
.markdown-section h3 { font-family: var(--serif); font-size: 18px; font-weight: 600; margin: 22px 0 8px; color: var(--heading); }
.markdown-section h4, .markdown-section h5, .markdown-section h6 { font-size: 15px; margin: 18px 0 6px; color: var(--heading); }
.markdown-section h1 a.anchor, .markdown-section h2 a.anchor, .markdown-section h3 a.anchor,
.markdown-section h4 a.anchor, .markdown-section h5 a.anchor, .markdown-section h6 a.anchor {
  color: inherit; text-decoration: none;
}
.markdown-section h2 a.anchor:hover span, .markdown-section h3 a.anchor:hover span { text-decoration: underline; text-decoration-color: var(--border); }
.markdown-section p { margin: 0 0 12px; }
.markdown-section ul, .markdown-section ol { margin: 0 0 12px; padding-left: 24px; }
.markdown-section li { margin-bottom: 5px; }
.markdown-section li > ul, .markdown-section li > ol { margin: 5px 0 0; }
.markdown-section strong { color: var(--heading); }
.markdown-section hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.markdown-section blockquote {
  margin: 0 0 14px; padding: 8px 16px; border-left: 3px solid var(--border);
  color: var(--text-dim); background: var(--bg); border-radius: 0 4px 4px 0;
}
.markdown-section blockquote p:last-child { margin-bottom: 0; }
.markdown-section code {
  font-family: var(--mono); font-size: 0.88em;
  background: var(--surface-2); color: var(--text);
  padding: 0.15em 0.4em; border-radius: 4px;
}
.markdown-section pre {
  margin: 0 0 14px; padding: 12px 14px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
}
.markdown-section pre > code { background: transparent; padding: 0; font-size: 13px; line-height: 1.55; color: var(--text); }
.markdown-section img { max-width: 100%; }
.markdown-section table:not(.infobox-table) {
  display: block; overflow-x: auto; max-width: 100%;
  border-collapse: collapse; margin: 0 0 16px; font-size: 14px;
}
.markdown-section table:not(.infobox-table) th, .markdown-section table:not(.infobox-table) td {
  padding: 7px 12px; border: 1px solid var(--border); text-align: left; vertical-align: top;
}
.markdown-section table:not(.infobox-table) th { background: var(--surface-2); color: var(--heading); font-weight: 600; }
.markdown-section table tr:nth-child(2n) { background-color: transparent; }
.markdown-section li input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); margin-right: 0.4em; }

/* ---------- Contents box ---------- */
.toc {
  display: inline-block; vertical-align: top;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  padding: 10px 16px 10px 14px; margin: 4px 0 16px;
  font-size: 13.5px; min-width: 220px; max-width: 100%;
}
.toc-h { font-weight: 700; color: var(--heading); text-align: center; margin-bottom: 6px; font-size: 13px; }
.toc-h button {
  font-weight: 400; color: var(--text-dim); font-size: 12px; margin-left: 8px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.toc-h button:hover { color: var(--accent); }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc ol ol { padding-left: 18px; }
.toc a { display: block; padding: 2px 0; color: var(--accent); line-height: 1.5; }
.toc .n { color: var(--text-dim); margin-right: 8px; font-variant-numeric: tabular-nums; }
.toc.collapsed ol { display: none; }
.toc.collapsed { min-width: 0; }

/* ---------- Infobox (markup unchanged from v1) ---------- */
.infobox {
  float: right; clear: right;
  width: 272px; margin: 0 0 16px 28px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 4px;
  overflow: hidden; font-size: 13px; line-height: 1.5;
}
.infobox-title {
  padding: 8px 10px; background: var(--surface-2);
  color: var(--heading); font-weight: 700; font-size: 14.5px; text-align: center;
  border-bottom: 1px solid var(--border); font-family: var(--serif);
}
.infobox-image {
  aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
  color: var(--text-dim); font-style: italic; font-size: 12px; overflow: hidden;
}
.infobox-image img { width: 100%; height: 100%; object-fit: contain; display: block; }
.infobox-description { padding: 9px 11px; border-bottom: 1px solid var(--border); color: var(--text); }
.infobox-description :last-child { margin-bottom: 0; }
.infobox-description p { margin: 0 0 6px; }
.infobox-table { width: 100%; border-collapse: collapse; margin: 0; }
.infobox-table tr:nth-child(2n) { background-color: transparent; }
.infobox-table th, .infobox-table td {
  padding: 6px 10px; border-top: 1px solid var(--border);
  text-align: left; vertical-align: top; line-height: 1.45;
}
.infobox-table tr:first-child th, .infobox-table tr:first-child td { border-top: none; }
.infobox-table th { width: 36%; color: var(--text-dim); font-weight: 600; font-size: 12.5px; }
.infobox-pill {
  display: inline-block; font-size: 11.5px; padding: 1px 8px; margin: 1px 4px 1px 0;
  border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
}

/* Section images (markup unchanged) */
.section-images { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 18px; }
.section-images figure { margin: 0; width: 220px; max-width: 100%; }
.section-images img {
  display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 6px; border: 1px solid var(--border);
}
.section-images figcaption { margin-top: 5px; font-size: 12px; color: var(--text-dim); text-align: center; }

/* ---------- Related pages + footer meta ---------- */
.related-pages { clear: both; margin-top: 30px; padding-top: 14px; border-top: 1px solid var(--border); }
.related-pages-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-dim); margin-bottom: 10px; font-weight: 600;
}
.related-pages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.related-card {
  display: block; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); padding: 9px 12px; font-size: 13.5px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.related-card:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.page-meta {
  clear: both; margin-top: 22px; padding-top: 10px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-dim);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.page-meta code { font-size: 12px; background: transparent; padding: 0; color: var(--text-dim); }
.page-meta button { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12.5px; }
.page-meta button:hover { text-decoration: underline; }
.site-footer { color: var(--text-dim); font-size: 12px; display: flex; gap: 18px; flex-wrap: wrap; padding: 14px 4px 0; max-width: 1080px; }
.site-footer a { color: var(--text-dim); }

/* ---------- Home page ---------- */
.is-home .lead { font-size: 17px; margin-bottom: 18px; }
.home-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 18px; }
.home-card {
  display: flex; flex-direction: column; gap: 8px;
  padding: 18px 18px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
.home-card:hover { border-color: var(--accent); text-decoration: none; }
.home-card .hc-title { font-family: var(--serif); font-size: 20px; color: var(--heading); display: flex; align-items: center; gap: 10px; }
.home-card .hc-title svg { flex-shrink: 0; color: var(--accent); }
.home-card .hc-desc { font-size: 13.5px; line-height: 1.5; color: var(--text-dim); min-height: 1.5em; }

/* ---------- Editor ---------- */
body.editing .markdown-section { display: none; }
.editor-panel {
  max-width: 1080px; padding: 22px 36px 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 2px;
}
.editor-panel h1 { font-family: var(--serif); font-size: 31px; font-weight: 400; margin: 0; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--heading); line-height: 1.25; }
.editor-frame { border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--bg); }
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 6px 8px;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tool {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 5px; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; font-size: 13px;
}
.tool:hover { background: var(--surface); color: var(--heading); }
.tool.serif { font-family: var(--serif); }
.editor-status { flex: 1; text-align: right; font-size: 12px; color: var(--text-dim); padding-right: 6px; }
.editor-status.dirty { color: var(--accent); }
.editor-status.error { color: var(--danger); }
.editor-status.ok { color: var(--ok); }
.editor-text {
  width: 100%; display: block; border: none; border-radius: 0; outline: none;
  background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  padding: 14px 16px; min-height: 60vh; resize: vertical; tab-size: 2;
}
.editor-preview { padding: 6px 16px 16px; min-height: 60vh; }
.editor-preview h1 { margin-top: 12px; }
.editor-actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.editor-actions .hint { flex: 1; text-align: right; font-size: 12.5px; color: var(--text-dim); }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: 6px; border: 1px solid var(--border); background: transparent;
  color: var(--text); font-size: 13.5px; cursor: pointer;
}
.btn:hover { border-color: var(--text-dim); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #071022; font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.08); }
.btn-quiet { border-color: transparent; }

/* Unlock modal */
.modal-scrim {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(3, 6, 18, 0.55);
}
.modal {
  width: 400px; max-width: 100%; padding: 24px 26px 22px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.modal-title { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 20px; color: var(--heading); }
.modal p { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--text-dim); }
.modal .err { color: var(--danger); min-height: 1.2em; font-size: 12.5px; }
.field {
  width: 100%; height: 38px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13.5px; padding: 8px 10px;
}
.field:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 70; padding: 10px 16px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  font-size: 13.5px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s;
}
.toast.error { border-color: var(--danger); }

/* Docsify progress bar */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; background: var(--accent); z-index: 100; transition: width 0.2s, opacity 0.4s; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .home-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .wiki-header { gap: 12px; padding: 0 14px; }
  .hdr-menu { display: inline-flex; }
  .wordmark span { display: none; }
  .hdr-todo span, .hdr-edit span { display: none; }
  .hdr-btn { padding: 0 9px; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; background: var(--header); border-right: 1px solid var(--border); width: 260px; box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(3, 6, 18, 0.5); }
  .sidebar-nav li.active > a, .portlet a.active { margin-right: 0; border-right: 1px solid var(--border); border-radius: 5px; }
  .content { margin-left: 0; padding: 12px; }
  .markdown-section, .editor-panel { padding: 16px 18px 22px; }
  .infobox { float: none; width: 100%; margin: 0 0 16px; }
  .home-cards { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 6px; }
}
