/**
 * Hatanakh theme — layout + components. Consumes tokens from brand.css only.
 * RTL-first (the site is Hebrew); LTR handled where needed.
 */

* { box-sizing: border-box; }

html { direction: rtl; }

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--c-text);
  background: var(--c-bg);
  line-height: 1.6;
}

a { color: var(--c-link); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout-container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

/* ---------- Top utility bar ---------- */
.site-utility {
  background: var(--c-teal-dark);
  color: #fff;
  font-size: 13px;
}
.site-utility a { color: #fff; opacity: .9; }
.site-utility .layout-container {
  display: flex; justify-content: space-between; align-items: center; height: 34px;
}
.site-utility .langs a { margin-inline-start: 12px; }
.site-utility .langs a.is-active { font-weight: 700; text-decoration: underline; }

/* ---------- Header ---------- */
.site-header {
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.site-header .layout-container {
  display: flex; align-items: center; gap: 18px; height: 76px;
}
.brand-wordmark { display: block; flex: 0 0 auto; }
.brand-wordmark svg { height: 52px; width: auto; display: block; }
.brand-wordmark:hover { text-decoration: none; }
.brand-herzog { color: var(--c-bordeaux); font-weight: 800; font-size: 20px; }

.header-actions { display: flex; gap: 10px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--c-teal); color: #fff; border: 0;
  padding: 9px 18px; border-radius: var(--radius-pill);
  font-family: var(--font-ui); font-weight: 700; font-size: 14px; cursor: pointer;
}
.btn:hover { background: var(--c-teal-dark); text-decoration: none; color: #fff; }
.btn--ghost { background: transparent; color: var(--c-teal-dark); border: 1.5px solid var(--c-teal); }

.header-search { flex: 1; display: flex; max-width: 560px; margin-inline-start: auto; }
.header-search input {
  flex: 1; border: 1.5px solid var(--c-border); border-radius: var(--radius-pill);
  padding: 9px 16px; font-family: var(--font-ui); font-size: 14px;
}
.header-search button { margin-inline-start: -46px; border-radius: var(--radius-pill); padding: 9px 16px; }

.header-hamburger { font-size: 24px; color: var(--c-teal-dark); background: none; border: 0; cursor: pointer; line-height: 1; }

/* ---------- Dropdowns (book picker, search scope) ---------- */
.dropdown-anchor { position: relative; }
.js-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); inset-inline-start: 0; z-index: 40;
  background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius);
  box-shadow: var(--shadow); min-width: 220px; padding: 10px;
}
.js-dropdown.is-open { display: block; }
.book-picker .book-picker-filter { width: 100%; border: 1.5px solid var(--c-border); border-radius: var(--radius-pill); padding: 8px 14px; margin-bottom: 8px; font-family: var(--font-ui); }
.book-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.book-item a { display: block; padding: 7px 10px; border-radius: 6px; color: var(--c-text); font-weight: 600; }
.book-item a:hover { background: var(--c-bg); text-decoration: none; color: var(--c-teal-dark); }

