/* =========================================
   סיפורי סבא · עיצוב
   ערכת צבעים חמה: עץ, נר, קלף
========================================= */
:root {
  --bg: #faf5ec;
  --bg-2: #f3eadb;
  --surface: #ffffff;
  --ink: #1f1a16;
  --ink-2: #5b5047;
  --ink-3: #8a7d70;
  --line: #eadfcd;
  --brand: #0f1a33;          /* כחול כהה מהלוגו */
  --accent: #d8891c;         /* אור הנר */
  --accent-2: #b86e0a;
  --accent-soft: #fbecd2;
  --stories: #b4531f;
  --stories-soft: #fbe5d6;
  --parasha: #1d5f8a;
  --parasha-soft: #dcecf7;
  --ok: #1f8a5b;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 8px 24px rgba(60, 40, 20, .08);
  --shadow-lg: 0 2px 4px rgba(60, 40, 20, .08), 0 18px 40px rgba(60, 40, 20, .16);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Rubik", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --display: "Frank Ruhl Libre", "Rubik", serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15110d;
    --bg-2: #1c1712;
    --surface: #221b15;
    --ink: #f5ecdd;
    --ink-2: #cdbfac;
    --ink-3: #9a8b7a;
    --line: #3a2f25;
    --brand: #f5ecdd;
    --accent: #f0a63a;
    --accent-2: #f7bb5e;
    --accent-soft: #3a2a14;
    --stories: #f29a66;
    --stories-soft: #3b2418;
    --parasha: #7cc0ea;
    --parasha-soft: #16303f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.3);
    --shadow-lg: 0 2px 4px rgba(0,0,0,.4), 0 18px 40px rgba(0,0,0,.45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
img { max-width: 100%; display: block; }
a { color: inherit; }
[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: 1240px;
  margin-inline: auto;
  padding-inline: 16px;
}
@media (min-width: 768px) { .wrap { padding-inline: 28px; } }

/* ---------- כותרת עליונה ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 62px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-family: var(--display);
  font-weight: 900;
  font-size: 22px;
  color: var(--brand);
}
.brand img { width: 40px; height: 40px; border-radius: 50%; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--line); }
.back-link {
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  transition: background .2s;
}
.back-link:hover { background: var(--bg-2); color: var(--ink); }

.social { display: flex; gap: 8px; }
.social-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 19px;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.social-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.social-btn.whatsapp { background: #25d366; }
.social-btn.youtube { background: #ff0000; }
.social-btn.spotify { background: #1db954; }

/* ---------- HERO ---------- */
.hero {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  min-height: 420px;
  display: flex;
  align-items: flex-end;
  color: #fff7ea;
  background: #1c140e;
}
.hero-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 30%;
  z-index: -2;
}
.hero-shade {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to top, rgba(20, 12, 6, .92) 0%, rgba(20, 12, 6, .55) 45%, rgba(20, 12, 6, .05) 100%);
}
.hero-content { padding-block: 120px 32px; }
.hero h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 8vw, 76px);
  line-height: 1;
  margin: 0 0 12px;
  text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.hero-lead {
  font-size: clamp(16px, 2.2vw, 20px);
  max-width: 560px;
  margin: 0 0 18px;
  color: #f3e6d2;
}
.schedule { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.hero .chip {
  background: rgba(255, 247, 234, .14);
  border: 1px solid rgba(255, 247, 234, .28);
  color: #fff7ea;
  backdrop-filter: blur(6px);
  font-size: 14px;
  padding: 6px 12px;
}
.hero-cta { font-size: 17px; padding: 14px 22px; max-width: 100%; }
.hero-cta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* בטלפון: התמונה מלאה למעלה והטקסט מתחתיה, כדי שהלוגו שבתמונה לא יתנגש בכותרת */
@media (max-width: 899px) {
  .hero { display: block; min-height: 0; }
  .hero-bg { position: relative; inset: auto; height: auto; aspect-ratio: 1376 / 768; z-index: auto; }
  .hero-shade {
    inset: auto; top: 0; left: 0; right: 0;
    aspect-ratio: 1376 / 768;
    background: linear-gradient(to top, #1c140e 0%, rgba(28, 20, 14, 0) 35%);
    z-index: 0;
  }
  .hero-content { position: relative; padding-block: 4px 28px; }
  .hero h1 { font-size: 42px; }
}

@media (min-width: 900px) {
  .hero { min-height: 560px; }
  .hero-shade {
    background:
      linear-gradient(to left, rgba(20, 12, 6, .88) 0%, rgba(20, 12, 6, .55) 38%, rgba(20, 12, 6, 0) 70%),
      linear-gradient(to top, rgba(20, 12, 6, .6), transparent 40%);
  }
  .hero-content { padding-block: 80px 56px; }
}

/* ---------- רכיבים כלליים ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.chip-stories { background: var(--stories-soft); color: var(--stories); }
.chip-parasha { background: var(--parasha-soft); color: var(--parasha); }
.chip-shorts { background: #ffe9e6; color: #d93025; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, background .2s;
  background: var(--bg-2);
  color: var(--ink);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-spotify { background: #1db954; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.section-title {
  font-family: var(--display);
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 900;
  margin: 0;
  color: var(--ink);
  display: flex; align-items: center; gap: 10px;
}
.section-title i { color: var(--accent); font-size: .8em; }
.count { font-family: var(--font); font-size: 15px; font-weight: 500; color: var(--ink-3); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- הנצחה ---------- */
.memorial {
  margin: 24px 0 8px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent-soft), var(--bg-2));
  border: 1px solid var(--line);
}
.memorial-candle {
  font-size: 30px;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(240, 166, 58, .6));
  animation: flicker 3.5s ease-in-out infinite;
}
@keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: .82; } }
.memorial h2 { margin: 0 0 4px; font-size: 17px; font-family: var(--display); }
.memorial p { margin: 0; color: var(--ink-2); font-size: 14.5px; max-width: 980px; }

