/* docs.emorli.com — "green Wikipedia" feel.
   Palette mirrors lib/core/theme/app_colors.dart (same vars as docs/features_he.html). */

:root {
  --primary: #7CB67C;
  --primary-dark: #5A9A5A;
  --primary-light: #A8D5A8;
  --secondary: #D4B896;
  --background: #FAF8F5;
  --surface: #FFFFFF;
  --on-surface: #2D3436;
  --on-surface-light: #636E72;
  --on-surface-lighter: #95A5A6;
  --border: #E0E0E0;
  --border-light: #F0F0F0;
  --tint: #F1F7F1;            /* soft sage wash for boxes */
  --tint-strong: #E4F0E4;
  --radius-card: 16px;
  --radius-small: 8px;
  --shadow-card: 0 2px 12px rgba(45, 52, 54, 0.06), 0 1px 3px rgba(45, 52, 54, 0.05);

  --cat-noun-bg: #FFE0B2;    --cat-noun-border: #FB8C00;
  --cat-person-bg: #FFE082;  --cat-person-border: #F9A825;
  --cat-emotion-bg: #F48FB1; --cat-emotion-border: #E91E63;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--background);
  color: var(--on-surface);
  font-family: 'Heebo', 'Rubik', -apple-system, 'Segoe UI', 'Arial Hebrew', sans-serif;
  font-size: 17px;
  line-height: 1.8;
  text-align: right;
}

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-card);
  padding: 10px 20px;
}

.nav-toggle {
  font-size: 20px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  padding: 4px 12px;
  cursor: pointer;
  color: var(--on-surface);
}
.nav-toggle:hover { background: var(--tint); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 20px;
  white-space: nowrap;
}
.brand small {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--on-surface-light);
  line-height: 1.1;
}

.brand-logo {
  height: 40px;
  width: 40px;
  object-fit: contain;
  flex: none;
}

.search { position: relative; margin-inline-start: auto; flex: 0 1 340px; }
.search input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 7px 14px;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--background);
  color: var(--on-surface);
  outline: none;
}
.search input:focus { border-color: var(--primary); background: var(--surface); }

#search-results {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  min-width: 300px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 30px rgba(45, 52, 54, 0.15);
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
}
#search-results a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-small);
  text-decoration: none;
  color: var(--on-surface);
}
#search-results a:hover, #search-results a.selected { background: var(--tint); }
#search-results a .r-title { font-weight: 700; color: var(--primary-dark); }
#search-results a .r-desc { font-size: 13px; color: var(--on-surface-light); }
#search-results .r-empty { padding: 10px 12px; color: var(--on-surface-light); font-size: 14px; }

/* ---------- layout ---------- */

.layout {
  display: flex;
  max-width: 1200px;
  margin: 0 auto;
  align-items: flex-start;
}

.article {
  flex: 1;
  min-width: 0;
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

/* side panel: overlay drawer on all sizes — content column stays centered & calm */
.sidenav {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: 300px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border-light);
  box-shadow: 0 0 40px rgba(45, 52, 54, 0.18);
  padding: 20px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease;
  z-index: 40;
}
[dir="ltr"] .sidenav { transform: translateX(-100%); }
body.nav-open .sidenav { transform: translateX(0); }

.sidenav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45, 52, 54, 0.35);
  z-index: 35;
}
body.nav-open .sidenav-backdrop { display: block; }

.nav-section { margin-bottom: 18px; }
.nav-section-title {
  font-weight: 800;
  color: var(--primary-dark);
  font-size: 14px;
  margin-bottom: 4px;
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }
.nav-section li a {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-small);
  text-decoration: none;
  color: var(--on-surface);
  font-size: 15px;
}
.nav-section li a:hover { background: var(--tint); }
.nav-section li.active a { background: var(--tint-strong); font-weight: 700; }

/* ---------- article ---------- */

