/* ═══════════════════════════════════════════════════════════════
   yeshiva-common.css — Shared styles for Yeshivat Tikkunei Ava
   All font paths relative to web/ where this file lives.
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── @font-face ──────────────────────────────────────────────── */
@font-face { font-family: 'David Libre'; src: url('fonts/david-libre-latin-400.woff2') format('woff2'); font-weight: 400; }
@font-face { font-family: 'David Libre'; src: url('fonts/david-libre-latin-700.woff2') format('woff2'); font-weight: 700; }
@font-face { font-family: 'David Libre'; src: url('fonts/david-libre-hebrew-400.woff2') format('woff2'); font-weight: 400; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: 'David Libre'; src: url('fonts/david-libre-hebrew-700.woff2') format('woff2'); font-weight: 700; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: 'Frank Ruhl Libre'; src: url('fonts/frank-ruhl-libre-latin-400.woff2') format('woff2'); font-weight: 400; }
@font-face { font-family: 'Frank Ruhl Libre'; src: url('fonts/frank-ruhl-libre-hebrew-400.woff2') format('woff2'); font-weight: 400; unicode-range: U+0590-05FF, U+FB1D-FB4F; }
@font-face { font-family: 'Frank Ruhl Libre'; src: url('fonts/frank-ruhl-libre-latin-700.woff2') format('woff2'); font-weight: 700; }
@font-face { font-family: 'Frank Ruhl Libre'; src: url('fonts/frank-ruhl-libre-hebrew-700.woff2') format('woff2'); font-weight: 700; unicode-range: U+0590-05FF, U+FB1D-FB4F; }

/* ─── Design Tokens ───────────────────────────────────────────── */
:root {
  --bg: #f5f0e8;
  --surface: #fffdf7;
  --primary: #2c1810;
  --primary-light: #5c3a28;
  --accent: #c9a84c;
  --accent-light: #e8d48b;
  --text: #2c1810;
  --text-light: #7a6b5d;
  --border: #d4c5a9;
  --success: #4a7c59;
  --warning: #b8860b;
  --danger: #8b2500;
  --sidebar-w: 260px;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(44,24,16,0.08);
  --shadow-lg: 0 4px 16px rgba(44,24,16,0.14);
  --transition: 0.2s ease;
}

/* ─── Body ────────────────────────────────────────────────────── */
body {
  font-family: 'David Libre', 'Frank Ruhl Libre', Georgia, serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
}

/* ─── Top Bar (module pages — sticky) ─────────────────────────── */
.topbar {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fffdf7;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar a { color: var(--accent-light); text-decoration: none; font-size: 0.9rem; }
.topbar a:hover { text-decoration: underline; }
.topbar h1 { font-size: 1.15rem; font-weight: 700; }
.topbar .progress-summary { font-size: 0.85rem; opacity: 0.85; }

/* ─── Header (landing / portal pages) ─────────────────────────── */
.header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fffdf7;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-lg);
}
.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.header h1 .star { color: var(--accent); font-size: 1.5rem; }
.header .subtitle { font-size: 0.85rem; opacity: 0.8; margin-top: 2px; }
.header-links { display: flex; gap: 12px; align-items: center; }
.header-links a {
  color: rgba(255,253,247,0.8);
  text-decoration: none;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background var(--transition);
}
.header-links a:hover { background: rgba(255,255,255,0.12); }
.donate-btn { background: var(--accent) !important; color: var(--primary) !important; font-weight: 700; }

/* ─── Layout (sidebar + main) ─────────────────────────────────── */
.layout { display: flex; min-height: calc(100vh - 52px); }

/* ─── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  overflow-y: auto;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: calc(100vh - 52px);
}
.sidebar-section { padding: 0 16px; margin-bottom: 8px; }
.sidebar-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-light);
  letter-spacing: 0.05em;
  margin-bottom: 4px;
  padding: 0 4px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: inherit;
  line-height: 1.4;
}
.sidebar-item:hover { background: #f0e8d8; }
.sidebar-item.active { background: #e8dcc8; font-weight: 700; color: var(--primary); }
.sidebar-item .check {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; flex-shrink: 0;
}
.sidebar-item .check.done { background: var(--success); border-color: var(--success); color: white; }
.sidebar-item.active .check { border-color: var(--accent); }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 16px; }

/* ─── Main Content ────────────────────────────────────────────── */
.main { flex: 1; padding: 32px 40px; max-width: 860px; overflow-y: auto; }

.lesson-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--accent);
}
.lesson-header h2 { font-size: 1.4rem; color: var(--primary); margin-bottom: 4px; }
.lesson-header .simanim { font-size: 0.9rem; color: var(--text-light); }

/* ─── Lesson Content ──────────────────────────────────────────── */
.lesson-content h3 {
  font-size: 1.15rem;
  color: var(--primary);
  margin: 28px 0 12px;
  padding-top: 8px;
  border-top: 1px solid #e8dcc8;
}
.lesson-content h3:first-child { border-top: none; margin-top: 0; }
.lesson-content h4 { font-size: 1rem; color: var(--primary-light); margin: 20px 0 8px; }
.lesson-content p { margin-bottom: 14px; }
.lesson-content ul, .lesson-content ol { margin: 0 0 14px 24px; }
.lesson-content li { margin-bottom: 6px; }

