/* ═══════════════════════════════════════════════════════════════
   cheder-common.css — Shared styles for Ava Torah Cheder modules
   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'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/david-libre-hebrew-400.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'David Libre'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/david-libre-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'David Libre'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/david-libre-hebrew-700.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'David Libre'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/david-libre-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Frank Ruhl Libre'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/frank-ruhl-libre-hebrew-400.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Frank Ruhl Libre'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/frank-ruhl-libre-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Frank Ruhl Libre'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/frank-ruhl-libre-hebrew-700.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}
@font-face {
  font-family: 'Frank Ruhl Libre'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/frank-ruhl-libre-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Rashi Hebrew'; font-style: normal; font-weight: 600; font-display: swap;
  src: url('fonts/noto-rashi-hebrew-600.woff2') format('woff2');
  unicode-range: U+0590-05FF, U+200C-2010, U+20AA, U+25CC, U+FB1D-FB4F;
}

/* ─── Design Tokens ───────────────────────────────────────────── */
:root {
  /* Modules override these for their color scheme */
  --ch-primary: #1a5276;
  --ch-primary-light: #2980b9;
  --ch-gold: #d4af37;
  --ch-gold-light: #f5e6b8;
  --ch-bg: #faf7f2;
  --ch-card: #fff;
  --ch-text: #1a1a1a;
  --ch-text-light: #666;
  --ch-border: #e0d5c1;
  --ch-shadow: 0 2px 8px rgba(0,0,0,0.1);
  --ch-radius: 10px;
  --ch-transition: 0.2s ease;
  /* Font sizes — reference global minimum from hebrew-min.css */
  --he-font-size: var(--he-min-font);
  --en-font-size: 1em;
}

/* ─── Body Base ───────────────────────────────────────────────── */
body {
  font-family: 'David Libre', Georgia, serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Rashi Script ────────────────────────────────────────────── */
.rashi-display { font-family: 'Noto Rashi Hebrew', 'David Libre', serif; font-weight: 600; direction: rtl; }

/* ═══════════════════════════════════════════════════════════════
   STANDARD HEADER — Dashboard-style gradient bar for all modules
   Themed via --ch-primary and --ch-primary-light.
   ═══════════════════════════════════════════════════════════════ */
.cheder-header {
  background: linear-gradient(135deg, var(--ch-primary), var(--ch-primary-light));
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
  position: relative;
  z-index: 10;
}
.cheder-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.cheder-header h1 .icon { font-size: 1.4rem; }
.cheder-header-back {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background var(--ch-transition);
  white-space: nowrap;
}
.cheder-header-back:hover { background: rgba(255,255,255,0.15); }
.cheder-header-right {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.9rem;
}
.cheder-header-right a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background var(--ch-transition);
}
.cheder-header-right a:hover { background: rgba(255,255,255,0.15); }
.cheder-header .student-name { font-weight: 600; }
.cheder-header .grade-badge {
  background: rgba(255,255,255,0.2);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
}

/* ─── Container ───────────────────────────────────────────────── */
.container { max-width: 940px; margin: 0 auto; padding: 0 16px; }

/* ─── Card ────────────────────────────────────────────────────── */
.card {
  background: var(--ch-card);
  border-radius: var(--ch-radius);
  box-shadow: var(--ch-shadow);
  padding: 18px;
  margin-bottom: 14px;
  border-left: 4px solid var(--ch-gold);
}
.card h3 { color: var(--ch-primary); margin-bottom: 8px; font-size: 1.1em; }
.card.green { border-left-color: #2e7d32; }
.card.purple { border-left-color: #6a1b9a; }
.card.red { border-left-color: #b71c1c; }

/* ─── Tab Bar (underline style) ───────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 10px 0 0;
  border-bottom: 2px solid var(--ch-border);
  overflow-x: auto;
}
.tab-bar button {
  padding: 8px 16px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.95em;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  color: var(--ch-text-light);
  white-space: nowrap;
  transition: all var(--ch-transition);
}
.tab-bar button.active { color: var(--ch-primary); border-bottom-color: var(--ch-gold); font-weight: 700; }
.tab-bar button:hover { color: var(--ch-primary); }
.tab-panel { display: none; padding: 16px 0; }
.tab-panel.active { display: block; }

/* ─── Profile Bar ─────────────────────────────────────────────── */
.profile-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.9em;
  flex-wrap: wrap;
  gap: 6px;
}
.profile-bar select, .profile-bar button {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--ch-border);
  font-family: inherit;
  font-size: 0.9em;
  cursor: pointer;
}
.profile-bar a { color: var(--ch-primary); text-decoration: none; }

/* ─── Phrase Table (Hebrew/English parallel text) ─────────────── */
.phrase-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.phrase-table td { padding: 6px 8px; border-bottom: 1px solid var(--ch-border); }
.phrase-table .he-cell {
  direction: rtl;
  font-size: var(--he-font-size);
  width: 50%;
  text-align: right;
  line-height: 1.8;
  vertical-align: middle;
}
.phrase-table .en-cell {
  font-size: var(--en-font-size);
  width: 50%;
  line-height: 1.8;
  vertical-align: middle;
}

/* ─── Word Hover Highlighting ─────────────────────────────────── */
.hw { cursor: pointer; transition: background 0.15s, color 0.15s; border-radius: 3px; padding: 0 1px; }
.hw:hover, .hw.active { background: var(--ch-gold-light); color: var(--ch-primary); }
.ew { cursor: pointer; transition: background 0.15s, color 0.15s; border-radius: 3px; padding: 0 1px; }
.ew.active { background: var(--ch-gold-light); color: var(--ch-primary); }

/* ─── Vocab Grid ──────────────────────────────────────────────── */
.vocab-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.vocab-card {
  background: var(--ch-card);
  border-radius: var(--ch-radius);
  box-shadow: var(--ch-shadow);
  padding: 14px;
  transition: transform var(--ch-transition);
}
.vocab-card:hover { transform: translateY(-2px); }
.vocab-card .term { font-weight: 700; color: var(--ch-primary); font-size: 1.05em; }
.vocab-card .hebrew { direction: rtl; font-size: var(--he-font-size); color: var(--ch-gold); margin: 4px 0; }
.vocab-card .definition { font-size: 0.9em; color: var(--ch-text-light); }

/* ─── Chapter / Gate Selector Grid ────────────────────────────── */
.chapter-grid, .gate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 16px 0;
}
.chapter-btn, .gate-btn {
  padding: 14px 10px;
  border: 2px solid var(--ch-border);
  border-radius: var(--ch-radius);
  background: var(--ch-card);
  cursor: pointer;
  text-align: center;
  transition: all var(--ch-transition);
  font-family: inherit;
}
.chapter-btn:hover, .gate-btn:hover { border-color: var(--ch-gold); background: var(--ch-gold-light); }
.chapter-btn.selected, .gate-btn.selected { border-color: var(--ch-gold); background: var(--ch-gold-light); font-weight: 700; }