/* ---------- פרקים שבדרך ---------- */
.upcoming { margin-top: 32px; }
.upcoming-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.upcoming-item {
  display: flex; gap: 12px; align-items: center;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
}
.upcoming-item img { width: 96px; height: 60px; object-fit: cover; border-radius: 10px; filter: saturate(.7); flex-shrink: 0; }
.upcoming-item div { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.upcoming-item b { font-size: 15px; line-height: 1.3; }
.countdown { font-size: 13px; font-weight: 600; color: var(--accent-2); display: inline-flex; gap: 6px; align-items: center; }

/* ---------- סרגל כלים ---------- */
#episodesSection { margin-top: 36px; padding-bottom: 48px; }
.toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}
.toolbar-controls { display: flex; flex-direction: column; gap: 10px; }
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-2);
  border-radius: 22px;
  flex-wrap: wrap;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink-2);
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, color .2s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.search {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-3);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input {
  flex: 1; min-width: 0;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; color: var(--ink);
  padding: 11px 0;
}

@media (min-width: 900px) {
  .toolbar { flex-direction: row; align-items: center; justify-content: space-between; }
  .toolbar-controls { flex-direction: row; align-items: center; }
  .tabs button { flex: 0 0 auto; }
  .search { width: 260px; }
}

/* ---------- רשת כרטיסים ---------- */
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 22px; } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.ep-card { overflow: hidden; transition: transform .25s, box-shadow .25s; }
.ep-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.ep-link { display: flex; flex-direction: column; height: 100%; text-decoration: none; color: inherit; }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--bg-2); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s; }
.ep-card:hover .thumb img { transform: scale(1.05); }
.play {
  position: absolute; inset: 0; margin: auto;
  width: 56px; height: 56px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .92);
  color: var(--accent-2);
  font-size: 20px;
  padding-inline-end: 3px;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  opacity: 0; transform: scale(.85);
  transition: opacity .25s, transform .25s;
}
.ep-card:hover .play { opacity: 1; transform: scale(1); }
@media (hover: none) { .play { opacity: .9; transform: scale(.8); } }
.badges { position: absolute; top: 10px; inset-inline: 10px; display: flex; justify-content: space-between; gap: 6px; pointer-events: none; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 700;
  backdrop-filter: blur(6px);
}
.badge-new { background: var(--accent); color: #fff; }
.badge-viewed { background: rgba(20, 14, 8, .65); color: #fff; }
.badge-pdf { background: rgba(31, 138, 91, .92); color: #fff; margin-inline-start: auto; }
.ep-body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.ep-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.meta-date { font-size: 13px; color: var(--ink-3); }
.ep-title { margin: 2px 0 0; font-size: 17px; line-height: 1.35; font-weight: 700; }
.ep-desc {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; }

/* שלד טעינה */
.skeleton {
  min-height: 280px;
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--surface) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- כותרת תחתונה ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 14px;
  color: var(--ink-2);
}
.site-footer .wrap {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: center;
  padding-block: 20px calc(20px + env(safe-area-inset-bottom));
}
.site-footer a { text-decoration: none; font-weight: 600; color: var(--ok); }

.install-btn {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom));
  inset-inline: 16px;
  margin-inline: auto;
  max-width: 360px;
  padding: 14px;
  background: var(--brand);
  color: var(--bg);
  border: none;
  border-radius: 999px;
  font: inherit; font-weight: 700;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 60;
  display: flex; justify-content: center; align-items: center; gap: 8px;
}

