/* ═══════════════════════════════════════════════════════════════
   FASE 04 — Funcionalidades Innovadoras
   El Regente Theme · Phase 4 CSS
   ═══════════════════════════════════════════════════════════════ */

/* ── El Azar de la Noticia ────────────────────────────────────── */
.er-azar-trigger {
  position: fixed;
  left: 24px;
  bottom: 100px;
  z-index: 900;
  width: 56px;
  height: 56px;
  background: var(--er-color-brand, #E53920);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(229, 57, 32, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  line-height: 1;
}
.er-azar-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(229, 57, 32, 0.6);
}
.er-azar-trigger:focus-visible {
  outline: 2px solid #E53920;
  outline-offset: 3px;
}
@media (max-width: 640px) {
  .er-azar-trigger { bottom: 84px; left: 16px; width: 48px; height: 48px; font-size: 1.2rem; }
}

/* Podcast (watch layout): en móvil/tablet el FAB pasa abajo a la derecha para no tapar las miniaturas de la lista */
@media (max-width: 63.99em) {
  body.single-er_podcast .er-azar-trigger,
  body.post-type-archive-er_podcast .er-azar-trigger {
    inset-inline-start: auto;
    inset-inline-end: 12px;
    inset-block-end: calc(12px + env(safe-area-inset-bottom, 0px));
    left: auto;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }
}