.breadcrumbs {
  font-size: 14px;
  color: var(--on-surface-light);
  margin-bottom: 14px;
}
.breadcrumbs a { color: var(--primary-dark); text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.crumb-sep { margin: 0 8px; color: var(--on-surface-lighter); }

/* Wikipedia-style TOC box */
.toc {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 12px 20px;
  margin: 4px 0 22px;
  font-size: 15px;
  min-width: 240px;
}
.toc summary {
  font-weight: 800;
  cursor: pointer;
  color: var(--on-surface);
}
.toc ol { margin: 8px 0 0; padding-inline-start: 22px; }
.toc ol.toc-sub { margin: 0; font-size: 14px; }
.toc a { color: var(--primary-dark); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

.content h1 {
  font-family: 'Suez One', 'Heebo', serif;
  font-weight: 400;
  font-size: 34px;
  line-height: 1.3;
  margin: 0 0 6px;
  color: var(--on-surface);
  border-bottom: 3px solid var(--primary-light);
  padding-bottom: 10px;
}
.content h2 {
  font-size: 24px;
  font-weight: 800;
  margin: 36px 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}
.content h3 { font-size: 19px; font-weight: 700; margin: 26px 0 4px; }

.content a { color: var(--primary-dark); text-decoration: none; border-bottom: 1px solid var(--primary-light); }
.content a:hover { color: var(--primary); border-bottom-color: var(--primary); }
.content a[href^="http"]:not([href*="emorli.com"])::after { content: " ↗"; font-size: 12px; }

.content p { margin: 10px 0; }
.content ul, .content ol { padding-inline-start: 26px; }
.content li { margin: 4px 0; }

.content strong { font-weight: 700; }

.content table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  background: var(--surface);
  border-radius: var(--radius-small);
  overflow: hidden;
  font-size: 15px;
}
.content th, .content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: right;
  vertical-align: top;
}
.content th { background: var(--tint); font-weight: 700; }

.content blockquote {
  margin: 14px 0;
  padding: 2px 18px;
  border-inline-start: 4px solid var(--primary-light);
  background: var(--tint);
  border-radius: var(--radius-small);
  color: var(--on-surface-light);
}

.content code {
  background: var(--border-light);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: inherit; /* Hebrew UI labels, not code */
}

/* callouts */
.callout {
  border-radius: var(--radius-card);
  padding: 12px 18px;
  margin: 16px 0;
  border: 1px solid var(--tint-strong);
  background: var(--tint);
}
.callout-note { border-color: #F0E4CE; background: #FAF4E8; }
.callout-title { font-weight: 800; margin-bottom: 2px; }
.callout p { margin: 6px 0; }

/* media figures + placeholders */
figure.media { margin: 20px 0; text-align: center; }
figure.media img, figure.media video {
  max-width: 100%;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
}
figure.media figcaption {
  font-size: 14px;
  color: var(--on-surface-light);
  margin-top: 6px;
}
.media-placeholder-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-content: center;
  min-height: 130px;
  border: 2px dashed var(--primary-light);
  border-radius: var(--radius-card);
  background: var(--tint);
  color: var(--on-surface-light);
  font-size: 15px;
  padding: 18px;
}
.media-placeholder-icon { font-size: 28px; }

/* see also */
.see-also {
  margin-top: 44px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 24px;
}
.see-also h2 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 800;
  color: var(--primary-dark);
}
.see-also ul { margin: 0; padding-inline-start: 22px; }
.see-also a { color: var(--primary-dark); font-weight: 700; text-decoration: none; }
.see-also a:hover { text-decoration: underline; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border-light);
  background: var(--surface);
  text-align: center;
  padding: 18px;
  font-size: 14px;
  color: var(--on-surface-light);
}
.site-footer a { color: var(--primary-dark); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer span { margin: 0 8px; color: var(--on-surface-lighter); }

/* ---------- wide screens: TOC docks to the side ---------- */

/* In RTL the first grid column is the RIGHT one — the TOC sits at the right
   edge of the article area and stays sticky while scrolling. On narrower
   screens it remains an inline box above the article. */
@media (min-width: 1100px) {
  .article {
    max-width: 1080px;
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    column-gap: 40px;
    align-items: start;
  }
  .breadcrumbs { grid-column: 1 / -1; }
  .toc {
    grid-column: 1;
    grid-row: 2 / span 3;
    position: sticky;
    top: 82px;
    display: block;
    min-width: 0;
    margin: 0;
  }
  .content { grid-column: 2; grid-row: 2; }
  .see-also { grid-column: 2; grid-row: 3; }
  /* pages without a TOC: let the content span the full width */
  .article:not(:has(.toc)) { display: block; max-width: 780px; }
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  body { font-size: 16px; }
  .site-header { flex-wrap: wrap; padding: 8px 12px; }
  .search { flex-basis: 100%; order: 3; margin: 4px 0 0; }
  .brand-text small { display: none; }
  .article { padding: 20px 16px 48px; }
  .content h1 { font-size: 27px; }
  .toc { display: block; }
}