.header-search .scope { display: flex; align-items: center; }
.scope-btn { display: flex; align-items: center; gap: 4px; background: var(--c-teal); color: #fff; border: 0; border-radius: var(--radius-pill); padding: 9px 14px; font-family: var(--font-ui); font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap; }
.search-scope { min-width: 170px; }
.search-scope button { display: block; width: 100%; text-align: start; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font-family: var(--font-ui); font-size: 14px; color: var(--c-text); cursor: pointer; }
.search-scope button:hover { background: var(--c-bg); color: var(--c-teal-dark); }
.header-search .search-go { margin-inline-start: -44px; background: none; border: 0; color: var(--c-muted); font-size: 18px; cursor: pointer; }

/* ---------- Slide-out menu ---------- */
.slideout {
  position: fixed; top: 0; left: 0; height: 100vh; width: 300px; max-width: 84vw;
  background: #fff; box-shadow: 4px 0 24px rgba(0, 0, 0, .18); z-index: 200;
  transform: translateX(-110%); transition: transform .25s ease; padding: 56px 0 24px; overflow-y: auto;
}
.slideout.is-open { transform: translateX(0); }
.slideout-close { position: absolute; top: 12px; right: 14px; background: none; border: 0; font-size: 22px; color: var(--c-muted); cursor: pointer; }
.slideout-nav a { display: flex; align-items: center; gap: 14px; padding: 12px 22px; color: var(--c-text); font-weight: 600; font-size: 15px; }
.slideout-nav a:hover { background: var(--c-bg); text-decoration: none; }
.slideout-nav .mi { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 19px; background: var(--_c, var(--c-teal)); }
.slideout-nav .mi.c-topics { background: var(--c-circle-topics); }
.slideout-nav .mi.c-articles { background: var(--c-circle-articles); }
.slideout-nav .mi.c-shorts { background: var(--c-circle-shorts); }

/* ---------- Main grid: content + right tabs ---------- */
.page-main { padding: 24px 0 48px; }
/* Flex is more predictable than grid for the RTL tabs sidebar: first DOM child
   (the tabs) lands on the inline-start = right in RTL. */
.page-grid { display: flex; gap: 20px; align-items: flex-start; }
.page-content { flex: 1 1 auto; min-width: 0; }

.section-tabs { flex: 0 0 88px; display: flex; flex-direction: column; gap: 10px; }
.section-tabs a {
  background: var(--c-lavender); color: #fff; text-align: center;
  padding: 14px 6px; border-radius: 8px 0 0 8px; font-weight: 700; font-size: 13px; line-height: 1.3;
}
.section-tabs a:hover, .section-tabs a.is-active { background: var(--c-lavender-dark); text-decoration: none; }

/* ---------- Homepage panels ---------- */
.hp-panel { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 22px; }

.hp-top { display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px; }

/* Reading pane */
.reading .ref-head { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--c-teal-soft); font-weight: 800; font-size: 22px; }
.reading .ref-head .nav { color: var(--c-teal-soft); text-decoration: none; font-size: 26px; line-height: 1; padding: 0 6px; }
.reading .ref-head .nav:hover { color: var(--c-teal-dark); }
.reading .ref-sub { text-align: center; color: var(--c-muted); font-weight: 700; margin: 2px 0 6px; }
.hp-note { text-align: center; color: var(--c-bordeaux); font-size: 13px; margin: 0 0 10px; }
.reading .daily-badge { color: var(--c-teal-soft); font-weight: 700; font-size: 13px; }
.reading .scripture { font-family: var(--font-scripture); font-size: 21px; line-height: 2; text-align: justify; }
.reading .scripture .vnum { color: var(--c-bordeaux); font-weight: 700; font-size: .8em; margin-inline-start: 4px; }
.reading .read-links { display: flex; justify-content: space-between; margin-top: 14px; }
.reading .read-links a { color: var(--c-teal-soft); font-weight: 700; }