.lesson-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin: 12px 0 16px;
  background: #faf6ee;
  border-radius: 0 6px 6px 0;
  font-style: italic;
}
.lesson-content blockquote strong { font-style: normal; }

/* ─── Hebrew Text ─────────────────────────────────────────────── */
.hebrew {
  font-family: 'David Libre', 'Frank Ruhl Libre', serif;
  direction: rtl;
  font-size: var(--he-min-font);
  color: var(--primary);
}

/* ─── Tables ──────────────────────────────────────────────────── */
.lesson-content table { width: 100%; border-collapse: collapse; margin: 14px 0 18px; font-size: 0.85rem; }
.lesson-content th {
  background: #f0e8d8; padding: 8px 10px; text-align: left;
  border: 1px solid var(--border); font-weight: 700; color: var(--primary);
}
.lesson-content td { padding: 8px 10px; border: 1px solid var(--border); vertical-align: top; }
.lesson-content tr:nth-child(even) td { background: #faf8f2; }

/* ─── Tradition Boxes ─────────────────────────────────────────── */
.tradition-box {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin: 12px 0; background: #faf8f2;
}
.tradition-box .tradition-label {
  font-weight: 700; font-size: 0.8rem; text-transform: uppercase;
  color: var(--accent); margin-bottom: 4px;
}

/* ─── Navigation Footer ──────────────────────────────────────── */
.lesson-nav {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border);
}
.nav-btn {
  padding: 10px 20px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--primary); cursor: pointer;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  transition: background var(--transition);
}
.nav-btn:hover { background: #f0e8d8; }
.nav-btn.primary { background: var(--primary); color: #fffdf7; border-color: var(--primary); }
.nav-btn.primary:hover { background: var(--primary-light); }
.mark-btn {
  padding: 10px 20px; border: none; border-radius: 6px;
  background: var(--success); color: white; cursor: pointer;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
}
.mark-btn:hover { opacity: 0.9; }
.mark-btn.marked { background: #b8b8b8; cursor: default; }

/* ─── Quiz Components ─────────────────────────────────────────── */
.quiz-container { max-width: 700px; }
.quiz-header { margin-bottom: 20px; }
.quiz-header h3 { margin-bottom: 8px; }
.quiz-progress { font-size: 0.85rem; color: var(--text-light); }
.quiz-question {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.quiz-question h4 { color: var(--primary); margin-bottom: 12px; }
.quiz-question .scenario { margin-bottom: 16px; line-height: 1.7; }
.quiz-answer {
  display: none; margin-top: 12px; padding: 16px;
  background: #f0ebe0; border-radius: 6px; border-left: 3px solid var(--success);
}
.quiz-answer.visible { display: block; }
.reveal-btn {
  padding: 8px 16px; border: 1px solid var(--accent); border-radius: 6px;
  background: #faf6ee; color: var(--primary); cursor: pointer;
  font-family: inherit; font-size: 0.85rem; font-weight: 600;
}
.reveal-btn:hover { background: var(--accent-light); }
.self-grade { display: none; margin-top: 12px; gap: 8px; }
.self-grade.visible { display: flex; }
.grade-btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 6px;
  cursor: pointer; font-family: inherit; font-size: 0.85rem; background: var(--surface);
}
.grade-btn.correct { border-color: var(--success); color: var(--success); }
.grade-btn.correct:hover { background: #d5e8d4; }
.grade-btn.incorrect { border-color: var(--danger); color: var(--danger); }
.grade-btn.incorrect:hover { background: #f5d5d0; }

/* ─── Status Bar ──────────────────────────────────────────────── */
.status-bar {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 24px; font-size: 0.8rem; color: var(--text-light);
  display: flex; justify-content: space-between;
  position: fixed; bottom: 0; left: 0; right: 0;
}

/* ─── Focus Visibility (keyboard navigation) ────────────────── */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ─── Site Footer ────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.85em;
  color: var(--text-light, #666);
  border-top: 1px solid var(--border, #e0d5c1);
  margin-top: 40px;
}
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 800px) {
  .sidebar { display: none; }
  .main { padding: 20px 16px; }
  .mobile-nav {
    display: flex; background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 8px 12px; overflow-x: auto; gap: 4px;
  }
  .mobile-nav button {
    padding: 6px 12px; border: 1px solid var(--border); border-radius: 16px;
    background: var(--surface); font-family: inherit; font-size: 0.75rem;
    white-space: nowrap; cursor: pointer;
  }
  .mobile-nav button.active { background: var(--primary); color: #fffdf7; border-color: var(--primary); }
}
@media (min-width: 801px) {
  .mobile-nav { display: none; }
}

/* ─── Print ───────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .status-bar, .mobile-nav, .lesson-nav { display: none; }
  .main { padding: 0; max-width: 100%; }
  body { background: white; color: black; }
}
