/*
 * libro-shared.css — Origin Planner
 * Estilos compartidos para todos los resúmenes de libros.
 * Incluir con: <link rel="stylesheet" href="libro-shared.css">
 *
 * SECCIONES:
 * 0. BASE LAYOUT (article-wrap, chapters, hero, CTAs…)
 * 1. ✅ Barra de progreso de lectura
 * 2. ✅ Tabla de contenidos sticky
 * 3. ✅ Key-phrases mejoradas
 * 4. ✅ Indicador de tiempo de lectura
 * 5. ✅ Separadores entre capítulos
 */

/* ═══════════════════════════════════════════
   0. BASE LAYOUT
   Base compartida para todos los libros.
   Los libros con inline CSS propio lo sobreescriben.
   ═══════════════════════════════════════════ */

:root {
  --lila: #7358c3;
  --lila-light: #f0ecfb;
  --lila-dark: #4a3a8a;
  --verde: #4fbf9a;
  --coral: #ff648f;
  --amarillo: #f9c308;
  --negro: #1a1a2e;
  --gris-texto: #3a3a4a;
  --gris-suave: #f5f5f8;
  --borde: #ececec;
}

/* ── HERO ── */
.post-hero {
  position: relative;
  overflow: hidden;
  padding: 80px 24px 64px;
  text-align: left;
}
.hero-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}
.hero-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hero-content {
  position: relative;
  max-width: 780px;
  margin: 0 auto;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.8);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 50px;
  margin-bottom: 18px;
}
.post-hero h1 {
  font-family: 'Playfair Display', serif;
  font-size: clamp(28px, 5vw, 52px);
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 10px;
  text-wrap: pretty;
}
.hero-author {
  font-size: 15px;
  color: rgba(255,255,255,.6);
  font-style: italic;
  margin-bottom: 18px;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255,255,255,.5);
  flex-wrap: wrap;
}
.hero-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
  display: inline-block;
}
.hero-meta a {
  color: rgba(255,255,255,.65);
  text-decoration: none;
  transition: color .2s;
}
.hero-meta a:hover { color: #fff; }

/* ── ARTICLE WRAP ── */
.article-wrap {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 64px;
}

/* ── LEGAL NOTE ── */
.legal-note {
  background: #fffbec;
  border-left: 3px solid var(--amarillo);
  padding: 14px 18px;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: #6a6a5a;
  margin-bottom: 40px;
  line-height: 1.7;
}
.legal-note strong { color: #5a5a3a; }

/* ── ARTICLE BODY ── */
.article-body p {
  font-size: 17px;
  line-height: 1.85;
  color: var(--gris-texto);
  margin-bottom: 20px;
  text-wrap: pretty;
}
.article-body h2 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--negro);
  margin: 48px 0 16px;
  line-height: 1.3;
}

/* ── CHAPTERS ── */
.chapters { display: flex; flex-direction: column; gap: 32px; margin: 40px 0; }
.chapter-card {
  border: 1px solid #ececec;
  border-radius: 16px;
  padding: 28px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s, transform .5s;
}
.chapter-card.visible { opacity: 1; transform: translateY(0); }
.chapter-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.chapter-num {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--lila);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chapter-card h3 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 20px;
  color: var(--negro);
  line-height: 1.3;
}
.chapter-card p {
  font-size: 16px;
  line-height: 1.8;
  color: var(--gris-texto);
  margin-bottom: 14px;
  text-wrap: pretty;
}
.chapter-card p:last-of-type { margin-bottom: 0; }

/* ── KEY PHRASE (base) ── */
.key-phrase {
  background: var(--lila-light);
  border-left: 3px solid var(--lila);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
  font-style: italic;
  font-weight: 600;
  font-size: 15px;
  color: var(--lila-dark);
  margin-top: 18px;
}

/* ── DIAGRAMS ── */
.diagram-wrap {
  background: #f5f5f8;
  border-radius: 16px;
  padding: 32px 24px;
  margin: 32px 0;
  text-align: center;
}
.diagram-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--lila);
  margin-bottom: 4px;
}
.diagram-caption {
  font-size: 13px;
  color: #888;
  margin-top: 12px;
  line-height: 1.5;
}
.diagram-wrap svg { max-width: 100%; height: auto; }

/* ── TIP BOX ── */
.tip-box {
  background: var(--lila-light);
  border-left: 4px solid var(--lila);
  border-radius: 0 16px 16px 0;
  padding: 20px 22px;
  margin: 32px 0;
  font-size: 15px;
  line-height: 1.75;
  color: var(--gris-texto);
}
.tip-box strong { color: var(--lila-dark); }
.tip-box a { color: var(--lila); font-weight: 600; text-decoration: underline; }

/* ── PRODUCT CTA ── */
.product-cta {
  background: linear-gradient(135deg, #4a3a8a, #7358c3);
  border-radius: 20px;
  padding: 40px 32px;
  text-align: center;
  margin: 48px 0;
}
.product-cta h2 {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 24px;
  color: #fff;
  margin-bottom: 12px;
}
.product-cta p {
  color: rgba(255,255,255,.75);
  font-size: 16px;
  margin-bottom: 24px;
  line-height: 1.6;
}
.btn-amarillo {
  display: inline-block;
  background: var(--amarillo);
  color: var(--negro);
  font-weight: 700;
  font-size: 15px;
  padding: 13px 28px;
  border-radius: 50px;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
}
.btn-amarillo:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(249,195,8,.4);
  text-decoration: none;
}

/* ── NEWSLETTER STRIP ── */
.nl-strip {
  background: var(--negro);
  border-radius: 20px;
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 48px 0;
  flex-wrap: wrap;
}
.nl-strip-text { flex: 1; min-width: 180px; }
.nl-strip-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--amarillo);
  margin-bottom: 6px;
}
.nl-strip-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  font-size: 20px;
  color: #fff;
}

