/* Reader page shared styles — for all module pages */

.reader-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 140px 40px 80px;
  display: grid;
  grid-template-columns: 220px 1fr 220px;
  gap: 56px;
}
@media (max-width: 1024px) {
  .reader-wrap { grid-template-columns: 1fr; padding: 120px 24px 60px; gap: 32px; }
  .reader-toc, .reader-aside { display: none; }
}

.reader-toc {
  position: sticky;
  top: 120px;
  align-self: start;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}
.toc-label {
  color: var(--muted-2);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--rule-col);
}
.toc-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.toc-list a { color: var(--muted); text-decoration: none; display: block; padding: 4px 0; transition: color 0.3s; line-height: 1.4; }
.toc-list a:hover, .toc-list a.active { color: var(--accent); }

.reader-aside {
  position: sticky;
  top: 120px;
  align-self: start;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
}
.aside-section { padding: 16px 0; border-bottom: 1px solid var(--rule-col); }
.aside-section:last-child { border-bottom: none; }
.aside-label { color: var(--muted-2); text-transform: uppercase; letter-spacing: 0.18em; font-size: 10px; margin-bottom: 6px; }
.aside-value { font-family: var(--f-body); font-size: 14px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }

.reader { max-width: var(--reader); width: 100%; min-width: 0; }
.reader pre.code,
.reader pre,
.reader .code {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.reader .module-jump-panel { max-width: 90vw; }
.reader-wrap { min-width: 0; }
.reader-head { margin-bottom: 48px; }

.reader-nav-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--f-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.reader-nav-bar a { color: var(--muted); text-decoration: none; }
.reader-nav-bar a:hover { color: var(--accent); }
.reader-nav-bar .sep { opacity: 0.5; }
.reader-track { color: var(--accent); font-weight: 600; }

.reader h1 {
  font-family: var(--f-display);
  font-size: clamp(2rem, 4.5vw, 3.6rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1;
  margin: 16px 0 24px;
}
.reader h1 em { font-family: var(--f-serif); font-style: italic; font-weight: 500; color: var(--accent); }
.reader-sub {
  font-family: var(--f-display);
  font-size: 19px;
  color: var(--muted);
  line-height: 1.55;
  font-weight: 400;
  letter-spacing: -0.01em;
  max-width: 620px;
}

.reader-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px 32px;
  padding: 16px 0;
  margin: 28px 0 40px;
  border-top: 1px solid var(--rule-col);
  border-bottom: 1px solid var(--rule-col);
}
.reader-meta > div { display: flex; flex-direction: column; gap: 2px; }
.reader-meta-label { font-family: var(--f-mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-2); }
.reader-meta-value { font-weight: 600; font-size: 14px; color: var(--ink); }

/* Prose */
.reader-prose { font-size: 17px; line-height: 1.8; color: var(--ink-2); }
.reader-prose h2 {
  font-family: var(--f-display);
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin: 56px 0 20px;
  color: var(--ink);
}
.reader-prose h2 em { font-family: var(--f-serif); font-style: italic; font-weight: 500; color: var(--accent); }
.reader-prose h2::before { content: '§ '; color: var(--accent); font-family: var(--f-serif); font-style: italic; font-weight: 500; opacity: 0.6; }
.reader-prose h3 {
  font-family: var(--f-display);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 40px 0 14px;
  color: var(--ink);
}
.reader-prose p { margin: 16px 0; }
.reader-prose p strong { color: var(--ink); font-weight: 700; }
.reader-prose p em { color: var(--accent); font-style: italic; }
.reader-prose ul, .reader-prose ol { margin: 16px 0; padding-right: 24px; }
.reader-prose li { margin: 8px 0; }
.reader-prose a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.reader-prose a:hover { color: var(--accent-2); }
.reader-prose hr { border: none; border-top: 1px solid var(--rule-col); margin: 48px 0; position: relative; }
.reader-prose hr::after { content: '✦'; position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--canvas); padding: 0 12px; color: var(--accent); font-size: 14px; }
.reader-prose code {
  font-family: var(--f-mono);
  background: var(--canvas-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
  color: var(--ink);
  unicode-bidi: isolate;
}
.reader-prose pre.code { margin: 24px 0; }

/* Complete button */
.mark-complete {
  margin-top: 56px;
  padding: 36px;
  border: 2px dashed var(--rule-col);
  border-radius: 20px;
  text-align: center;
  background: linear-gradient(135deg, rgba(201,64,46,0.02), rgba(184,145,77,0.02));
}
.mark-complete h3 { font-family: var(--f-display); font-size: 22px; font-weight: 900; letter-spacing: -0.035em; margin-bottom: 8px; }
.mark-complete p { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.mark-complete button {
  padding: 14px 28px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  background: var(--ink);
  color: var(--canvas);
  border: 1px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.3s, transform 0.3s var(--ease-out);
  letter-spacing: -0.01em;
}
.mark-complete button:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.mark-complete button.done { background: var(--accent); border-color: var(--accent); }

/* Pagination */
.reader-pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--rule-col);
}
@media (max-width: 600px) { .reader-pagination { grid-template-columns: 1fr; } }
.rpage {
  padding: 20px 24px;
  border: 1px solid var(--rule-col);
  border-radius: 14px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s, border-color 0.35s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rpage:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: transparent; }
