:root {
  --bg: #f7f7f7;
  --text: #222;
  --text-muted: #555;
  --accent: #0078ff;
  --card-bg: #fff;
  --border: #ddd;
  --shadow: rgba(0, 0, 0, 0.1);
  --transition-speed: 0.3s;
}

[data-theme="dark"] {
  --bg: #121212;
  --text: #e0e0e0;
  --text-muted: #aaa;
  --accent: #4ea3ff;
  --card-bg: #1f1f1f;
  --border: #333;
  --shadow: rgba(0, 0, 0, 0.5);
}

/* ===== BASE ===== */
body {
  font-family: "Inter", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background var(--transition-speed) ease, color var(--transition-speed) ease;
  overflow-x: hidden;
  overflow-y: auto;
}

/* ===== MODO BIBLIOTECA ===== */
body.library-mode {
  background: url("images/library_bg.png") center center / cover no-repeat fixed;
  background-color: #1a0f08;
  color: #f2e7c9;
  animation: candleGlow 6s ease-in-out infinite;
}

@keyframes candleGlow {
  0%, 100% { filter: brightness(100%); }
  50% { filter: brightness(107%); }
}

body.library-mode header {
  background: rgba(25, 15, 10, 0.9);
  color: #ffd98a;
}

body.library-mode .story-card {
  background: rgba(30, 20, 10, 0.85);
  border-color: #6b4c2e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  color: #f2e7c9;
}

body.library-mode .sidebar-left,
body.library-mode .sidebar-right {
  background: rgba(15, 10, 5, 0.92);
  border-color: #5a3b1e;
}

/* ===== LAYOUT ===== */
.container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.2rem;
  padding: 1rem 0;
  width: 100%;
}

/* Barras laterales más cercanas al borde */
.sidebar-left {
  position: fixed;
  top: 90px;
  left: 1rem;
  width: 360px;
  height: calc(100vh - 140px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 6px var(--shadow);
  padding: 1rem;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-right {
  position: fixed;
  top: 90px;
  right: 1rem;
  width: 460px;
  height: calc(100vh - 140px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 2px 6px var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2rem;
  overflow-y: auto;
  z-index: 10;
}

/* Columna central más alta */
.main-content {
  position: relative;
  z-index: 20;
  margin-top: -0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 2px 6px var(--shadow);
  padding: 1.5rem;
  width: 100%;
  max-width: 800px;
  height: calc(100vh - 130px);
  overflow-y: auto;
  scrollbar-gutter: stable;
  transition: background var(--transition-speed), color var(--transition-speed);
}

.main-content::-webkit-scrollbar { width: 8px; }
.main-content::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* ===== HEADER ===== */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 6px var(--shadow);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.header-buttons {
  display: flex;
  gap: 0.8rem;
}

button {
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s ease, transform 0.2s ease;
}

#theme-toggle, #library-toggle {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.6rem 1.3rem;
}

#theme-toggle:hover, #library-toggle:hover {
  background: #006ed4;
  transform: scale(1.05);
}

/* ===== HISTORIAS ===== */
.story-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 6px var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.story-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px var(--shadow);
}

.story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

.story-title {
  font-size: 1.2rem;
  color: var(--accent);
}