/* ── RELATED SECTION ── */
.related-section {
  background: var(--gris-suave);
  padding: 64px 24px;
  margin-top: 0;
}
.related-inner {
  max-width: 780px;
  margin: 0 auto;
}
.related-section h2 {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--negro);
  margin-bottom: 32px;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}
.related-card {
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  transition: transform .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 12px rgba(0,0,0,.06);
}
.related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 28px rgba(115,88,195,.15);
  text-decoration: none;
}
.related-cover {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}
.related-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.related-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--lila);
}
.related-body h3 {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--negro);
  line-height: 1.3;
}
.related-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--lila);
  margin-top: auto;
}

/* ── INTERSECTION OBSERVER for chapter-card ── */
/* JS in libro-shared is injected via nav.js / inline — chapters default to hidden,
   made visible by IntersectionObserver adding .visible class */

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .post-hero { padding: 56px 20px 40px; }
  .article-wrap { padding: 32px 16px 48px; }
  .product-cta { padding: 32px 20px; }
  .nl-strip { flex-direction: column; align-items: flex-start; }
  .chapter-card { padding: 20px; }
  .related-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   1. BARRA DE PROGRESO DE LECTURA
   ═══════════════════════════════════════════ */
#leer-progreso {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 3px;
  background: linear-gradient(90deg, #7358c3, #4fbf9a);
  z-index: 9999;
  transition: width 0.1s linear;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
}

/* ═══════════════════════════════════════════
   2. TABLA DE CONTENIDOS STICKY
   ═══════════════════════════════════════════ */
#libro-toc {
  position: fixed;
  top: 50%;
  right: 28px;
  transform: translateY(-50%) translateX(12px);
  width: 210px;
  background: #fff;
  border: 1px solid #ececec;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 4px 24px rgba(115,88,195,.10);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}
#libro-toc.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}
#libro-toc-title {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #7358c3;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ececec;
}
#libro-toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#libro-toc ul li a {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  text-decoration: none;
  transition: background .15s, color .15s;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #6b6b7b;
  line-height: 1.35;
}
#libro-toc ul li a:hover {
  background: #f0ecfb;
  color: #4a3a8a;
  text-decoration: none;
}
#libro-toc ul li.active a {
  background: #f0ecfb;
  color: #4a3a8a;
  font-weight: 700;
}
#libro-toc ul li.active a .toc-num {
  background: #7358c3;
  color: #fff;
}
.toc-num {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 50%;
  background: #f0ecfb;
  color: #7358c3;
  font-size: 10px;
  font-weight: 700;
  transition: background .15s, color .15s;
  margin-top: 1px;
}
/* Solo visible en pantallas anchas */
@media (max-width: 1280px) {
  #libro-toc { display: none !important; }
}

/* ═══════════════════════════════════════════
   3. KEY-PHRASES MÁS VISUALES
   Sobreescribe el estilo base de cada libro.
   ═══════════════════════════════════════════ */
.key-phrase {
  position: relative;
  background: linear-gradient(135deg, #f0ecfb, #e8f8f4) !important;
  border-left: 4px solid #7358c3 !important;
  border-radius: 0 16px 16px 0 !important;
  padding: 20px 24px 20px 28px !important;
  font-size: 17px !important;
  line-height: 1.65 !important;
  margin-top: 24px !important;
  overflow: hidden;
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity .5s ease, transform .5s ease;
}
.key-phrase.kp-visible {
  opacity: 1;
  transform: translateX(0);
}
.key-phrase::before {
  content: '\201C';
  position: absolute;
  top: -10px;
  left: 10px;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 80px;
  font-style: normal;
  font-weight: 900;
  color: #7358c3;
  opacity: .12;
  line-height: 1;
  pointer-events: none;
  user-select: none;
}
.key-phrase::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40px;
  height: 40px;
  background: radial-gradient(circle at bottom right, rgba(115,88,195,.08), transparent 70%);
  border-radius: 0 0 16px 0;
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   4. INDICADOR DE TIEMPO DE LECTURA
   ═══════════════════════════════════════════ */
.hero-tiempo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: default;
}
.hero-tiempo-tooltip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,26,46,.95);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 11px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
  z-index: 200;
}
.hero-tiempo-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(26,26,46,.95);
}
.hero-tiempo-wrap:hover .hero-tiempo-tooltip {
  opacity: 1;
}

/* ═══════════════════════════════════════════
   5. SEPARADORES ENTRE CAPÍTULOS
   Se inyectan automáticamente entre .chapter-card
   ═══════════════════════════════════════════ */
.chapter-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  opacity: 0;
  transition: opacity .7s ease;
}
.chapter-sep.sep-visible {
  opacity: 1;
}
.chapter-sep-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #e0d8f5 30%, #e0d8f5 70%, transparent);
}
.chapter-sep-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7358c3;
  opacity: .3;
  flex-shrink: 0;
}


/* ═══════════════════════════════════════════
   6. BOTÓN FLOTANTE "← Todos los resúmenes"
   ═══════════════════════════════════════════ */
#libro-back-btn {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 500;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #1a1a2e;
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease, background .2s, box-shadow .2s;
  white-space: nowrap;
}
#libro-back-btn span {
  font-size: 16px;
  line-height: 1;
  transition: transform .2s;
}
#libro-back-btn:hover {
  background: #7358c3;
  box-shadow: 0 8px 28px rgba(115,88,195,.4);
  text-decoration: none;
}
#libro-back-btn:hover span {
  transform: translateX(-3px);
}
#libro-back-btn.libro-back-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 600px) {
  #libro-back-btn {
    font-size: 13px;
    padding: 10px 18px;
    bottom: 16px;
  }
}
