/* ============================================================
   Components — רכיבים ויזואליים משותפים לכל המצגות
   ============================================================ */

/* --- Lesson title banner (top of page) --- */
.lesson-title-banner {
  background: var(--bg-banner);
  border: 2px solid var(--border-banner);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 0 0 32px 0;
}

.lesson-title-banner h1 {
  margin: 0 0 12px 0;
  font-size: 40px;
  font-weight: 700;
  color: var(--text-title);
}

.lesson-title-banner .subtitle {
  font-size: 22px;
  color: var(--text-body);
  font-weight: 500;
}

.lesson-title-banner .pill {
  display: inline-block;
  margin-top: 14px;
  padding: 6px 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-body);
  background: var(--bg-banner-alt);
  border: 1px solid var(--border-light);
  border-radius: 999px;
}

/* --- Section banner (per block in מערך הצגה) --- */
.section-banner {
  background: var(--bg-banner);
  border-right: 4px solid var(--border-banner);
  border-radius: 8px;
  padding: 14px 20px;
  margin: 28px 0 16px 0;
}

.section-banner h2 {
  margin: 0;
  font-size: 28px;
  color: var(--text-title);
}

/* --- Callout (key takeaway / 3 assumptions / warning) --- */
.callout {
  background: var(--bg-banner);
  border: 2px solid var(--border-banner);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 20px 0;
}

.callout--accent {
  background: var(--accent-bg);
  border-color: var(--accent);
}

.callout h3 {
  margin: 0 0 10px 0;
  font-size: 22px;
  color: var(--text-title);
}

.callout--accent h3 {
  color: var(--accent-text);
}

/* --- Question box (with optional reveal) --- */
.qa {
  background: var(--bg-soft);
  border: 1px dashed var(--border-soft);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 16px 0;
}

.qa .question {
  font-weight: 600;
  color: var(--text-default);
}

.qa .answer {
  display: none;
  margin-top: 10px;
  padding: 12px;
  background: var(--revealed-bg);
  border: 1px solid var(--revealed-border);
  border-radius: 6px;
}

.qa.revealed .answer {
  display: block;
}

.qa .toggle-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 12px;
  font-size: 14px;
  background: var(--bg-banner);
  border: 1px solid var(--border-banner);
  border-radius: 999px;
  color: var(--text-body);
  cursor: pointer;
}

/* --- Code-switch marker (Jupyter handoff) --- */
.code-switch {
  background: var(--code-switch-bg);
  border: 2px dashed var(--code-switch-border);
  border-radius: 10px;
  padding: 14px 18px;
  margin: 24px 0;
  font-size: 18px;
  color: var(--code-switch-text);
  display: flex;
  gap: 12px;
  align-items: center;
}

.code-switch {
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.code-switch:hover {
  background: #ffe9b0;
  border-color: var(--code-switch-text);
  transform: translateY(-1px);
}

.code-switch .icon {
  font-size: 28px;
}

.code-switch .cell-ref {
  font-family: 'Consolas', 'Monaco', monospace;
  background: rgba(255, 160, 0, 0.15);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

/* --- Formula box --- */
.formula-box {
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0;
  text-align: center;
  font-size: 22px;
}

/* --- Table of contents (TOC) --- */
.toc {
  background: var(--bg-soft);
  border-right: 3px solid var(--border-banner);
  padding: 16px 24px;
  margin: 24px 0;
  border-radius: 6px;
}

.toc h2 {
  margin: 0 0 12px 0;
  font-size: 20px;
  color: var(--text-title);
}

.toc ol {
  margin: 0;
  padding-right: 24px;
}

.toc li {
  margin: 6px 0;
}

.toc a {
  color: var(--text-body);
  text-decoration: none;
}

.toc a:hover {
  text-decoration: underline;
}

/* ============================================================
   Floating-control conventions (auto-injected from interactivity.js)
   Bottom-left vertical stack of 44px circular buttons.
   ============================================================ */

.float-btn {
  position: fixed;
  left: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-banner);
  border: 1.5px solid var(--border-banner);
  color: var(--text-title);
  cursor: pointer;
  transition: opacity 0.25s ease, visibility 0.25s ease,
              transform 0.18s ease, background 0.18s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  box-shadow: 0 2px 8px rgba(0, 77, 112, 0.18);
  padding: 0;
  opacity: 0.88;
}
.float-btn:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 77, 112, 0.25);
}
.float-btn.active {
  background: var(--border-banner);
  color: white;
  opacity: 1;
}
.float-btn svg {
  width: 20px;
  height: 20px;
}

/* Stack positions, bottom up: top → mode → cursor → toc */
.back-to-top    { bottom: 28px; }
.float-cursor   { bottom: 84px; }
.float-mode     { bottom: 140px; }
.float-toc-btn  { bottom: 196px; }

