*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand:   #1e3a5f;
  --accent:  #8b6914;
  --bg:      #fdfcf8;
  --surface: #ffffff;
  --border:  #d8d0c6;
  --text:    #1a1109;
  --muted:   #6b5f52;
  --link:    #1e3a5f;
  --gold:    #b8972a;
  --font-scale: 1;
}

html { direction: rtl; font-size: 17px; }

body {
  font-family: 'Frank Ruhl Libre', 'David Libre', 'David', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
}

/* ── Header (never scaled by the reader font-size control) ── */
.site-header {
  background: var(--brand);
  color: #fff;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  gap: 1rem;
  border-bottom: 3px solid var(--gold);
}
.site-header a {
  color: #fff;
  text-decoration: none;
}
.site-logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .45rem;
}
.site-logo::before {
  content: "◆";
  color: var(--gold);
  font-size: .8rem;
}
.site-header nav a {
  font-size: .88rem;
  font-weight: 400;
  opacity: .82;
  margin-right: 1.2rem;
  letter-spacing: .01em;
}
.site-header nav a:hover { opacity: 1; }

.font-size-control {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  vertical-align: middle;
  margin-right: 1.2rem;
}
.font-size-icon {
  font-size: .78rem;
  font-weight: 700;
  opacity: .75;
  user-select: none;
}
.font-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  line-height: 1;
  padding: 0;
  transition: background .15s, border-color .15s;
}
.font-btn:hover, .font-btn:focus-visible { background: var(--gold); border-color: var(--gold); }
.font-btn:active { transform: scale(.92); }