/* ── Volver arriba: mismo FAB que el Azar, en el lado derecho ─────── */
.er-totop {
  position: fixed;
  right: 24px;
  bottom: 100px;
  z-index: 900;
  width: 56px;
  height: 56px;
  padding: 0;
  background: var(--er-color-brand, #E53920);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(229, 57, 32, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s, visibility 0.2s;
}
.er-totop:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(229, 57, 32, 0.6);
}
.er-totop:focus-visible {
  outline: 2px solid #E53920;
  outline-offset: 3px;
}
.er-totop:not(.is-visible) {
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  pointer-events: none;
}
@media (max-width: 640px) {
  .er-totop { bottom: 84px; right: 16px; width: 48px; height: 48px; }
  .er-totop svg { width: 20px; height: 20px; }
}
/* Podcast <64em: el ♠ ocupa la esquina derecha; la flecha se apila encima */
@media (max-width: 63.99em) {
  body.single-er_podcast .er-totop,
  body.post-type-archive-er_podcast .er-totop {
    right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: 44px;
    height: 44px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .er-totop, .er-totop:not(.is-visible) { transition: none; transform: none; }
}
@media print { .er-totop { display: none; } }

.er-azar-widget {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}
.er-azar-widget[hidden] { display: none; }

.er-azar-widget__inner {
  background: #1A1A1A;
  border: 1px solid #2A2A2A;
  border-top: 3px solid #E53920;
  border-radius: 16px;
  padding: 40px 32px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
}
@media (max-width: 480px) {
  .er-azar-widget__inner { padding: 32px 20px 24px; }
}

.er-azar-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: #9A9A9A;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.er-azar-close:hover { color: #fff; }

.er-azar-widget__headline {
  font: 800 1.5rem/1.2 'Space Grotesk', sans-serif;
  color: #FFFFFF;
  margin: 0 0 4px;
}
.er-azar-widget__sub {
  font-size: 0.875rem;
  color: #9A9A9A;
  margin: 0 0 28px;
}

/* Card 3D flip */
.er-azar-card {
  width: 200px;
  height: 300px;
  margin: 0 auto 24px;
  perspective: 1000px;
}
.er-azar-card__inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.er-azar-card.is-flipping .er-azar-card__inner {
  transform: rotateY(90deg);
}
.er-azar-card.is-revealed .er-azar-card__inner {
  transform: rotateY(180deg);
}
.er-azar-card__back,
.er-azar-card__front {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.er-azar-card__back {
  background: #1A1A1A;
  border: 2px solid #E53920;
  color: #E53920;
  gap: 8px;
}
.er-azar-card__back-spade {
  font-size: 4rem;
  line-height: 1;
}
.er-azar-card__back-name {
  font: 700 0.6rem/1 'Space Grotesk', sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(229, 57, 32, 0.7);
  white-space: nowrap;
}
.er-azar-card__front {
  background: #fff;
  border: 2px solid #E53920;
  padding: 12px;
  text-align: center;
  transform: rotateY(180deg);
  justify-content: flex-start;
}
.er-azar-card__thumb {
  width: 100%;
  height: 90px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 8px;
}
.er-azar-card__section {
  font: 700 0.6rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #E53920;
  display: block;
}
.er-azar-card__title {
  font: 700 0.78rem/1.3 'Space Grotesk', sans-serif;
  color: #1A1A1A;
  margin: 4px 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.er-azar-card__author {
  font-size: 0.68rem;
  color: #666;
  margin: 0 0 8px;
}
.er-azar-card__read {
  display: inline-block;
  padding: 4px 14px;
  background: var(--er-color-brand-action);
  color: #fff;
  border-radius: 4px;
  font: 700 0.68rem 'Space Grotesk', sans-serif;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.er-azar-error {
  color: #E53920;
  font-size: 0.8rem;
  margin-top: 8px;
}

.er-azar-draw {
  display: block;
  width: 100%;
  padding: 14px;
  background: #E53920;
  color: #fff;
  border: none;
  border-radius: 8px;
  font: 700 0.95rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 10px;
}
.er-azar-draw:hover { background: #c0281a; }
.er-azar-share {
  background: none;
  border: 1px solid #3A3A3A;
  color: #9A9A9A;
  border-radius: 6px;
  padding: 8px 20px;
  font: 600 0.8rem 'Space Grotesk', sans-serif;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.er-azar-share:hover { border-color: #E53920; color: #E53920; }

/* ── Persistent Podcast Player ────────────────────────────────── */
.er-podcast-player {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 72px;
  background: #111111;
  border-top: 2px solid #E53920;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.er-podcast-player.is-visible {
  transform: translateY(0);
}

.er-player__brand {
  color: #E53920;
  font-size: 1.25rem;
  flex-shrink: 0;
  line-height: 1;
}
.er-player__thumb {
  width: 48px;
  height: 48px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}
.er-player__info {
  min-width: 0;
  flex: 0 0 180px;
  overflow: hidden;
}
.er-player__program {
  font: 600 0.6rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--er-color-brand-on-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.er-player__title {
  font: 600 0.82rem 'Space Grotesk', sans-serif;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.er-player__controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.er-player__controls button {
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background 0.15s;
  line-height: 1;
}
.er-player__controls button:hover { background: rgba(255,255,255,0.1); }
.er-player__play {
  width: 40px !important;
  height: 40px !important;
  background: #E53920 !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 1rem !important;
}
.er-player__play:hover { background: #c0281a !important; }
.er-player__progress-wrap {
  flex: 1;
  max-width: 380px;
  min-width: 80px;
}
.er-player__progress {
  height: 4px;
  background: #2A2A2A;
  border-radius: 2px;
  cursor: pointer;
  position: relative;
}
.er-player__progress:hover { height: 6px; }
.er-player__progress-bar {
  height: 100%;
  background: #E53920;
  border-radius: 2px;
  width: 0%;
  transition: width 0.25s linear;
  pointer-events: none;
}
.er-player__time {
  display: flex;
  justify-content: space-between;
  font: 500 0.6rem 'JetBrains Mono', monospace;
  color: #999; /* sobre #1A1A1A: 6.11:1 (#555 daba 2.33) */
  margin-top: 4px;
}
.er-player__volume {
  width: 72px;
  accent-color: #E53920;
  flex-shrink: 0;
  cursor: pointer;
}
.er-player__close {
  background: none;
  border: none;
  color: #555;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.er-player__close:hover { color: #fff; }

@media (max-width: 640px) {
  .er-podcast-player { height: 60px; padding: 0 12px; gap: 8px; }
  .er-player__progress-wrap,
  .er-player__volume,
  .er-player__brand { display: none; }
  .er-player__info { flex: 1; }
}

/* ── La Tarjeta del Regente (columnist card) ─────────────────── */
.er-columnist-card {
  width: 220px;
  min-height: 300px;
  border-radius: 16px;
  padding: 20px 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border: 2px solid rgba(229, 57, 32, 0.25);
  float: right;
  margin: 0 0 24px 32px;
  clear: right;
}
.er-columnist-card__spade {
  position: absolute;
  font-size: 0.7rem;
  color: rgba(229, 57, 32, 0.4);
  line-height: 1;
}
.er-columnist-card__spade--tl { top: 8px;    left: 10px;  }
.er-columnist-card__spade--tr { top: 8px;    right: 10px; }
.er-columnist-card__spade--bl { bottom: 8px; left: 10px;  }
.er-columnist-card__spade--br { bottom: 8px; right: 10px; }
.er-columnist-card__body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.er-columnist-card__photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(229, 57, 32, 0.4);
  display: block;
}
.er-columnist-card__name {
  font: 800 1rem/1.2 'Space Grotesk', sans-serif;
  color: #fff;
  text-decoration: none;
  margin-top: 10px;
  display: block;
}
.er-columnist-card__name:hover { color: #E53920; }
.er-columnist-card__cargo {
  font: 600 0.65rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(229, 57, 32, 0.85);
  display: block;
}
.er-columnist-card__divider {
  width: 70%;
  height: 1px;
  background: rgba(229, 57, 32, 0.25);
  margin: 12px auto;
}
.er-columnist-card__firma {
  max-width: 140px;
  height: auto;
  opacity: 0.85;
  filter: invert(1) brightness(2);
}
.er-columnist-card__twitter {
  font: 600 0.68rem 'Space Grotesk', sans-serif;
  color: rgba(229, 57, 32, 0.7);
  text-decoration: none;
  margin-top: 8px;
  display: block;
  transition: color 0.15s;
}
.er-columnist-card__twitter:hover { color: #E53920; }
@media (max-width: 768px) {
  .er-columnist-card {
    float: none;
    width: 100%;
    margin: 0 0 24px;
    flex-direction: row;
    min-height: auto;
    gap: 16px;
    align-items: flex-start;
    text-align: left;
    padding: 16px;
  }
  .er-columnist-card__body { flex-direction: row; align-items: center; gap: 16px; flex: 1; }
  .er-columnist-card__photo { width: 64px; height: 64px; }
  .er-columnist-card__divider { display: none; }
  .er-columnist-card__firma { max-width: 80px; }
  .er-columnist-card__spade { display: none; }
}

/* ── Series Sidebar ───────────────────────────────────────────── */
.er-series-sidebar {
  background: var(--er-bg-secondary, #212121);
  border: 1px solid var(--er-border-color, #2A2A2A);
  border-top: 4px solid var(--er-color-brand, #E53920);
  border-radius: 8px;
  padding: 24px;
  position: sticky;
  top: 90px;
}
.er-series-sidebar__header { margin-bottom: 20px; }
.er-series-sidebar__name {
  font: 700 0.95rem/1.3 'Space Grotesk', sans-serif;
  color: var(--er-text-primary, #fff);
  margin: 8px 0 6px;
}
.er-series-sidebar__progress-label {
  font-size: 0.72rem;
  color: var(--er-text-muted, #9A9A9A);
  margin-bottom: 8px;
}
.er-series-sidebar__progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}
.er-series-sidebar__progress-fill {
  height: 100%;
  background: var(--er-color-brand, #E53920);
  border-radius: 2px;
  width: 0%;
  transition: width 0.5s ease;
}
.er-series-sidebar__chapter {
  display: grid;
  grid-template-columns: 44px 1fr 18px;
  gap: 6px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--er-border-color, #2A2A2A);
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.15s;
}
.er-series-sidebar__chapter:last-child { border-bottom: none; }
.er-series-sidebar__chapter:hover { background: rgba(229, 57, 32, 0.05); }
.er-series-sidebar__chapter.is-current .er-series-sidebar__chapter-num { color: #E53920; }
.er-series-sidebar__chapter.is-current .er-series-sidebar__chapter-title {
  color: var(--er-text-primary, #fff);
  font-weight: 700;
}
.er-series-sidebar__chapter-num {
  font: 700 0.65rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--er-text-muted, #9A9A9A);
  padding-top: 2px;
}
.er-series-sidebar__chapter-title {
  font: 500 0.78rem/1.3 'Space Grotesk', sans-serif;
  color: var(--er-text-secondary, #CCCCCC);
}
.er-series-sidebar__read-check {
  color: var(--er-color-brand, #E53920);
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 0.2s;
  padding-top: 2px;
}
.er-series-sidebar__chapter.is-read .er-series-sidebar__read-check { opacity: 1; }
.er-series-sidebar__chapter.is-read .er-series-sidebar__chapter-title {
  color: var(--er-text-muted, #9A9A9A);
  text-decoration: line-through;
  text-decoration-color: rgba(229, 57, 32, 0.3);
}

/* ── OG Image share preview box ───────────────────────────────── */
.er-share-og-preview {
  background: #1A1A1A;
  border: 1px solid #2A2A2A;
  border-radius: 8px;
  overflow: hidden;
  max-width: 440px;
}
.er-share-og-preview__strip {
  height: 4px;
  background: #E53920;
}
.er-share-og-preview__body { padding: 16px; }
.er-share-og-preview__section {
  font: 700 0.65rem 'Space Grotesk', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #E53920;
  margin-bottom: 6px;
}
.er-share-og-preview__title {
  font: 700 1.1rem/1.3 'Space Grotesk', sans-serif;
  color: #fff;
}
.er-share-og-preview__brand {
  font: 500 0.7rem 'Space Grotesk', sans-serif;
  color: #555;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Light mode overrides */
[data-theme="light"] .er-azar-widget__inner { background: #fff; border-color: #e0e0e0; }
[data-theme="light"] .er-azar-card__back { background: #f5f5f5; }
[data-theme="light"] .er-podcast-player { background: #1A1A1A; }
[data-theme="light"] .er-series-sidebar { background: #f8f8f8; }
[data-theme="light"] .er-columnist-card { border-color: rgba(229, 57, 32, 0.3); }