/* --- TOC floating panel (auto-injected) --- */
.float-toc-panel {
  position: fixed;
  bottom: 196px;
  left: 84px;
  background: white;
  border: 1.5px solid var(--border-banner);
  border-radius: 10px;
  padding: 14px 18px;
  min-width: 280px;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 6px 20px rgba(0, 77, 112, 0.2);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-8px);
  transition: opacity 0.18s ease, visibility 0.18s ease, transform 0.18s ease;
}
.float-toc-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateX(0);
}
.float-toc-panel h4 {
  margin: 0 0 10px 0;
  font-size: 16px;
  color: var(--text-title);
  border-bottom: 1px solid var(--divider);
  padding-bottom: 6px;
}
.float-toc-panel ol {
  margin: 0;
  padding-right: 22px;
  list-style-position: outside;
}
.float-toc-panel li {
  margin: 5px 0;
  font-size: 15px;
}
.float-toc-panel a {
  color: var(--text-body);
  text-decoration: none;
}
.float-toc-panel a:hover {
  text-decoration: underline;
}
.float-toc-panel li.active {
  font-weight: 700;
}
.float-toc-panel li.active a {
  color: var(--border-banner);
}
.float-toc-panel li.active::marker {
  color: var(--border-banner);
}

/* --- Cursor halo (toggle via .float-cursor button) --- */
.cursor-halo {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle,
    rgba(0, 119, 182, 0.30) 0%,
    rgba(0, 119, 182, 0.12) 45%,
    transparent 70%);
  pointer-events: none;
  z-index: 9998;
  transform: translate(-50%, -50%);
  display: none;
}
body.cursor-halo-on .cursor-halo {
  display: block;
}
body.cursor-halo-on, body.cursor-halo-on * {
  cursor: none !important;
}
body.cursor-halo-on a, body.cursor-halo-on button,
body.cursor-halo-on .qa, body.cursor-halo-on .code-switch,
body.cursor-halo-on .float-btn, body.cursor-halo-on .toc a {
  cursor: pointer !important;
}

/* --- Slides mode (toggle via .float-mode button) --- */
body[data-mode="slides"] {
  overflow: hidden;
}
body[data-mode="slides"] header.lesson-nav,
body[data-mode="slides"] .lesson-footer,
body[data-mode="slides"] .scroll-progress,
body[data-mode="slides"] .back-to-top,
body[data-mode="slides"] main > :not(section) {
  display: none;
}
body[data-mode="slides"] main {
  max-width: 100%;
  padding: 0;
  margin: 0;
}
body[data-mode="slides"] main > section {
  position: fixed;
  inset: 0;
  display: none;
  padding: 56px 72px 80px 72px;
  overflow-y: auto;
  background: var(--bg-page);
  margin: 0;
  scroll-margin: 0;
  animation: none;
}
body[data-mode="slides"] main > section.slide-active {
  display: block;
}
body[data-mode="slides"] main > section.slide-active > * {
  animation: slide-fade-in 0.35s ease;
}
@keyframes slide-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Slide indicator (dots at bottom) */
.slide-indicator {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: none;
  gap: 8px;
  z-index: 1001;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: 0 2px 8px rgba(0, 77, 112, 0.15);
  backdrop-filter: blur(4px);
}
body[data-mode="slides"] .slide-indicator {
  display: flex;
  align-items: center;
}
.slide-indicator .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border-light);
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
  border: none;
  padding: 0;
}
.slide-indicator .dot:hover {
  transform: scale(1.2);
}
.slide-indicator .dot.active {
  background: var(--border-banner);
  transform: scale(1.3);
}
.slide-indicator .counter {
  margin: 0 10px;
  font-size: 13px;
  color: var(--text-body);
  font-weight: 600;
  min-width: 38px;
  text-align: center;
}

/* --- Slides side-nav arrows (auto-injected, visible only in slides mode) --- */
/* RTL convention: prev=right, next=left (matches lesson-nav header).        */
.slide-side-nav {
  position: fixed;
  top: 50%;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid var(--border-banner);
  color: var(--text-title);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  box-shadow: 0 4px 16px rgba(0, 77, 112, 0.18);
  backdrop-filter: blur(4px);
  transition: opacity 0.18s ease, transform 0.18s ease,
              background 0.18s ease, box-shadow 0.18s ease;
  padding: 0;
  opacity: 0.78;
  transform: translateY(-50%);
}

.slide-side-nav.prev { right: 28px; }
.slide-side-nav.next { left: 28px; }

.slide-side-nav:hover {
  opacity: 1;
  background: white;
  box-shadow: 0 6px 20px rgba(0, 77, 112, 0.28);
}
.slide-side-nav.prev:hover { transform: translateY(-50%) translateX(4px); }
.slide-side-nav.next:hover { transform: translateY(-50%) translateX(-4px); }

.slide-side-nav:disabled {
  opacity: 0.22;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0, 77, 112, 0.10);
}

.slide-side-nav svg {
  width: 26px;
  height: 26px;
}