.search-bar {
  display: flex;
  gap: .4rem;
  flex: 1;
  max-width: 380px;
}
.search-bar input {
  flex: 1;
  padding: .32rem .7rem;
  border-radius: 3px;
  border: none;
  font-size: .88rem;
  direction: rtl;
  font-family: inherit;
}
.search-bar button {
  padding: .32rem .8rem;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: .83rem;
  font-family: inherit;
}
.search-bar button:hover { background: #9a7720; }
.search-bar button.adv-search-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,.4);
  color: #fff;
  white-space: nowrap;
  font-size: .78rem;
}
.search-bar button.adv-search-btn:hover { background: rgba(255,255,255,.12); border-color: #fff; }

/* ── Page content — the reader font-size control scales only the
   font-size of each rule below (via calc(...*var(--font-scale))), never
   `main`'s width/padding, so a bigger letter size just wraps onto more
   lines instead of widening the column. ── */
main { max-width: 900px; margin: 2.5rem auto; padding: 0 1.4rem; }

/* ── Advanced search ── */
.adv-search-toggle { margin-bottom: .8rem; }
.adv-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--muted);
  padding: .35rem .9rem;
  font-size: calc(.85rem * var(--font-scale));
  font-family: inherit;
  cursor: pointer;
}
.adv-toggle-btn:hover { border-color: var(--gold); color: var(--text); }
.adv-search-form {
  background: #f7f4ee;
  border: 1px solid var(--border);
  border-right: 3px solid var(--gold);
  border-radius: 4px;
  padding: 1rem 1.3rem;
  margin-bottom: 1.2rem;
}
.adv-search-form fieldset {
  border: none;
  padding: 0;
  margin: 0 0 .8rem;
}
.adv-search-form legend {
  font-size: calc(.85rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
  padding: 0;
  margin-bottom: .4rem;
}
.adv-search-form fieldset label {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: calc(.88rem * var(--font-scale));
  margin-left: 1.1rem;
  cursor: pointer;
}
.adv-row { margin-bottom: .7rem; font-size: calc(.88rem * var(--font-scale)); }
.adv-row label { cursor: pointer; }
.adv-row input[type="number"] {
  width: 80px;
  padding: .25rem .5rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: inherit;
  margin-right: .5rem;
}
.adv-submit-btn {
  padding: .4rem 1.4rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: calc(.88rem * var(--font-scale));
  font-family: inherit;
}
.adv-submit-btn:hover { background: #16283f; }

footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: .8rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

/* ── Typography ── */
h1 { font-size: calc(1.9rem * var(--font-scale)); margin-bottom: .5rem; color: var(--brand); font-weight: 700; }
h2 { font-size: calc(1.35rem * var(--font-scale)); margin-bottom: .3rem; }
h3 { font-size: calc(1.1rem * var(--font-scale)); }

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

.muted { color: var(--muted); font-size: calc(.88rem * var(--font-scale)); }

/* ── Tags ── */
.tag {
  display: inline-block;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 8px;
  font-size: calc(.77rem * var(--font-scale));
  margin: 2px 0;
  text-decoration: none;
}
.tag:hover { background: #f0ebe3; color: var(--text); text-decoration: none; border-color: #b8a898; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem 1.3rem;
  margin-bottom: .7rem;
  border-right: 3px solid transparent;
  transition: border-right-color .15s;
}
.card:hover { border-right-color: var(--gold); }
.card h3 a { color: var(--text); }
.card h3 a:hover { color: var(--link); text-decoration: none; }

mark { background: #fef9e4; padding: 0 2px; border-radius: 2px; }

/* ── Issue grid ── */
.issue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: .6rem;
  margin-top: 1.5rem;
}
.issue-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .85rem 1.1rem;
  text-decoration: none;
  color: var(--text);
  display: block;
  border-right: 3px solid transparent;
  transition: border-right-color .15s, background .15s;
}
.issue-card:hover {
  border-right-color: var(--gold);
  background: #faf7f2;
  text-decoration: none;
  color: var(--text);
}
.issue-card .issue-num {
  font-size: calc(1rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
}
.issue-card .article-count { font-size: calc(.82rem * var(--font-scale)); color: var(--muted); margin-top: .2rem; }

/* ── Article full text ── */
.article-body {
  line-height: 2;
  font-size: calc(1.05rem * var(--font-scale));
  text-align: justify;
  margin-top: 1.2rem;
}

/* ── Breadcrumb ── */
.breadcrumb { font-size: calc(.84rem * var(--font-scale)); color: var(--muted); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--link); }

/* ── Stats bar ── */
.stats { font-size: calc(.85rem * var(--font-scale)); color: var(--muted); margin-bottom: 1.5rem; }

/* ── Table of contents ── */
.toc {
  background: #f7f4ee;
  border: 1px solid var(--border);
  border-radius: 4px;
  border-right: 3px solid var(--gold);
  padding: 1rem 1.3rem;
  margin: 1rem 0 1.4rem;
  display: inline-block;
  min-width: 260px;
  max-width: 100%;
}
.toc-title {
  font-size: calc(.95rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
  margin-bottom: .5rem;
  letter-spacing: .02em;
}
.toc-list {
  margin: 0;
  padding-right: 1rem;
  list-style: none;
}
.toc-list li { margin: .25rem 0; font-size: calc(.91rem * var(--font-scale)); }
.toc-level-2 { padding-right: 1rem; font-size: calc(.87rem * var(--font-scale)); }
.toc-level-3 { padding-right: 2rem; font-size: calc(.83rem * var(--font-scale)); }
.toc-level-4 { padding-right: 3rem; font-size: calc(.8rem * var(--font-scale)); }
.toc-level-5 { padding-right: 4rem; font-size: calc(.78rem * var(--font-scale)); }
.toc-list a { color: var(--link); }
.toc-list a:hover { text-decoration: underline; }

/* ── Heading → TOC back-link ── */
.heading-toc-link {
  color: inherit;
  text-decoration: none;
}
.heading-toc-link:hover {
  text-decoration: none;
  opacity: .7;
}

/* ── Article headings ── */
.article-body h2.article-heading {
  font-size: calc(1.3rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
  margin: 2rem 0 .6rem;
}
.article-body h3.article-heading {
  font-size: calc(1.12rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
  border-right: 3px solid var(--gold);
  padding-right: .6rem;
  margin: 1.6rem 0 .5rem;
}
.article-body h4.article-heading,
.article-body h5.article-heading,
.article-body h6.article-heading {
  font-size: calc(1.03rem * var(--font-scale));
  font-weight: 700;
  color: var(--muted);
  margin: 1.2rem 0 .4rem;
}

/* ── Footnote refs in body (em, relative to the already-scaled body text) ── */
.fn-ref {
  color: var(--accent);
  text-decoration: none;
  font-size: .8em;
  vertical-align: super;
}
.fn-ref:hover { text-decoration: underline; }

/* ── Footnotes section ── */
.footnotes { margin-top: 1.5rem; }
.footnotes-title {
  font-size: calc(1rem * var(--font-scale));
  color: var(--muted);
  margin-bottom: .6rem;
}
.footnotes-list {
  padding-right: 1.4rem;
  font-size: calc(.88rem * var(--font-scale));
  line-height: 1.7;
  color: var(--muted);
}
.fn-item { margin-bottom: .4rem; }
.fn-back {
  color: var(--accent);
  text-decoration: none;
  margin-left: .4rem;
  font-size: .9em;
}
.fn-back:hover { text-decoration: underline; }

/* ── Authors grid ── */
.authors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .6rem;
  margin-top: 1rem;
}
.author-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .65rem 1rem;
  text-decoration: none;
  color: var(--text);
  border-right: 3px solid transparent;
  transition: border-right-color .15s;
}
.author-card:hover { border-right-color: var(--gold); color: var(--text); text-decoration: none; }
.author-name { font-size: calc(.93rem * var(--font-scale)); }
.author-count { font-size: calc(.78rem * var(--font-scale)); color: var(--muted); white-space: nowrap; margin-right: .5rem; }

/* ── About page ── */
.about-hero {
  text-align: center;
  padding: 2.5rem 1.5rem 2rem;
  background: linear-gradient(160deg, #f2ece0 0%, #fdfcf8 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  border-top: 3px solid var(--gold);
  margin-bottom: 2.5rem;
}
.about-hero h1 {
  font-size: calc(2.2rem * var(--font-scale));
  color: var(--brand);
  margin-bottom: .5rem;
}
.about-hero .subtitle {
  font-size: calc(1.05rem * var(--font-scale));
  color: var(--muted);
  font-style: italic;
}
.about-divider {
  text-align: center;
  color: var(--gold);
  font-size: calc(1.1rem * var(--font-scale));
  letter-spacing: .5rem;
  margin: 2.2rem 0;
  opacity: .75;
}
.about-section {
  margin-bottom: 2.5rem;
}
.about-section h2 {
  font-size: calc(1.3rem * var(--font-scale));
  color: var(--brand);
  border-right: 3px solid var(--gold);
  padding-right: .8rem;
  margin-bottom: 1rem;
}
.about-section p { margin-bottom: .8rem; line-height: 1.85; }

/* Issue 100 image */
.issue-100-wrap {
  text-align: center;
  margin: .5rem 0 1.5rem;
}
.issue-100-frame {
  display: inline-block;
  background: linear-gradient(145deg, #1a2e4a 0%, #1e3a5f 100%);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.28);
}
.issue-100-img {
  display: block;
  max-width: 300px;
  width: 100%;
  border-radius: 4px;
}
.issue-100-caption {
  margin-top: .7rem;
  font-size: calc(.88rem * var(--font-scale));
  color: var(--muted);
  max-width: 420px;
  display: inline-block;
}

/* Departments grid */
.departments-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
  margin-top: .8rem;
}
.dept-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-right: 3px solid var(--gold);
  border-radius: 4px;
  padding: .9rem 1.1rem;
}
.dept-card strong {
  display: block;
  color: var(--brand);
  font-size: calc(.95rem * var(--font-scale));
  margin-bottom: .3rem;
}
.dept-card p {
  font-size: calc(.87rem * var(--font-scale));
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

/* Editorial list */
.editorial-list {
  list-style: none;
  padding: 0;
  margin-top: .8rem;
}
.editorial-list li {
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: .4rem;
  align-items: baseline;
  flex-wrap: wrap;
}
.editorial-list li:last-child { border-bottom: none; }
.editorial-name  { font-weight: bold; color: var(--brand); }
.editorial-role  { font-size: calc(.9rem * var(--font-scale)); color: var(--muted); }

/* Closing quote */
.about-quote {
  text-align: center;
  font-size: calc(1.15rem * var(--font-scale));
  font-style: italic;
  color: var(--brand);
  border: 1px solid var(--gold);
  border-radius: 4px;
  padding: 1.4rem 2rem;
  margin: 2.5rem 0 1rem;
  background: linear-gradient(135deg, #fffdf4 0%, #faf5e4 100%);
}
.about-nav-links {
  text-align: center;
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.about-nav-links a {
  display: inline-block;
  padding: .5rem 1.4rem;
  border: 1px solid var(--brand);
  border-radius: 3px;
  font-size: calc(.9rem * var(--font-scale));
  color: var(--brand);
  text-decoration: none;
}
.about-nav-links a:hover {
  background: var(--brand);
  color: #fff;
  text-decoration: none;
}

/* ── מפתחות (topical index) ── */
.mafteach-topic-grid { grid-template-columns: 1fr 1fr; }
.mafteach-topic-card p { font-size: calc(.82rem * var(--font-scale)); color: var(--muted); margin-top: .3rem; }

.mafteach-body { margin-top: 1.5rem; }

.mafteach-section { margin-top: 1.6rem; }
.mafteach-section.level-2 { padding-right: 0; }
.mafteach-section.level-3 { padding-right: 1rem; }
.mafteach-section.level-4 { padding-right: 2rem; }
.mafteach-section.level-5 { padding-right: 3rem; }

.mafteach-heading {
  color: var(--brand);
  margin-bottom: .5rem;
}
.mafteach-section.level-2 > .mafteach-heading {
  font-size: calc(1.3rem * var(--font-scale));
  border-bottom: 1px solid var(--border);
  padding-bottom: .3rem;
}
.mafteach-section.level-3 > .mafteach-heading {
  font-size: calc(1.1rem * var(--font-scale));
  border-right: 3px solid var(--gold);
  padding-right: .6rem;
}
.mafteach-section.level-4 > .mafteach-heading,
.mafteach-section.level-5 > .mafteach-heading {
  font-size: calc(.98rem * var(--font-scale));
  color: var(--muted);
}

.mafteach-entries {
  list-style: none;
  margin: .4rem 0 .8rem;
  padding: 0;
}
.mafteach-entry {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: calc(.93rem * var(--font-scale));
}
.mafteach-entry:last-child { border-bottom: none; }
.mafteach-entry > a:first-child { flex: 1; color: var(--text); }
.mafteach-entry > a:first-child:hover { color: var(--link); }
.pdf-link {
  flex-shrink: 0;
  font-size: calc(.68rem * var(--font-scale));
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
}
.pdf-link:hover { background: #f0ebe3; text-decoration: none; border-color: #b8a898; }

/* ── תגובות (article ↔ response cross-links) ── */
.response-to-link {
  display: inline-block;
  font-size: calc(.88rem * var(--font-scale));
  color: var(--muted);
  background: #f7f4ee;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: .35rem .9rem;
  margin-bottom: .8rem;
  text-decoration: none;
}
.response-to-link:hover { border-color: var(--gold); color: var(--text); text-decoration: none; }
.response-to-link strong { color: var(--brand); }

.responses-box {
  background: #f7f4ee;
  border: 1px solid var(--border);
  border-radius: 4px;
  border-right: 3px solid var(--accent);
  padding: .85rem 1.3rem;
  margin: .8rem 0 1.4rem;
}
.responses-box-title {
  font-size: calc(.95rem * var(--font-scale));
  font-weight: 700;
  color: var(--brand);
  margin-bottom: .4rem;
  letter-spacing: .02em;
}
.responses-list { list-style: none; margin: 0; padding: 0; }
.responses-list li { font-size: calc(.91rem * var(--font-scale)); padding: .2rem 0; }
.responses-list a { color: var(--link); }
.responses-list a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 600px) {
  html { font-size: 15px; }
  .search-bar { max-width: 100%; }
  .site-header { flex-wrap: wrap; height: auto; padding: .6rem 1rem; gap: .5rem; }
  .departments-grid { grid-template-columns: 1fr; }
  .about-hero h1 { font-size: calc(1.7rem * var(--font-scale)); }
}
