/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
h1[id], h2[id], h3[id], h4[id], [id].mw-headline, span[id] { scroll-margin-top: 10px; }
a[href^="http"]::after { content: "\00a0\2197"; font-size: 0.75em; }

:root {
  --header-bg: #5a1020;
  --light-bg: #fffdf9;
  --content-max: 780px;
  --accent: #5a1020;
  --accent-gold: #b8862d;
  --accent-gold-light: #d4a94a;
  --accent-gold-pale: #e8d5a8;
  --text: #2c2420;
  --text-muted: #5a534d;
  --border: #e0d8d0;
  --toc-bg: #f5f0e8;
  --blockquote-bg: #faf5ed;
}

body {
  font-family: 'Frank Ruhl Libre', 'David', 'Noto Serif Hebrew', serif;
  color: var(--text);
  font-size: 20px;
  line-height: 1.85;
  direction: rtl;
  background: var(--light-bg);
}

/* Header */
.site-header {
  background: linear-gradient(180deg, #6b1828 0%, var(--header-bg) 100%);
  color: #fff;
  z-index: 100;
  border-bottom: 2px solid var(--accent-gold);
  box-shadow: 0 2px 12px rgba(90, 16, 32, 0.25);
}
.header-inner {
  max-width: var(--content-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  height: 70px;
  padding: 0 2.5rem;
}
.site-logo {
  color: #fff;
  text-decoration: none;
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.site-logo img {
  height: 40px;
  width: auto;
}

/* Header search */
.header-search {
  margin-inline-start: auto;
  min-width: 180px;
  max-width: 300px;
  position: relative;
  --pagefind-ui-scale: 0.55;
}
.header-search .pagefind-ui__form::before {
  display: none !important;
}
.header-search .pagefind-ui__search-input {
  font-size: 0.85rem !important;
  direction: rtl;
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  border-radius: 20px !important;
  padding: 0.25rem 0.8rem !important;
  width: 100% !important;
  height: 36px !important;
  font-weight: 400 !important;
}
.header-search .pagefind-ui__search-input::placeholder { color: var(--text-muted) !important; }
.header-search .pagefind-ui__search-input:focus {
  outline: none !important;
  border-color: var(--accent-gold) !important;
  box-shadow: 0 0 0 2px rgba(184, 134, 45, 0.2);
}
.header-search .pagefind-ui__search-clear { display: none !important; }
.header-search .pagefind-ui__drawer {
  position: absolute;
  top: 100%;
  right: 0;
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 200;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  text-align: right;
}
.header-search .pagefind-ui__results-area { margin-top: 0 !important; padding: 0 !important; }
.header-search .pagefind-ui__result {
  padding: 0.4rem 0 !important;
  border-bottom: 1px solid var(--border);
}
.header-search .pagefind-ui__result:last-child { border-bottom: none; }
.header-search .pagefind-ui__result-inner { margin: 0 !important; padding: 0 !important; }
.header-search .pagefind-ui__result-thumb { display: none !important; }
.header-search .pagefind-ui__result-title { line-height: 1.3 !important; margin: 0 !important; }
.header-search .pagefind-ui__result-link { color: var(--accent) !important; font-size: 1rem !important; display: block; text-align: right; font-weight: 600 !important; }
.header-search .pagefind-ui__result-excerpt { font-size: 0.95rem !important; color: var(--text-muted); text-align: right; margin: 0.15rem 0 0 !important; padding: 0 !important; min-width: 0 !important; }
.header-search .pagefind-ui__message { padding: 0.3rem 0 !important; height: auto !important; font-size: 0.85rem !important; color: var(--text-muted) !important; text-align: right; }
.header-search .pagefind-ui__button { display: none; }

/* Hamburger (mobile only) */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  flex-direction: column;
  gap: 5px;
}
.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.header-nav { display: none; }

/* Layout */
.page-layout {
  display: flex;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 2.5rem;
  min-height: calc(100vh - 70px);
}



/* TOC */
.toc {
  margin: 1.2rem 0;
  padding: 1rem 1.4rem;
  background: var(--toc-bg);
  border-radius: 6px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.toc .toctitle h2 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}
.toc > ul { list-style: decimal; padding-inline-start: 1.5rem; }
.toc ul ul { list-style: decimal; padding-inline-start: 1.2rem; }
.toc .tocnumber { display: none; }
.toc li { margin: 0.2rem 0; }
.toc a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.15s;
}
.toc a:hover { color: var(--accent); text-decoration: underline; }
.toc .toctogglespan { display: none; }
.toc input { display: none; }

/* Merged TOC (ספר ימות המשיח בהלכה): part labels */
.toc.toc-merged .toc-part-label {
  font-family: 'Noto Serif Hebrew', serif;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 0.8rem;
  margin-bottom: 0.25rem;
  color: var(--accent);
}
.toc.toc-merged .toc-part-label:first-of-type { margin-top: 0.4rem; }
.toc.toc-merged .toc-list { margin-bottom: 0.5rem; }
.toc.toc-merged .toc-list:last-child { margin-bottom: 0; }

/* Content */
.content {
  flex: 1;
  padding: 2rem 0;
  min-width: 0;
}

article h1 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
article h2 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.45rem;
  margin: 2rem 0 0.8rem;
  padding-bottom: 0.5rem;
  color: var(--accent);
  border-bottom: none;
  text-align: center;
  position: relative;
}
article h2::after {
  content: '';
  display: block;
  width: 60px;
  height: 2px;
  background: var(--accent-gold);
  margin: 0.4rem auto 0;
  border-radius: 1px;
}
article h3 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.15rem;
  margin: 1.4rem 0 0.5rem;
  padding-right: 0.7rem;
  border-right: 3px solid var(--accent-gold);
}
article p { margin: 0.6rem 0; }
article ul, article ol { margin: 0.5rem 0; padding-inline-start: 1.5rem; }
article li { margin: 0.2rem 0; }
article a {
  color: var(--accent-gold);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  transition: color 0.15s;
}
article a:hover {
  color: #8a6418;
  text-decoration-style: solid;
}
article pre {
  font-family: inherit;
  white-space: pre-wrap;
  background: var(--blockquote-bg);
  border-right: 3px solid var(--accent-gold);
  padding: 0.8rem 1.2rem;
  margin: 0.8rem 0;
  line-height: 1.7;
  border-radius: 6px;
}
article blockquote {
  border-right: 3px solid var(--accent-gold);
  padding: 1rem 1.5rem 1rem 1rem;
  margin: 1.2rem 0;
  background: var(--blockquote-bg);
  color: var(--text);
  border-radius: 0 6px 6px 0;
  position: relative;
}
article blockquote::before {
  content: '\201F';
  position: absolute;
  top: -0.15rem;
  right: 0.5rem;
  font-size: 3rem;
  color: var(--accent-gold-pale);
  line-height: 1;
  font-family: serif;
}
article table {
  border-collapse: collapse;
  margin: 1rem 0;
  width: 100%;
}
article th, article td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
  text-align: right;
}
article th {
  background: var(--toc-bg);
  font-family: 'Noto Serif Hebrew', serif;
  font-weight: 700;
}
article tr:nth-child(even) td { background: #fdfbf7; }
article sup { font-size: 0.75em; }

/* Book-part dividers */
.book-part {
  margin-top: 2.5rem;
  padding-top: 2rem;
  position: relative;
}
.book-part::before {
  content: '';
  display: block;
  height: 1px;
  background: linear-gradient(to left, transparent 0%, var(--accent-gold-pale) 30%, var(--accent-gold) 50%, var(--accent-gold-pale) 70%, transparent 100%);
  margin-bottom: 2rem;
}
.book-part:first-of-type { margin-top: 1rem; padding-top: 0; }
.book-part:first-of-type::before { display: none; }
.book-part .part-title {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.35rem;
  margin: 0 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 2px solid var(--accent-gold);
  color: var(--accent);
}
.book-part-b {
  margin-top: 3rem;
  padding-top: 2.5rem;
}
.book-part-b::before {
  height: 2px;
}

/* Article prefix & author */
.article-prefix {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.article-prefix a { color: var(--accent); text-decoration: none; }
.article-prefix a:hover { text-decoration: underline; }
.article-author {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
  margin-bottom: 1rem;
}

/* Breadcrumbs */
.breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.breadcrumbs a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumbs a:hover {
  color: #8a6418;
  text-decoration: underline;
}
.breadcrumbs .sep { color: var(--border); }
.breadcrumbs .current { color: var(--text); }

/* Categories footer */
.article-categories {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.article-categories a {
  display: inline-block;
  background: transparent;
  padding: 0.2rem 0.7rem;
  border-radius: 20px;
  margin: 0.2rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.article-categories a:hover {
  background: var(--accent-gold-pale);
  border-color: var(--accent-gold);
  color: var(--accent);
}

/* Category / index page listing */
.page-list { list-style: none; }
.page-list li {
  margin: 0;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  border-right: 3px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.page-list li:hover {
  border-right-color: var(--accent-gold);
  background: var(--blockquote-bg);
}
.page-list a { font-size: 1rem; }

/* Homepage hero */
.home-hero {
  text-align: center;
  padding: 2rem 0 1.5rem;
}
.home-hero h1 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 2.4rem;
  border-bottom: none;
  margin-bottom: 0.5rem;
}
.home-hero > p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 600px;
  margin: 0.3rem auto;
}

/* Homepage search */
.home-search {
  max-width: 500px;
  margin: 1.2rem auto 0;
}
.home-search .pagefind-ui__form { position: relative; }
.home-search .pagefind-ui__search-input {
  font-size: 1rem;
  direction: rtl;
  background: #fff;
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 28px;
  padding: 0.5rem 1.2rem;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.home-search .pagefind-ui__search-input:focus {
  outline: none;
  border-color: var(--accent-gold);
  box-shadow: 0 0 0 3px rgba(184, 134, 45, 0.15);
}
.home-search .pagefind-ui__search-input::placeholder { color: var(--text-muted); }
.home-search .pagefind-ui__search-clear { color: var(--text-muted); }
.home-search .pagefind-ui__drawer {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 0 0 10px 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.4rem 0.6rem;
  text-align: right;
}
.home-search .pagefind-ui__results-area { margin-top: 0 !important; padding: 0 !important; }
.home-search .pagefind-ui__result {
  padding: 0.4rem 0 !important;
  border-bottom: 1px solid var(--border);
}
.home-search .pagefind-ui__result:last-child { border-bottom: none; }
.home-search .pagefind-ui__result-inner { margin: 0 !important; padding: 0 !important; }
.home-search .pagefind-ui__result-thumb { display: none !important; }
.home-search .pagefind-ui__result-link {
  color: var(--accent);
  font-size: 0.95rem;
  text-align: right;
  display: block;
}
.home-search .pagefind-ui__result-excerpt {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: right;
  margin: 0 !important;
  padding: 0 !important;
}
.home-search .pagefind-ui__message {
  padding: 0.3rem 0 !important;
  height: auto !important;
  font-size: 0.85rem !important;
  color: var(--text-muted) !important;
  text-align: right;
}
.home-search .pagefind-ui__button { display: none; }

/* Homepage section cards */
.home-sections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin: 1.5rem 0 2rem;
}
.section-card {
  display: block;
  background: var(--blockquote-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  border-right: 3px solid var(--accent-gold-pale);
  padding: 1.2rem;
  text-decoration: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.section-card:hover {
  border-right-color: var(--accent-gold);
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.section-card h2 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.2rem;
  color: var(--accent);
  margin: 0 0 0.4rem;
  text-align: right;
  border-bottom: none;
  padding-bottom: 0;
}
.section-card h2::after { display: none; }
.section-card p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin: 0;
  line-height: 1.6;
}

/* Homepage dvar malchus */
.home-dvar-malchus h2 {
  text-align: center;
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.45rem;
  color: var(--accent);
  margin: 1rem 0 0.8rem;
}
.home-dvar-malchus blockquote {
  border-right: 3px solid var(--accent-gold);
  padding: 1.2rem 1.5rem 1.2rem 1rem;
  margin: 0;
  background: var(--blockquote-bg);
  border-radius: 0 6px 6px 0;
  position: relative;
}
.home-dvar-malchus blockquote::before {
  content: '\201F';
  position: absolute;
  top: -0.15rem;
  right: 0.5rem;
  font-size: 3rem;
  color: var(--accent-gold-pale);
  line-height: 1;
  font-family: serif;
}
.home-dvar-malchus cite {
  display: block;
  margin-top: 0.8rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* Homepage team */
.home-team {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.home-team h2 {
  font-family: 'Noto Serif Hebrew', serif;
  font-size: 1.3rem;
  color: var(--accent);
  margin-bottom: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
  body { font-size: 18px; }

  .page-layout { padding: 0 1rem; }
  .header-inner {
    padding: 0 1rem;
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.4rem;
  }
  .site-logo { font-size: 1.1rem; }
  .site-logo img { height: 32px; }
  .header-search {
    order: 3;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    margin: 0.3rem 0 0.2rem;
  }
  .hamburger { display: flex; }
  .header-nav {
    order: 4;
    width: 100%;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border-top: 1px solid rgba(255,255,255,0.15);
  }
  .header-nav.open { display: flex; }
  .header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .header-nav a:hover { color: #fff; }

  .content { padding: 1rem 0; }
  article h1 { font-size: 1.5rem; }
  article h2 { font-size: 1.2rem; }
  article h2::after { width: 40px; }
  article h3 { font-size: 1.05rem; }
  article blockquote::before { font-size: 2rem; right: 0.3rem; }

  .toc { padding: 0.6rem 0.8rem; }
  .toc > ul, .toc ul ul { padding-inline-start: 1.2rem; }

  .page-list li { padding: 0.55rem 0.6rem; }
  .page-list a { font-size: 1.05rem; }

  article table { display: block; overflow-x: auto; }

  .home-hero h1 { font-size: 1.8rem; }
  .home-hero > p { font-size: 0.95rem; }
  .home-sections { grid-template-columns: 1fr; gap: 0.8rem; }
  .section-card { padding: 1rem; }
  .home-dvar-malchus blockquote::before { font-size: 2rem; right: 0.3rem; }
}