.story-id {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ===== FORMULARIO (iframe submit.html) ===== */
.sidebar-right iframe {
  border: none;
  width: 100%;
  height: 460px;
  border-radius: 10px;
  background: rgba(30, 20, 10, 0.85);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ===== FORMULARIO INTERNO (submit.html contenido) ===== */
form {
  background: rgba(30, 20, 10, 0.85);
  border: 1px solid #6b4c2e;
  border-radius: 10px;
  padding: 1.5rem;
  color: #f2e7c9;
  font-family: "Inter", sans-serif;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

form h3, label {
  color: #ffd98a;
  font-weight: 600;
}

input[type="text"], textarea {
  width: 100%;
  border: 1px solid #5b3b1e;
  border-radius: 6px;
  background: rgba(25, 15, 10, 0.8);
  color: #f2e7c9;
  padding: 0.6rem;
  font-size: 1rem;
  margin-top: 0.3rem;
  transition: border-color 0.2s ease;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: #d49a50;
  box-shadow: 0 0 4px #d49a50;
}

button[type="submit"] {
  margin-top: 1rem;
  background: linear-gradient(135deg, #d49a50, #b87b2e);
  border: none;
  border-radius: 8px;
  padding: 0.8rem 1.2rem;
  color: #2b1605;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

/* ===== FOOTER ===== */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* === Candle / llama flotante (solo visual) ============================== */
/* Contenedor de la vela. Va centrado y flotando en la parte baja. */
.candle-overlay {
  position: fixed;
  left: 50%;
  bottom: 42px;                 /* parte baja central */
  transform: translateX(-50%) translateY(10px);
  width: 130px;
  height: 180px;
  pointer-events: none;
  z-index: 9999;                /* encima del feed */
  opacity: 0;
  animation: candle-in 2s ease-out forwards,
             candle-out .5s ease-in 2s forwards; /* total 2.5s */
  filter: drop-shadow(0 6px 14px rgba(255,170,50,.35));
}

/* “Aureola” de luz */
.candle-glow {
  position: absolute;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  width: 220px;
  height: 220px;
  background: radial-gradient(circle,
    rgba(255,200,90,.28) 0%,
    rgba(255,160,40,.18) 30%,
    rgba(255,140,0,.08) 55%,
    rgba(255,120,0,0) 75%);
  filter: blur(8px);
  opacity: .9;
  border-radius: 50%;
}

/* Llama */
.candle-flame {
  position: absolute;
  left: 50%;
  bottom: 72px; /* ligeramente más alta que el glow */
  transform: translateX(-50%);
  width: 34px;
  height: 60px;
  border-radius: 50% 50% 40% 40%;
  background:
    radial-gradient(ellipse at 50% 35%,
      #fff6c8 0%, #ffd36b 40%, #ff9e2a 70%, rgba(255,140,0,0) 100%);
  animation: flame-wobble 2s ease-in-out infinite;
  opacity: .95;
}

/* Reflejo sutil bajo la vela */
.candle-reflection {
  position: absolute;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%);
  width: 140px;
  height: 22px;
  background: radial-gradient(ellipse at 50% 50%,
    rgba(255,210,110,.25),
    rgba(255,180,80,.05) 60%,
    rgba(255,160,60,0) 70%);
  opacity: .9;
  border-radius: 50%;
}

/* Blur localizado en el feed mientras aparece la llama */
.main-content.is-animating {
  filter: blur(3px) brightness(.9);
  transition: filter .25s ease;
}

/* Animaciones */
@keyframes flame-wobble {
  0%   { transform: translateX(-50%) scale(1); }
  25%  { transform: translateX(calc(-50% - 2px)) scale(1.04); }
  50%  { transform: translateX(-50%) scale(1.02); }
  75%  { transform: translateX(calc(-50% + 2px)) scale(1.05); }
  100% { transform: translateX(-50%) scale(1); }
}
@keyframes candle-in {
  0%   { opacity: 0;   transform: translateX(-50%) translateY(10px); }
  100% { opacity: 1;   transform: translateX(-50%) translateY(0); }
}
@keyframes candle-out {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* === Pulso sutil en botones de voto al cambiar categoría =============== */
/* No altera su estilo normal; se activa temporalmente vía clase .pulse */
.vote-btn.pulse {
  border-radius: 8px;
  background: rgba(255,170,40,.15);
  animation: vote-pulse 1.6s ease-out;
}
@keyframes vote-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,170,40,.35); }
  100% { box-shadow: 0 0 0 14px rgba(255,170,40,0); }
}