/* =========================================
   דף פרק
========================================= */
.episode-layout {
  display: grid;
  gap: 28px;
  padding-block: 20px 48px;
}
@media (min-width: 1000px) {
  .episode-layout { grid-template-columns: minmax(0, 1fr) 340px; gap: 36px; padding-top: 28px; }
  .episode-side { position: sticky; top: 86px; align-self: start; max-height: calc(100vh - 100px); overflow-y: auto; }
}

.video-wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-lg);
  margin-inline: -16px;
  border-radius: 0;
}
@media (min-width: 600px) { .video-wrapper { margin-inline: 0; border-radius: var(--radius); } }
.video-wrapper.skeleton { min-height: 0; }
.video-wrapper iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.episode-meta { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.episode-title {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(26px, 4vw, 38px);
  line-height: 1.2;
  margin: 8px 0 16px;
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
@media (max-width: 480px) {
  .actions .btn { flex: 1 1 auto; }
  .actions .btn-primary { flex-basis: 100%; }
}

.episode-desc {
  margin-top: 24px;
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--ink-2);
  white-space: pre-line;
  max-width: 760px;
}
.episode-desc a { color: var(--accent-2); word-break: break-all; }

.pdf-section {
  margin-top: 24px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.pdf-text { display: flex; flex-direction: column; gap: 2px; }
.pdf-text strong { font-size: 17px; }
.pdf-text span { color: var(--ink-2); font-size: 14.5px; }
.pdf-download-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  transition: transform .15s, background .2s;
}
.pdf-download-btn:hover { background: var(--accent-2); transform: translateY(-1px); }
.pdf-download-btn i { font-size: 18px; }

.ep-nav {
  margin-top: 32px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.nav-card {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  text-decoration: none;
  transition: border-color .2s, transform .2s;
  min-width: 0;
}
.nav-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.nav-card small { color: var(--ink-3); font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.nav-card b { font-size: 14.5px; line-height: 1.35; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.nav-card.next { text-align: left; align-items: flex-end; }

.episode-side .section-title { font-size: 20px; margin-bottom: 12px; }
.more-list { display: flex; flex-direction: column; gap: 6px; }
.more-item {
  display: flex; gap: 12px; align-items: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background .2s;
}
.more-item:hover { background: var(--bg-2); }
.more-item img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; flex-shrink: 0; }
.more-item div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.more-item b { font-size: 14px; line-height: 1.35; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.more-item small { color: var(--ink-3); font-size: 12.5px; }

.notice { padding: 40px 24px; text-align: center; }
.notice h1 { font-family: var(--display); margin: 0 0 8px; }
.notice p { color: var(--ink-2); margin: 0 0 20px; }

.toast {
  position: fixed; bottom: 24px; inset-inline: 0; margin-inline: auto;
  width: max-content; max-width: 90vw;
  padding: 12px 20px;
  border-radius: 999px;
  background: var(--brand); color: var(--bg);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(20px);
  transition: opacity .25s, transform .25s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
