/* ══════════════════════════════════════════════════════════
   RECURSO — Layout responsivo
   ══════════════════════════════════════════════════════════ */
:root {
  --sp-w: 320px;
  --radius: 14px;
  --blue: #611232;
  --blue-dark: #310214;
  --border: #e3e6ef;
}

/* ── Layout ─────────────────────────────────────────────── */
.rec-layout {
  display: flex; align-items: flex-start;
  gap: 1.5rem; padding: 1rem 1.5rem 2rem;
}
.rec-main  { flex: 1; min-width: 0; }
.rec-aside {
  width: var(--sp-w); flex-shrink: 0;
  position: sticky; top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto; border-radius: var(--radius);
  background: #1a1a2e;
  scrollbar-width: thin; scrollbar-color: #333 #111;
}
.rec-aside::-webkit-scrollbar       { width: 4px; }
.rec-aside::-webkit-scrollbar-track { background: #111; }
.rec-aside::-webkit-scrollbar-thumb { background: #333; border-radius: 4px; }

/* ── Header del recurso ─────────────────────────────────── */
.rec-header {
  background: linear-gradient(135deg, #0d1f40 0%, #1a4280 100%);
  border-radius: var(--radius); padding: 1.75rem 2rem;
  color: #fff; margin-bottom: 1.25rem; position: relative; overflow: hidden;
  background-size: cover;
  background-position: center;
}
/* Overlay oscuro sobre la portada */
.rec-header::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(
    135deg,
    rgba(13, 31, 64, 0.90) 0%,
    rgba(26, 66, 128, 0.82) 100%
  );
  border-radius: var(--radius);
  z-index: 0;
}
.rec-header::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04'%3E%3Cpath d='M20 20.5V18H0v5h5v5H0v5h20v-9.5zm-2 4.5H8v-4h10v4zm12-8H18v1H8V18h5v-2H8V8h14v4h-4v2h4v3zM38 8H28v-2h-2V4h-2V2h-2V0h-2v2h2v2h2v2h2v2h2v2h-4v2h2v2h-2v2h2v2h-2v4h2v-2h2v-2h2v-2h2V8z'/%3E%3C/g%3E%3C/svg%3E");
  z-index: 0;
}
/* Todo el contenido por encima de los overlays */
.rec-header >* { position: relative; z-index: 1; }
.rec-header__tipo {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.6); margin-bottom: .4rem;
}
.rec-header__title {
  font-size: clamp(1.3rem, 2.8vw, 2rem);
  font-weight: 800; line-height: 1.2;
  margin: 0 0 1rem; text-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.rec-header__meta {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem;
}
.rec-meta-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
  border-radius: 20px; padding: .22rem .65rem;
  font-size: .76rem; color: rgba(255,255,255,.88);
}
.rec-header__tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .75rem; }
.rec-header__tags .badge {
  font-size: .68rem; padding: .25rem .6rem; border-radius: 20px;
  background: rgba(255,183,27,.2); color: #ffb91b;
  border: 1px solid rgba(255,183,27,.3); text-decoration: none;
}
.rec-header__actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

