/* ============================================================
   Mi Enciclopedia — diseño calmado para estudiar oposiciones
   ============================================================ */
:root {
  --bg: #f6f4ef;
  --ink: #3d3a36;
  --ink-soft: #8a857d;
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #ffffff;
  --line: rgba(61, 58, 54, 0.1);
  --accent: #8b9dc3;
  --lavender: #b8c0e0;
  --sage: #a3b18a;
  --sand: #e0c097;
  --rose: #d4a5a5;
  --shadow: 0 10px 40px rgba(90, 80, 70, 0.12);
  --radius: 18px;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --sans: 'Nunito Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- fondo animado (blobs flotantes) ---------- */
.bg {
  position: fixed; inset: 0;
  overflow: hidden; z-index: -1;
  background: linear-gradient(160deg, #f7f3ec 0%, #eef0f7 45%, #f1f3ea 100%);
}
.blob {
  position: absolute; border-radius: 50%;
  filter: blur(60px); opacity: 0.5;
  will-change: transform;
  animation: drift 26s ease-in-out infinite alternate;
}
.blob-1 { width: 45vw; height: 45vw; background: #c9d2ee; top: -12%; left: -8%; }
.blob-2 { width: 38vw; height: 38vw; background: #dde5cf; bottom: -10%; right: -6%; animation-delay: -7s; animation-duration: 32s; }
.blob-3 { width: 30vw; height: 30vw; background: #f0dcc8; top: 30%; right: 18%; animation-delay: -14s; animation-duration: 38s; }
.blob-4 { width: 26vw; height: 26vw; background: #ecd6d6; bottom: 20%; left: 16%; animation-delay: -20s; animation-duration: 29s; }

@keyframes drift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(6vw, -4vh) scale(1.12); }
  100% { transform: translate(-5vw, 5vh) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .blob, .stars::before, .stars::after, .landing-emblem { animation: none !important; }
}

/* ---------- navegación ---------- */
.topnav {
  display: flex; align-items: center; gap: 20px;
  padding: 16px 32px;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.55);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand {
  font-family: var(--serif); font-size: 1.35rem; font-weight: 600;
  text-decoration: none; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.crumbs { font-size: 0.92rem; color: var(--ink-soft); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumb-sep { opacity: 0.5; }
.crumb-current { color: var(--ink); font-weight: 600; }

/* ---------- contenedor ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; margin-bottom: 32px; flex-wrap: wrap;
}
.page-head h1 { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; line-height: 1.15; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.75rem; font-weight: 700; margin-bottom: 4px; }
.muted { color: var(--ink-soft); font-size: 0.95rem; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card-solid); color: var(--ink);
  font-family: var(--sans); font-size: 0.95rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary { background: var(--ink); color: #fdfbf7; border-color: var(--ink); }
.btn-primary:hover { background: #55504a; }
.btn-small { padding: 6px 14px; font-size: 0.85rem; }

.chip-btn {
  border: none; background: rgba(255,255,255,0.85);
  width: 34px; height: 34px; border-radius: 50%;
  cursor: pointer; font-size: 0.95rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: transform 0.15s;
}
.chip-btn:hover { transform: scale(1.12); }

/* ---------- flashes ---------- */
.flashes { position: fixed; top: 76px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 12px 20px; border-radius: 12px; font-size: 0.92rem; font-weight: 600;
  box-shadow: var(--shadow); animation: flash-in 0.3s ease, flash-out 0.5s ease 3.5s forwards;
}
.flash-ok { background: #e6efdd; color: #4e6b3a; border: 1px solid #c6d8b4; }
.flash-error { background: #f7e3e3; color: #9c4a4a; border: 1px solid #e6c3c3; }
@keyframes flash-in { from { opacity: 0; transform: translateX(30px); } }
@keyframes flash-out { to { opacity: 0; transform: translateX(30px); visibility: hidden; } }

/* ---------- tarjetas de sección ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.section-card {
  position: relative;
  background: var(--card); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-top: 4px solid var(--accent);
  border-radius: var(--radius); padding: 28px 24px 20px;
  text-decoration: none; color: var(--ink);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.section-icon { font-size: 2.2rem; margin-bottom: 10px; }
.section-card h2 { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; margin-bottom: 2px; }
.card-actions {
  position: absolute; top: 14px; right: 14px;
  display: flex; gap: 6px; align-items: center;
  opacity: 0; transition: opacity 0.2s;
}
.section-card:hover .card-actions, .topic-row:hover .card-actions { opacity: 1; }

/* ---------- lista de temas ---------- */
.topic-list { display: flex; flex-direction: column; gap: 12px; }
.topic-row {
  position: relative;
  display: flex; align-items: center; gap: 18px;
  background: var(--card); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 24px; text-decoration: none; color: var(--ink);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.topic-row:hover { transform: translateX(4px); box-shadow: var(--shadow); }
.topic-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.topic-info h2 { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; }
.topic-row .card-actions { position: static; margin-left: auto; }
.topic-arrow { color: var(--ink-soft); font-size: 1.2rem; }

/* ---------- vacío ---------- */
.empty {
  text-align: center; padding: 70px 20px;
  background: var(--card); border: 1px dashed var(--line);
  border-radius: var(--radius);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty h2 { font-family: var(--serif); font-size: 1.6rem; margin-bottom: 6px; }
.empty .btn { margin-top: 18px; }

/* ---------- paneles ---------- */
.panel {
  background: var(--card); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 28px; margin-bottom: 24px;
}
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2 { font-family: var(--serif); font-size: 1.4rem; font-weight: 600; }

/* notas */
.notes-view { white-space: pre-wrap; font-size: 0.98rem; }
.notes-view.is-empty { color: var(--ink-soft); font-style: italic; }
#notes-area {
  width: 100%; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; font-family: var(--sans); font-size: 0.98rem;
  resize: vertical; background: var(--card-solid);
}
.notes-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

/* ---------- galería ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.thumb {
  position: relative; border-radius: 14px; overflow: hidden;
  background: var(--card-solid); border: 1px solid var(--line);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.thumb:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.thumb img { width: 100%; height: 170px; object-fit: cover; display: block; cursor: zoom-in; }
.thumb figcaption {
  padding: 8px 10px; font-size: 0.8rem; color: var(--ink-soft);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.thumb-delete { position: absolute; top: 8px; right: 8px; opacity: 0; transition: opacity 0.2s; }
.thumb:hover .thumb-delete { opacity: 1; }

/* ---------- lista de archivos ---------- */
.file-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: var(--card-solid); border: 1px solid var(--line);
  flex-wrap: wrap;
}
.file-ico { font-size: 1.3rem; }
.file-name { font-weight: 600; flex: 1; min-width: 140px; word-break: break-all; }
.file-size { flex-shrink: 0; }
.file-row audio { height: 34px; max-width: 240px; }

/* ---------- modales ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(50, 45, 40, 0.45); backdrop-filter: blur(4px);
  padding: 20px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--bg); border-radius: 22px;
  padding: 32px; width: 100%; max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
  animation: pop 0.22s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(10px); } }
.modal-box h2 { font-family: var(--serif); font-size: 1.5rem; margin-bottom: 18px; }
.modal-box label { display: block; font-weight: 700; font-size: 0.88rem; margin: 14px 0 6px; }
.modal-box input[type="text"] {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-solid);
  font-family: var(--sans); font-size: 1rem;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* pickers */
.icon-picker, .color-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.icon-opt input, .color-opt input { display: none; }
.icon-opt span {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; font-size: 1.3rem;
  background: var(--card-solid); border: 2px solid transparent; cursor: pointer;
  transition: border 0.15s, transform 0.15s;
}
.icon-opt input:checked + span { border-color: var(--ink); transform: scale(1.08); }
.color-opt span {
  display: block; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid transparent; cursor: pointer; transition: border 0.15s, transform 0.15s;
}
.color-opt input:checked + span { border-color: var(--ink); transform: scale(1.12); }

/* dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  border: 2px dashed rgba(61,58,54,0.25); border-radius: 16px;
  padding: 36px 20px; text-align: center; cursor: pointer;
  background: var(--card-solid); transition: border-color 0.2s, background 0.2s;
  font-weight: 400 !important;
}
.dropzone.dragover { border-color: var(--accent); background: #eef1f8; }
.dropzone input[type="file"] { display: none; }
.dz-icon { font-size: 2rem; }
.dz-text { font-weight: 700; }
.dz-hint { font-size: 0.8rem; color: var(--ink-soft); }
.dz-count { font-size: 0.9rem; color: #4e6b3a; font-weight: 700; }

/* ---------- visor a pantalla completa ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(28, 26, 24, 0.96);
  display: flex; align-items: center; justify-content: center;
}
.viewer[hidden] { display: none; }
.viewer-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; overflow: auto; }
.viewer-stage img {
  max-width: 92vw; max-height: 92vh; object-fit: contain;
  border-radius: 6px; cursor: zoom-in;
  transition: max-width 0.2s ease;
}
.viewer-stage.zoomed { align-items: flex-start; }
.viewer-stage.zoomed img { max-width: none; max-height: none; width: 150vw; cursor: zoom-out; border-radius: 0; }
.viewer-close {
  position: absolute; top: 18px; right: 22px; z-index: 210;
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.2rem; cursor: pointer;
  transition: background 0.15s;
}
.viewer-close:hover { background: rgba(255,255,255,0.28); }
.viewer-nav {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 210;
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  width: 52px; height: 52px; border-radius: 50%; font-size: 1.8rem; cursor: pointer;
  transition: background 0.15s;
}
.viewer-nav:hover { background: rgba(255,255,255,0.28); }
.viewer-prev { left: 20px; }
.viewer-next { right: 20px; }
.viewer-caption {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,0.85); font-size: 0.9rem;
  background: rgba(0,0,0,0.4); padding: 6px 16px; border-radius: 999px;
  max-width: 80vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#pdf-frame { width: 92vw; height: 92vh; border: none; border-radius: 8px; background: #fff; }

/* ============================================================
   LANDING
   ============================================================ */
.landing-page .container { max-width: none; padding: 0; }
.landing {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; padding: 24px;
}

/* partículas suaves */
.stars { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.stars::before, .stars::after {
  content: ''; position: absolute; inset: -10%;
  background-image:
    radial-gradient(3px 3px at 12% 20%, rgba(255,255,255,0.9) 40%, transparent 60%),
    radial-gradient(2px 2px at 32% 68%, rgba(255,255,255,0.8) 40%, transparent 60%),
    radial-gradient(3px 3px at 55% 30%, rgba(255,255,255,0.85) 40%, transparent 60%),
    radial-gradient(2px 2px at 70% 75%, rgba(255,255,255,0.8) 40%, transparent 60%),
    radial-gradient(3px 3px at 85% 15%, rgba(255,255,255,0.9) 40%, transparent 60%),
    radial-gradient(2px 2px at 22% 88%, rgba(255,255,255,0.75) 40%, transparent 60%),
    radial-gradient(2px 2px at 92% 55%, rgba(255,255,255,0.8) 40%, transparent 60%);
  animation: float-up 60s linear infinite;
  opacity: 0.7;
}
.stars::after { animation-duration: 90s; animation-delay: -30s; transform: scale(1.4); opacity: 0.4; }
@keyframes float-up {
  from { transform: translateY(0); }
  to   { transform: translateY(-40vh); }
}

.landing-card {
  position: relative; z-index: 2; text-align: center;
  background: rgba(255, 255, 255, 0.6); backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 28px; padding: 64px 56px;
  max-width: 640px; box-shadow: 0 30px 90px rgba(90, 80, 70, 0.18);
  animation: card-in 0.9s ease both;
}
@keyframes card-in { from { opacity: 0; transform: translateY(24px); } }

.landing-emblem { font-size: 3.4rem; animation: emblem-float 5s ease-in-out infinite; }
@keyframes emblem-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
.landing-eyebrow {
  text-transform: uppercase; letter-spacing: 0.22em; font-size: 0.78rem;
  font-weight: 700; color: var(--ink-soft); margin: 18px 0 10px;
}
.landing-title {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(2.1rem, 5vw, 3.2rem); line-height: 1.15;
}
.landing-title em { font-style: italic; font-weight: 600; }
.landing-sub { margin: 22px 0 34px; color: var(--ink-soft); font-size: 1.05rem; }

.btn-start {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 16px 44px; border-radius: 999px;
  background: var(--ink); color: #fdfbf7;
  font-size: 1.1rem; font-weight: 700; text-decoration: none;
  box-shadow: 0 12px 30px rgba(61, 58, 54, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.btn-start:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(61, 58, 54, 0.35); }
.btn-start-arrow { transition: transform 0.2s; }
.btn-start:hover .btn-start-arrow { transform: translateX(5px); }

.sound-toggle {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.6); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 10px 18px; font-family: var(--sans); font-size: 0.85rem; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; transition: background 0.2s;
}
.sound-toggle:hover { background: rgba(255,255,255,0.9); }
.sound-toggle.on { color: #4e6b3a; border-color: #c6d8b4; }
.sound-toggle-float { position: absolute; bottom: 26px; left: 26px; z-index: 3; }
.sound-toggle-nav { margin-left: auto; padding: 8px 13px; font-size: 1rem; }

/* ---------- Lexi, la mascota ---------- */
.mascot {
  position: fixed; right: 22px; bottom: 16px; z-index: 80;
  cursor: pointer; user-select: none;
}
.mascot svg {
  display: block;
  filter: drop-shadow(0 8px 16px rgba(90, 80, 70, 0.25));
  animation: lexi-bob 4.5s ease-in-out infinite;
}
@keyframes lexi-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
.mascot.hop svg { animation: lexi-hop 0.6s ease; }
@keyframes lexi-hop {
  0% { transform: translateY(0); }
  35% { transform: translateY(-20px) rotate(-4deg); }
  70% { transform: translateY(0); }
  85% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}
.mascot .lid {
  transform-box: fill-box; transform-origin: center top;
  transform: scaleY(0);
  animation: lexi-blink 5.5s infinite;
}
.mascot .lid:last-of-type { animation-delay: 0.05s; }
@keyframes lexi-blink {
  0%, 93%, 100% { transform: scaleY(0); }
  95%, 97% { transform: scaleY(1); }
}
.mascot-bubble {
  position: absolute; bottom: calc(100% + 8px); right: 6px;
  width: max-content; max-width: 240px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px; font-size: 0.85rem; font-weight: 600; color: var(--ink);
  box-shadow: var(--shadow);
  animation: pop 0.25s ease;
}
@media (prefers-reduced-motion: reduce) {
  .mascot svg, .mascot .lid { animation: none !important; }
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .topnav { padding: 12px 16px; }
  .container { padding: 24px 14px 60px; }
  .page-head h1 { font-size: 1.8rem; }
  .landing-card { padding: 44px 26px; }
  .viewer-nav { width: 42px; height: 42px; }
  .flashes { left: 14px; right: 14px; }
  .mascot { right: 12px; bottom: 10px; }
  .mascot svg { width: 62px; height: 62px; }
  .mascot-bubble { max-width: 190px; font-size: 0.8rem; }
  .sound-toggle-float { left: 14px; bottom: 14px; }
  .sound-toggle-float .sound-label { display: none; }
}