/* Connection circles — radial layout (central node + dotted connectors) */
.circles h3 { text-align: center; color: var(--c-muted); font-weight: 700; margin: 0 0 8px; }
.circles-radial { position: relative; width: 100%; max-width: 440px; height: 330px; margin: 0 auto; }
.radial-lines { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; }
.radial-lines line { stroke: #c9c3b8; stroke-width: 1; stroke-dasharray: 2 4; vector-effect: non-scaling-stroke; }
.radial-center {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 98px; height: 98px; border-radius: 50%; border: 2px solid #cfcabf; background: #fff;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-weight: 700; font-size: 14px; line-height: 1.25; color: var(--c-text); z-index: 2;
}
.circles-radial .circle { position: absolute; transform: translate(-50%, -50%); width: 74px; z-index: 1; }
.circles-radial .pos-1 { top: 12%; left: 50%; }
.circles-radial .pos-2 { top: 26%; left: 80%; }
.circles-radial .pos-3 { top: 58%; left: 87%; }
.circles-radial .pos-4 { top: 84%; left: 66%; }
.circles-radial .pos-5 { top: 84%; left: 34%; }
.circles-radial .pos-6 { top: 58%; left: 13%; }
.circles-radial .pos-7 { top: 26%; left: 20%; }
.circle {
  width: 78px; text-align: center; text-decoration: none; color: var(--c-text);
  border: 0; background: none; padding: 0; font: inherit; cursor: pointer;
}
.circle[disabled] { cursor: default; opacity: .55; }
.circle.is-active .ring { background: var(--_c); color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, var(--_c) 25%, transparent); }
.circle .ring {
  width: 62px; height: 62px; margin: 0 auto 6px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--_c, var(--c-teal)); color: var(--_c, var(--c-teal));
  font-weight: 800; font-size: 19px; background: #fff;
}
.circle .lbl { font-size: 13px; color: var(--c-muted); font-weight: 600; }
.circle:hover .ring { background: var(--_c); color: #fff; }
.circle:hover { text-decoration: none; }
.c-topics { --_c: var(--c-circle-topics); }
.c-figures { --_c: var(--c-circle-figures); }
.c-shorts { --_c: var(--c-circle-shorts); }
.c-places { --_c: var(--c-circle-places); }
.c-articles { --_c: var(--c-circle-articles); }
.c-lessons { --_c: var(--c-circle-lessons); }
.c-commentators { --_c: var(--c-circle-commentators); }

/* Circle results panel */
.hp-study { padding: 0; overflow: hidden; }
.hp-study[hidden] { display: none; }
.hp-study-head {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--c-teal-dark); color: #fff; padding: 12px 18px;
}
.hp-study-title { font-weight: 700; }
.hp-study-close { background: none; border: 0; color: #fff; font-size: 16px; cursor: pointer; }
.hp-study-body { padding: 14px 20px; max-height: 460px; overflow-y: auto; }
.hp-study-body { columns: 2; column-gap: 28px; }
.hp-study-body.is-text { columns: 1; }
.hp-study-body.is-map { columns: 1; padding: 0; }
.hp-study-body.is-map .mx-mini-map { height: 380px; border: 0; border-radius: 0; }
.hp-study-item { break-inside: avoid; padding: 8px 0; border-bottom: 1px solid var(--c-border); }
.hp-study-name { margin: 0 0 4px; color: var(--c-bordeaux); font-size: 15px; }
.hp-study-text { font-family: var(--font-scripture); font-size: 17px; line-height: 1.8; }
.hp-study-item a { color: var(--c-teal-dark); font-weight: 600; text-decoration: none; }
.hp-study-item a:hover { text-decoration: underline; }
.hp-study-by { display: block; color: var(--c-muted); font-size: 12px; }
.hp-study-empty { color: var(--c-muted); text-align: center; padding: 10px 0; column-span: all; }

/* Timeline band */
.hp-timeline { padding: 20px 20px 14px; }
.tl-flags { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.tl-flag { position: relative; background: var(--c-bordeaux); color: #fff; border-radius: 8px; padding: 8px 12px 6px; min-width: 110px; text-align: center; }
.tl-flag::after { content: ""; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--c-bordeaux); border-bottom: 0; }
.tl-flag-name { display: block; font-size: 13px; font-weight: 700; line-height: 1.25; }
.tl-flag-range { display: block; font-size: 12px; opacity: .85; border-top: 1px solid rgba(255, 255, 255, .3); margin-top: 5px; padding-top: 3px; }
.tl-track { display: flex; align-items: center; gap: 8px; }
.tl-arrow { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #4a4f57; color: #fff; cursor: pointer; font-size: 16px; }
.tl-books { flex: 1; display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 10px 4px; border-top: 3px solid var(--c-border); position: relative; }
.tl-book { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--c-muted); font-size: 13px; font-weight: 600; padding: 0 10px; }
.tl-book:hover { text-decoration: none; color: var(--c-teal-dark); }
.tl-book .tl-dot { width: 13px; height: 13px; border-radius: 50%; background: #cfcabf; margin-top: -18px; border: 2px solid #fff; }
.tl-book.is-current { color: var(--c-bordeaux); font-weight: 800; }
.tl-book.is-current .tl-dot { background: var(--c-bordeaux); width: 16px; height: 16px; }

/* Content cards */
.hp-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.card > h3 { margin: 0; background: var(--c-teal-soft); color: #fff; padding: 12px 16px; font-size: 16px; }
.card ul { list-style: none; margin: 0; padding: 8px 16px 16px; }
.card li { padding: 8px 0; border-bottom: 1px dashed var(--c-border); }
.card li:last-child { border-bottom: 0; }
.card li a { font-weight: 600; }
.card li .muted { display: block; color: var(--c-muted); font-size: 13px; }

/* Contents grid (site sections) */
.hp-hero { text-align: center; padding: 10px 0 24px; }
.hp-hero h1 { color: var(--c-teal); font-size: 40px; margin: 0; }
.hp-hero p { color: var(--c-bordeaux); font-weight: 700; }

/* Search results */
.search-page { padding: 24px 28px; }
.search-title { color: var(--c-teal-dark); font-size: 24px; margin: 0 0 6px; }
.search-scope-tag { font-size: 14px; background: var(--c-teal); color: #fff; border-radius: var(--radius-pill); padding: 3px 12px; margin-inline-start: 8px; vertical-align: middle; }
.search-count, .search-note { color: var(--c-muted); margin: 0 0 16px; }
.search-results { list-style: none; margin: 0; padding: 0; }
.search-result { padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.sr-title { font-weight: 700; font-size: 17px; }
.sr-type { display: inline-block; font-size: 12px; color: var(--c-teal-dark); background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-pill); padding: 1px 10px; margin-inline-start: 8px; }
.sr-snippet { color: var(--c-text); margin: 6px 0 0; line-height: 1.7; }

/* Per-paragraph bidi for content: Hebrew paragraphs stay RTL, English/Spanish
   paragraphs render LTR/left-aligned, without flipping the RTL page chrome. */
.page-content article p,
.page-content article li,
.sr-snippet { unicode-bidi: plaintext; }

/* Footer */
.site-footer { background: var(--c-teal-dark); color: #fff; padding: 28px 0; margin-top: 30px; font-size: 14px; }
.site-footer a { color: #fff; opacity: .85; }

/* Responsive */
@media (max-width: 820px) {
  .page-grid { display: block; }
  .section-tabs { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
  .section-tabs a { flex: 1 1 auto; border-radius: 8px; }
  .hp-top { display: block; }
  .hp-top .circles { margin-top: 24px; }
  .hp-cards { display: block; }
  .hp-cards .card { margin-bottom: 16px; }
  .site-header .layout-container { height: auto; flex-wrap: wrap; padding: 10px 16px; }
  .header-search { max-width: none; width: 100%; }
}
