/* HaDerech tool theme: loads after style.css and re-skins it with the home page tokens. */
:root {
  --ink: #17201B;
  --paper: #F2EFE7;
  --accent: #3E5B47;
  --line: #DAD6C8;
  --muted: #566057;

  --night: #0F1713;
  --night-line: #2A382F;
  --night-text: #E9E6DA;
  --night-mute: #A9B2A6;
  --gold: #D6A648;
  --gold-ink: #7A5712;
  --card: #FBFAF5;
  --display: "Fraunces", Georgia, serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --bar-h: 64px;     /* set by app.js from the real header height */
  --sbar-h: 0px;     /* height of the study title bar when it is showing */
  font-size: 17px;
  scroll-padding-top: calc(var(--bar-h) + var(--sbar-h) + 16px);
}

body { font-family: var(--body); background: var(--paper); color: var(--ink); line-height: 1.65; -webkit-font-smoothing: antialiased; padding-top: var(--bar-h); }
h1, h2, h3, h4 { font-family: var(--display); font-weight: 400; letter-spacing: -.01em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- fixed top bar ---------- */
header.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 60;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 22px;
  padding: 8px clamp(16px, 3vw, 32px);
  text-align: left;
  background: var(--night); color: var(--night-text);
  border-bottom: 1px solid var(--night-line);
}
.tool-mark {
  font: 500 24px/1 var(--display); letter-spacing: -.01em;
  color: var(--night-text); text-decoration: none; padding: 8px 0;
}
.bar-nav { display: flex; flex-wrap: nowrap; justify-content: flex-start; gap: 2px; margin: 0; flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.bar-nav::-webkit-scrollbar { display: none; }
.tab-btn, .top-nav a.tab-btn {
  font: 500 12px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--night-mute); background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  padding: 14px 10px 11px; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.tab-btn:hover, .top-nav a.tab-btn:hover { color: var(--gold); }
.tab-btn[aria-selected="true"], .tab-btn.active, .tab-btn[aria-current="page"] {
  color: var(--night-text); background: none; border-bottom-color: var(--gold); font-weight: 500;
}
.bar-tools { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.global-search { position: relative; width: clamp(180px, 22vw, 280px); max-width: none; margin: 0; }
#global-search-input {
  width: 100%; height: 40px; padding: 0 14px;
  font: 400 15px/1 var(--body); background: var(--card); color: var(--ink);
  border: 2px solid transparent; border-radius: 10px;
}
#global-search-input:focus { outline: none; border-color: var(--gold); }
.global-search-results { border-radius: 12px; border: 0; box-shadow: 0 30px 70px -30px rgba(0,0,0,.6); width: max(100%, 320px); right: 0; left: auto; z-index: 70; }
.global-search-item:hover { background: #ECE8DA; }
.global-search-type { font-family: var(--mono); font-size: .66rem; letter-spacing: .1em; color: var(--gold-ink); border-color: transparent; padding-left: 0; }
.bar-fb {
  font: 600 13px/1 var(--body); color: var(--night-text); background: none;
  border: 1px solid rgba(233,230,218,.5); border-radius: 999px; padding: 11px 16px; cursor: pointer; white-space: nowrap;
}
.bar-fb:hover { border-color: var(--gold); color: var(--gold); }

@media (max-width: 1060px) {
  header.bar { row-gap: 0; padding-top: 4px; padding-bottom: 0; }
  .tool-mark { order: 1; }
  .bar-tools { order: 2; flex: 1 1 0; min-width: 0; justify-content: flex-end; }
  .bar-nav { order: 3; flex: 1 0 100%; }
  .global-search { flex: 1 1 auto; width: auto; max-width: 280px; }
}
@media (max-width: 520px) {
  .tool-mark { font-size: 21px; }
  .bar-fb { padding: 9px 11px; font-size: 12px; }
  #global-search-input { height: 38px; font-size: 14px; }
}

/* ---------- study title bar (shows which study you are in) ---------- */
.study-bar {
  position: fixed; top: var(--bar-h); left: 0; right: 0; z-index: 55;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.study-bar.hidden { display: none; }
.sb-inner { max-width: 70rem; margin: 0 auto; padding: 8px clamp(16px, 3vw, 32px); display: flex; align-items: baseline; gap: 6px 18px; flex-wrap: wrap; }
.back-btn { font: 500 12px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); background: none; border: 0; padding: 8px 0; cursor: pointer; }
.back-btn:hover { color: #2F4838; text-decoration: underline; text-underline-offset: 4px; }
.sb-title { font: 400 1.25rem/1.2 var(--display); color: var(--ink); }
.sb-section { font: 500 11px/1.2 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-ink); }
.sb-section:empty { display: none; }
@media (max-width: 520px) { .sb-section { display: none; } .sb-title { font-size: 1.1rem; } }

/* ---------- main column ---------- */
main { max-width: 46rem; padding: 2rem clamp(16px, 4vw, 24px) 5rem; margin: 0 auto; }
main.wide { max-width: 72rem; }
.hint { font-family: var(--body); color: var(--muted); }
.btn, .btn-ghost {
  display: inline-block; font: 600 15px/1 var(--body); border-radius: 10px; padding: 14px 22px; min-height: 46px; text-decoration: none; cursor: pointer;
}
.btn { background: var(--accent); color: var(--card); border: 0; }
.btn:hover { background: #2F4838; color: var(--card); }
.btn-ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--accent); }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- tile pages (passages, topics, words) ---------- */
.lib-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px 24px; margin-bottom: 26px; }
.lib-head h2 { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.1; margin: 0 0 6px; }
.lede { color: var(--muted); margin: 0; max-width: 38rem; }
.filter input {
  height: 46px; width: min(100%, 320px); padding: 0 16px; font: 400 16px/1 var(--body); color: var(--ink);
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.filter input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62,91,71,.2); }
.lib-layout { display: grid; grid-template-columns: 210px 1fr; gap: clamp(20px, 3vw, 40px); align-items: start; }
.book-rail {
  position: sticky; top: calc(var(--bar-h) + 20px);
  max-height: calc(100vh - var(--bar-h) - 40px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 10px;
}
.rail-group { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--gold-ink); margin: 14px 8px 6px; }
.rail-group:first-child { margin-top: 2px; }
.rail-item { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 9px 10px; font: 400 15px/1.2 var(--body); color: var(--ink); cursor: pointer; }
.rail-item:hover { background: #ECE8DA; }
.rail-item[aria-pressed="true"] { background: var(--accent); color: var(--card); }
.rail-item .n { font: 400 12px/1 var(--mono); opacity: .7; }
.rail-req { display: block; width: 100%; margin-top: 12px; padding: 10px; border: 1px dashed #B9B49F; border-radius: 10px; background: none; font: 500 13px/1.3 var(--body); color: var(--accent); cursor: pointer; text-align: center; }
.rail-req:hover { border-color: var(--accent); background: #ECE8DA; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.card a, .card .card-static {
  display: flex; flex-direction: column; gap: 10px; height: 100%;
  padding: 22px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; transition: border-color .18s, transform .18s;
}
.card a:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .book { font: 500 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--gold-ink); }
.card h3 { font: 400 1.5rem/1.15 var(--display); letter-spacing: -.01em; margin: 0; }
.card .verse-line { quotes: "\201C" "\201D"; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font: italic 300 1rem/1.45 var(--display); }
.card p { margin: 0; font-size: 14.5px; line-height: 1.55; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .go { margin-top: auto; font: 500 12px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding-top: 6px; }
.card-planned .card-static { background: transparent; border-style: dashed; border-color: #B9B49F; color: var(--muted); cursor: pointer; }
.card-planned .go { color: var(--muted); }
.card-request button {
  display: flex; align-items: center; justify-content: center; height: 100%; min-height: 150px; width: 100%;
  background: none; border: 2px dashed #B9B49F; border-radius: 14px; padding: 22px;
  font: 500 15px/1.3 var(--body); color: var(--accent); cursor: pointer; text-align: center;
}
.card-request button:hover { border-color: var(--accent); background: #ECE8DA; }
.empty { color: var(--muted); margin-top: 20px; }

@media (max-width: 860px) {
  .lib-layout { grid-template-columns: 1fr; }
  .book-rail { position: static; max-height: none; display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; padding: 10px; align-items: center; }
  .rail-group { display: none; }
  .rail-item { width: auto; white-space: nowrap; flex: 0 0 auto; border: 1px solid var(--line); }
  .rail-req { width: auto; margin: 0; white-space: nowrap; flex: 0 0 auto; }
}

/* ---------- a study ---------- */
.result h2 {
  font-size: clamp(1.9rem, 4.4vw, 2.7rem); font-weight: 400; line-height: 1.1;
  color: var(--ink); border-bottom: 3px solid var(--gold); padding-bottom: .5rem; margin-top: .4rem;
}
.result h3 { margin-top: 2.6rem; font: 500 12px/1.4 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--gold-ink); }
.result h2, .result h3 { scroll-margin-top: calc(var(--bar-h) + var(--sbar-h) + 16px); }
.copy-link-btn, #copy-request-btn { font-family: var(--body); border-radius: 8px; background: var(--card); }
.text-block { background: var(--card); border-radius: 12px; border-left-width: 3px; padding: 1.1rem 1.3rem; }
.text-block .lang { font-family: var(--mono); letter-spacing: .1em; font-size: .72rem; color: var(--muted); }
.original { font-family: "Frank Ruhl Libre", "SBL Hebrew", serif; font-size: 1.3rem; }
.greek-text { font-style: normal; }
.common-misreading { background: var(--card); border: 1px solid var(--line); border-left: 3px solid #B9B49F; border-radius: 12px; font-style: normal; color: var(--muted); }
.synthesis { background: var(--night); color: var(--night-text); border: 0; border-radius: 14px; padding: 1.4rem 1.6rem; }
.synthesis a { color: var(--gold); }
.source-list .tag { font-family: var(--mono); font-size: .68rem; letter-spacing: .06em; border-radius: 6px; }
.source-list li { border-bottom-color: var(--line); }
.confidence { font-family: var(--mono); font-size: .64rem; letter-spacing: .08em; border-radius: 6px; padding: .2rem .5rem; }
.confidence-well-attested { background: #E4EFE1; color: #2F4838; border-color: #C5DCC0; }
.confidence-debated { background: #F7ECD6; color: #7A4F14; border-color: #E8D3A6; }
.confidence-speculative { background: #F3DFD8; color: #8E4A2E; border-color: #E4C0B2; }
.section-divider { font-family: var(--mono); font-size: .8rem; letter-spacing: .14em; }
.result p { max-width: 42rem; }
.result .synthesis p { max-width: none; }
.result .synthesis p + p, .result .common-misreading p + p, .result > p + p { margin-top: 1em; }
.cite-desc + .cite-desc { display: block; margin-top: .7em; }
.dev-only { display: none !important; }
#not-found { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 1.4rem; text-align: left; }

/* ---------- contents box ---------- */
.toc { background: var(--card); border-color: var(--line); font-family: var(--body); border-radius: 14px; }
.toc-toggle { font-family: var(--mono); letter-spacing: .08em; top: auto; bottom: 16px; left: 16px; }
@media (min-width: 1180px) {
  .toc { top: calc(var(--bar-h) + var(--sbar-h) + 16px); max-height: calc(100vh - var(--bar-h) - var(--sbar-h) - 32px); }
}

footer { background: var(--night); color: var(--night-mute); font-size: .85rem; padding: 2rem 1rem 2.4rem; }
footer a { color: var(--night-text); }

/* ---------- feedback pop-up ---------- */
.fb-dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); background: var(--card); color: var(--ink); box-shadow: 0 40px 90px -30px rgba(0,0,0,.6); }
.fb-dialog::backdrop { background: rgba(15,23,19,.6); }
.fb { padding: clamp(18px, 3vw, 28px); }
.fb-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.fb-top h2 { font-size: 1.6rem; line-height: 1.15; margin: 0; }
.fb-close { background: none; border: 0; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.kinds { border: 0; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.kinds legend { font: 500 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; padding: 0; float: left; width: 100%; }
.kinds label { position: relative; }
.kinds input { position: absolute; opacity: 0; inset: 0; }
.kinds span { display: inline-block; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; min-height: 42px; line-height: 20px; background: var(--paper); }
.kinds input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--card); }
.kinds input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 500; font-size: 15px; margin-bottom: 8px; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field textarea, .field input { width: 100%; padding: 12px 14px; font: 400 16px/1.5 var(--body); color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.field textarea:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(62,91,71,.2); }
.field textarea { resize: vertical; min-height: 110px; }
.err { display: block; color: #8E4A2E; margin-top: 6px; font-size: 14px; }
.hp { position: absolute; left: -9999px; }
.fb-actions { display: flex; gap: 10px; }
.fb-status { margin: 12px 0 0; min-height: 1.4em; font-size: 15px; color: var(--muted); }
.fb-status.ok { color: var(--accent); font-weight: 500; }
.fb-status.bad { color: #8E4A2E; }
.fb .btn[disabled] { opacity: .6; cursor: progress; }

/* ---------- sub-pages (methodology, glossary) ---------- */
.page-title { font-size: clamp(1.9rem, 4vw, 2.6rem); line-height: 1.1; margin: 0 0 8px; }
.page-lede { color: var(--muted); margin: 0 0 1.6rem; max-width: 38rem; }

@media (prefers-reduced-motion: reduce) { .card a { transition: none; } }

/* wide tables scroll inside their own box instead of stretching the page on phones */
.lxx-first { overflow-x: auto; }
.lxx-first table { min-width: 520px; }
.result table { max-width: 100%; }
html, body { overflow-x: clip; }