/* ── Visor del contenido ────────────────────────────────── */
.rec-viewer {
  background: #000; border-radius: var(--radius);
  overflow: hidden; margin-bottom: 1.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
}
.rec-viewer iframe { display: block; width: 100%; border: none; aspect-ratio: 16/9; }
.rec-viewer video  { display: block; width: 100%; }
.rec-viewer audio  { display: block; width: 100%; padding: 1.5rem; background: #111; }
.rec-viewer img    { display: block; width: 100%; max-height: 80vh; object-fit: contain; }
.rec-viewer object,
.rec-viewer embed  { display: block; width: 100%; height: 90vh; }

/* Download fallback */
.rec-download {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem; text-align: center;
  margin-bottom: 1.25rem;
}
.rec-download p { color: #666; font-size: .9rem; margin-bottom: 1rem; }
.rec-download .btn { min-width: 160px; }

/* ── Card de contenido de texto ─────────────────────────── */
.rec-body-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Panel lateral ──────────────────────────────────────── */
.aside-info { padding: 1rem; }
.aside-info h4 {
  font-size: .95rem; font-weight: 700; color: #fff;
  margin-bottom: .5rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
}
.aside-info .badge {
  font-size: .68rem; margin: .15rem;
  background-color: #ffb91b; color: #000;
  text-decoration: none; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis;
}
.aside-info p { font-size: .82rem; color: rgba(255,255,255,.65); margin: .5rem 0; }
.aside-divider {
  border: none; border-top: 1px solid rgba(255,255,255,.1);
  margin: .75rem 0;
}
.aside-info-row {
  display: flex; gap: .5rem; font-size: .8rem;
  color: rgba(255,255,255,.7); margin-bottom: .35rem;
  align-items: baseline;
}
.aside-info-row b { color: rgba(255,255,255,.9); white-space: nowrap; }

/* Metadatos tabla */
.aside-meta-table { width: 100%; border-collapse: collapse; }
.aside-meta-table td { font-size: .78rem; padding: .2rem .1rem; color: rgba(255,255,255,.75); vertical-align: top; }
.aside-meta-table td:first-child { font-weight: 600; color: rgba(255,255,255,.9); white-space: nowrap; padding-right: .5rem; }

.aside-section-title {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; color: rgba(255,255,255,.35);
  margin: 1rem 0 .4rem; padding: 0 .1rem;
}

/* Lista de colecciones */
.colecciones-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: .4rem;
}
.colecciones-list li {
  display: flex; align-items: center; gap: .5rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px; padding: .45rem .65rem;
  transition: background .14s;
}
.colecciones-list li:hover { background: rgba(255,255,255,.12); }
.colecciones-list li a {
  flex: 1; font-size: .82rem; font-weight: 500;
  color: #fff !important; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.colecciones-list li a:hover { text-decoration: underline; }

/* ── Responsivo ─────────────────────────────────────────── */
@media (max-width: 1100px) {
  .rec-layout { flex-direction: column; padding: .75rem 1rem 2rem; }
  .rec-aside { width: 100%; position: static; max-height: none; }
}
@media (max-width: 576px) {
  .rec-header { padding: 1.2rem; }
  .rec-header__title { font-size: 1.3rem; }
  .rec-body-card { padding: 1rem; }
  .rec-download { padding: 1.25rem; }
}

.picture-in-picture { position: relative; }
.picture-in-picture .pip-player { position: absolute; top: .5rem; right: .5rem; }

/* ── Derivados IA ──────────────────────────────────── */
.derivados-section { margin: 2rem 0; }
.derivados-title {
  font-size: 1.1rem; font-weight: 700; color: #1f2937;
  margin-bottom: 1rem; display: flex; align-items: center;
}
.derivados-tabs .nav-link {
  font-size: .82rem; font-weight: 600; color: #6b7280;
  border: none; padding: .6rem 1rem;
}
.derivados-tabs .nav-link.active { color: #4f46e5; border-bottom: 2px solid #4f46e5; }

/* Flashcards */
.fc-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px; padding: 16px 0;
}
.fc-card { perspective: 800px; cursor: pointer; height: 170px; }
.fc-card__inner {
  position: relative; width: 100%; height: 100%;
  transition: transform .5s; transform-style: preserve-3d;
}
.fc-card--flipped .fc-card__inner { transform: rotateY(180deg); }
.fc-card__front, .fc-card__back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
.fc-card__front { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff; }
.fc-card__back { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: #fff; transform: rotateY(180deg); }
.fc-card__badge { position: absolute; top: 10px; right: 12px; font-size: .6rem; opacity: .7; font-weight: 600; }
.fc-card__text { font-size: .85rem; line-height: 1.4; font-weight: 500; }
.fc-card__hint { position: absolute; bottom: 8px; font-size: .55rem; opacity: .5; text-transform: uppercase; letter-spacing: .05em; }

/* Mapa conceptual */
.mapa { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 16px 0; }
.mapa-centro { display: flex; justify-content: center; }
.mapa-nodo { padding: 10px 18px; border-radius: 10px; font-size: .82rem; font-weight: 500; display: inline-flex; align-items: center; }
.mapa-nodo--central {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: #fff;
  font-size: 1rem; font-weight: 700; padding: 14px 24px; box-shadow: 0 4px 16px rgba(102,126,234,.3);
}
.mapa-nodo--rama { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.mapa-nodo--hoja { background: #f8fafc; color: #64748b; border: 1px solid #e2e8f0; font-size: .75rem; padding: 6px 12px; }
.mapa-ramas { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; width: 100%; }
.mapa-rama { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 150px; flex: 1; max-width: 260px; }
.mapa-hijos { display: flex; flex-direction: column; gap: 4px; align-items: center; }

/* Resumen */
.resumen-panel { padding: 16px 0; }
.resumen-panel h4 { font-size: 1rem; font-weight: 700; margin-bottom: .5rem; }
.resumen-puntos { padding-left: 1.2rem; margin: 0; }
.resumen-puntos li { padding: .4rem 0; font-size: .88rem; line-height: 1.5; color: #374151; }