.rpage-label { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
.rpage-title { font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -0.01em; }
.rpage.next { text-align: left; }
.rpage.prev { text-align: right; }
.rpage.disabled { opacity: 0.4; pointer-events: none; padding: 20px 24px; border: 1px solid var(--rule-col); border-radius: 14px; text-align: center; color: var(--muted); }

/* Deliverable — משימת-מסירה (gating hook for T30) */
.deliverable {
  margin: 56px 0 0;            /* בלי שוליים-תחתונים: mark-complete מביא 56px משלו → רווח אחיד */
  padding: 28px 32px;
  border: 1px solid var(--rule-col);
  border-right: 4px solid var(--accent);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(201,64,46,0.03), rgba(184,145,77,0.03));
}
.deliverable-tag {
  font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.deliverable h2 { margin-top: 0 !important; }
.deliverable h2::before { content: none !important; } /* בלי ה-'§' של reader-prose h2 */
.deliverable-build, .deliverable-submit { margin: 16px 0; }
.deliverable h4 {
  font-family: var(--f-display); font-size: 16px; font-weight: 800;
  letter-spacing: -0.02em; margin: 0 0 6px; color: var(--ink);
}
.deliverable-gate-note {
  margin-top: 16px; font-size: 14px; color: var(--muted);
  border-top: 1px solid var(--rule-col); padding-top: 14px;
}

/* R30 — mobile-first reader polish, RTL/code hardening, sticky module nav */
.reader-prose,
.reader-sub,
.deliverable,
.mark-complete {
  overflow-wrap: anywhere;
}

.reader-prose p,
.reader-prose li {
  max-width: 72ch;
}

.reader-prose pre.code,
.reader-prose pre,
.reader .code {
  direction: ltr;
  text-align: left;
  unicode-bidi: isolate;
  scrollbar-width: thin;
  scrollbar-color: rgba(247,243,236,0.34) transparent;
}

.reader-prose pre.code code,
.reader-prose pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  direction: inherit;
  unicode-bidi: inherit;
}

.reader-prose table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  -webkit-overflow-scrolling: touch;
}

.reader-pagination {
  background: linear-gradient(180deg, rgba(247,243,236,0), var(--canvas) 18%);
}

.rpage:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .reader-wrap {
    padding: 112px 18px 48px;
  }

  .reader-head {
    margin-bottom: 36px;
  }

  .reader h1 {
    font-size: clamp(2rem, 12vw, 3rem);
    line-height: 1.04;
  }

  .reader-sub,
  .reader-prose {
    font-size: 16px;
    line-height: 1.78;
  }

  .reader-prose h2 {
    margin-top: 44px;
    font-size: clamp(1.45rem, 8vw, 1.85rem);
  }

  .reader-prose h3 {
    font-size: 19px;
  }

  .reader-prose ul,
  .reader-prose ol {
    padding-right: 20px;
  }

  .reader-prose pre.code,
  .reader-prose pre,
  .reader .code {
    margin-inline: -6px;
    padding: 16px 18px;
    font-size: 12.5px;
    line-height: 1.7;
  }

  .reader-pagination {
    position: sticky;
    bottom: 0;
    z-index: 20;
    margin-inline: -18px;
    padding: 18px;
    border-top: 1px solid var(--rule-col);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }

  .rpage {
    min-height: 76px;
    padding: 16px 18px;
    background: rgba(255,255,255,0.92);
  }

  .deliverable {
    padding: 24px 20px;
    border-radius: 14px;
  }

  .mark-complete {
    padding: 28px 20px;
    border-radius: 16px;
  }
}