/* ─── Mastery Bars ────────────────────────────────────────────── */
.mastery-bar { height: 8px; background: #eee; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.mastery-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.mastery-fill.low { background: #E74C3C; }
.mastery-fill.mid { background: #F39C12; }
.mastery-fill.high { background: #4CAF50; }

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

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

/* ─── Responsive ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  .cheder-header { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .cheder-header h1 { font-size: 1.1rem; }
  .chapter-grid, .gate-grid { grid-template-columns: repeat(3, 1fr); }
  .vocab-grid { grid-template-columns: 1fr; }
  .phrase-table .he-cell, .phrase-table .en-cell { display: block; width: 100%; }
  .phrase-table .he-cell { text-align: right; padding-bottom: 2px; }
  .phrase-table .en-cell { padding-bottom: 10px; border-bottom: 1px solid var(--ch-border); }
}

/* ─── Print ───────────────────────────────────────────────────── */
@media print {
  .cheder-header, .tab-bar, .profile-bar { display: none; }
  body { background: white; color: black; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ═══════════════════════════════════════════════════════════════
   CHEDER MODULE STANDARD — applies to all cheder modules.
   Loaded together with cheder-helpers.js for shared sound +
   encouragement + Hebrew font convention.
   ═══════════════════════════════════════════════════════════════ */

/* Hebrew auto-class — applied by Cheder.hebrew.applyTo() to any
   dynamically-rendered element whose text contains Hebrew chars.
   Ensures consistent Hebrew rendering across all match games,
   quizzes, ordering exercises, etc. */
.cheder-he {
  font-family: 'Frank Ruhl Libre', 'David Libre', serif;
  font-size: 1.25em;
  direction: rtl;
  text-align: right;
  letter-spacing: 0.01em;
}

/* Sound toggle — small icon button that mounts into any header */
.cheder-sound-toggle {
  background: transparent;
  border: 1px solid var(--ch-border, #d4c89a);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--ch-text, #1a1a1a);
  transition: background 0.15s, border-color 0.15s;
}
.cheder-sound-toggle:hover {
  background: var(--ch-gold-light, #f5e6b8);
  border-color: var(--ch-gold, #c89b3c);
}

/* Encouragement toast — slides up from the bottom, then fades */
.cheder-toast {
  position: fixed;
  left: 50%;
  bottom: 64px;
  transform: translate(-50%, 24px);
  background: #2c1810;
  color: #fffdf7;
  padding: 12px 22px;
  border-radius: 28px;
  font-family: 'David Libre', Georgia, serif;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  max-width: 80vw;
  text-align: center;
}
.cheder-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.cheder-toast.positive { background: linear-gradient(135deg, #2e7d32, #43a047); }
.cheder-toast.neutral  { background: linear-gradient(135deg, #5d4037, #6d4c41); }
.cheder-toast.warning  { background: linear-gradient(135deg, #ef6c00, #f57c00); }

/* Action button standard — primary/secondary/success/gold variants
   so every module uses the same button look-and-feel. The .tab-bar
   .tab-btn pattern (defined earlier in this file) remains the
   canonical tabs pattern; .cheder-btn is for actions (Start, Submit,
   Mark-as-Read, etc.). */
.cheder-btn {
  display: inline-block;
  padding: 9px 20px;
  border: 2px solid var(--ch-primary, #1a3a5c);
  border-radius: var(--ch-radius, 10px);
  background: var(--ch-primary, #1a3a5c);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  transition: all 0.15s;
  text-decoration: none;
}
.cheder-btn:hover {
  background: var(--ch-gold, #c89b3c);
  border-color: var(--ch-gold, #c89b3c);
}
.cheder-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.cheder-btn.secondary {
  background: transparent;
  color: var(--ch-primary, #1a3a5c);
}
.cheder-btn.secondary:hover {
  background: var(--ch-primary, #1a3a5c);
  color: #fff;
}
.cheder-btn.success {
  background: var(--ch-green, #2e7d32);
  border-color: var(--ch-green, #2e7d32);
}
.cheder-btn.gold {
  background: var(--ch-gold, #c89b3c);
  border-color: var(--ch-gold, #c89b3c);
}