body[data-mode="slides"] .slide-side-nav {
  display: flex;
}

/* --- Top scroll-progress bar (auto-injected by interactivity.js) --- */
.scroll-progress {
  position: fixed;
  top: 0;
  right: 0;
  height: 3px;
  width: 0;
  background: var(--border-banner);
  z-index: 1000;
  transition: width 0.05s linear;
  pointer-events: none;
}

/* --- Back-to-top: visibility tied to scroll position (auto-injected) --- */
.back-to-top {
  opacity: 0;
  visibility: hidden;
}
.back-to-top.visible {
  opacity: 0.88;
  visibility: visible;
}

/* --- Prev / next reminder block --- */
.prev-reminder {
  background: var(--bg-soft);
  border-right: 3px solid var(--border-light);
  padding: 12px 18px;
  margin: 16px 0;
  font-size: 16px;
  color: var(--text-muted);
}

.prev-reminder strong {
  color: var(--text-title);
}

/* ============================================================
   Responsive — tablet (≤768px) and phone (≤480px)
   ============================================================ */

@media (max-width: 768px) {
  /* Lesson title banner */
  .lesson-title-banner       { padding: 18px 20px; margin-bottom: 22px; }
  .lesson-title-banner h1    { font-size: 26px; margin-bottom: 8px; }
  .lesson-title-banner .subtitle { font-size: 16px; }
  .lesson-title-banner .pill { font-size: 13px; padding: 4px 10px; margin-top: 10px; }

  /* Section banners (per פרק) */
  .section-banner            { padding: 10px 14px; margin: 22px 0 12px 0; }
  .section-banner h2         { font-size: 20px; }

  /* Callouts */
  .callout                   { padding: 12px 14px; margin: 16px 0; }
  .callout h3                { font-size: 17px; margin-bottom: 8px; }
  .callout h4                { font-size: 15px; }

  /* Formula-box: allow horizontal scroll for long expressions */
  .formula-box {
    font-size: 16px;
    padding: 12px 14px;
    margin: 12px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Q&A blocks */
  .qa                        { padding: 10px 14px; margin: 14px 0; }
  .qa .question              { font-size: 15px; }
  .qa .toggle-btn            { font-size: 13px; padding: 4px 10px; }

  /* Code-switch (Jupyter handoff): allow wrap */
  .code-switch {
    padding: 10px 14px;
    font-size: 14px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .code-switch .icon         { font-size: 22px; }

  /* TOC */
  .toc                       { padding: 12px 16px; margin: 18px 0; }
  .toc h2                    { font-size: 16px; }
  .toc li                    { font-size: 14px; }

  /* Tables — allow horizontal scroll on overflow */
  main table, .callout table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 13px;
  }

  /* Floating buttons — smaller, closer to edge */
  .float-btn                 { width: 38px; height: 38px; left: 14px; }
  .float-btn svg             { width: 17px; height: 17px; }
  .back-to-top               { bottom: 14px; }
  .float-cursor              { bottom: 60px; }
  .float-mode                { bottom: 106px; }
  .float-toc-btn             { bottom: 152px; }

  .float-toc-panel {
    bottom: 152px;
    left: 60px;
    min-width: 220px;
    max-width: calc(100vw - 80px);
    max-height: 60vh;
  }
  .float-toc-panel li        { font-size: 14px; }

  /* Slides mode — tighter padding so content actually fits */
  body[data-mode="slides"] main > section {
    padding: 32px 18px 64px 18px;
  }

  /* Slide indicator dots — smaller */
  .slide-indicator           { padding: 6px 12px; }
  .slide-indicator .dot      { width: 8px; height: 8px; }
  .slide-indicator .counter  { font-size: 12px; min-width: 32px; margin: 0 8px; }

  /* Side-nav arrows */
  .slide-side-nav            { width: 44px; height: 44px; }
  .slide-side-nav.prev       { right: 12px; }
  .slide-side-nav.next       { left: 12px; }
  .slide-side-nav svg        { width: 20px; height: 20px; }
}

@media (max-width: 480px) {
  .lesson-title-banner h1    { font-size: 22px; }
  .lesson-title-banner .subtitle { font-size: 14px; }
  .lesson-title-banner .pill { font-size: 12px; }

  .section-banner h2         { font-size: 18px; }

  .formula-box               { font-size: 14px; padding: 10px 12px; }

  /* Hide cursor halo button on mobile (no mouse) — re-stack remaining */
  .float-cursor              { display: none; }
  .back-to-top               { bottom: 14px; }
  .float-mode                { bottom: 60px; }
  .float-toc-btn             { bottom: 106px; }
  .float-toc-panel           { bottom: 106px; }

  /* Side-nav arrows even smaller on tiny screens */
  .slide-side-nav            { width: 38px; height: 38px; }
  .slide-side-nav svg        { width: 17px; height: 17px; }
}
