/* ============================================================
   Crónicas Crypto — Main Stylesheet
   A modern crypto-tech educational platform.
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   0. CSS Custom Properties
   ──────────────────────────────────────────────────────────── */

:root {
  /* Light mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;

  /* Pillar colors */
  --accent-historia: #F59E0B;
  --accent-tutoriales: #3B82F6;
  --accent-wiki: #8B5CF6;
  --accent-primary: #F59E0B;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 28px rgba(15, 23, 42, 0.12);
  --shadow-xl: 0 16px 48px rgba(15, 23, 42, 0.14);

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* Layout */
  --top-bar-h: 56px;
  --sidebar-w: 280px;
  --content-max-w: 800px;
  --tab-bar-h: 44px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
  --transition-slow: 300ms ease;
}

[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border: #334155;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.5);
}

/* ────────────────────────────────────────────────────────────
   1. Base Reset & Typography
   ──────────────────────────────────────────────────────────── */

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

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; margin-top: 2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1.2rem; margin-top: 1.5rem; margin-bottom: 0.5rem; }
h4 { font-size: 1.05rem; margin-top: 1rem; margin-bottom: 0.5rem; }

a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

::selection { background: var(--accent-primary); color: #0f172a; }

/* ────────────────────────────────────────────────────────────
   2. Skip Link
   ──────────────────────────────────────────────────────────── */

.skip-link {
  position: fixed; top: -100%; left: 16px; z-index: 999;
  padding: 8px 16px; background: var(--accent-primary); color: #0f172a;
  border-radius: var(--radius-md); font-weight: 600;
}
.skip-link:focus { top: 8px; }

/* ────────────────────────────────────────────────────────────
   3. Top Bar
   ──────────────────────────────────────────────────────────── */

.top-bar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--top-bar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px); z-index: 100;
}

.top-bar__left { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.top-bar__center { flex: 1; max-width: 480px; margin: 0 auto; }
.top-bar__right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.top-bar__logo {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text-primary);
  font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.1rem;
}
.top-bar__logo:hover { text-decoration: none; }

.logo-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-historia), var(--accent-wiki));
  color: #0f172a; font-weight: 800; font-size: 0.8rem;
  font-family: 'Space Grotesk', sans-serif;
}

.logo-text {
  background: linear-gradient(135deg, var(--accent-historia), var(--accent-wiki));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ────────────────────────────────────────────────────────────
   3a. Hamburger
   ──────────────────────────────────────────────────────────── */

.hamburger {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 36px; height: 36px; padding: 6px;
  background: none; border: none; cursor: pointer;
}
.hamburger span {
  display: block; height: 2px; background: var(--text-primary);
  border-radius: 2px; transition: var(--transition-base);
}
.sidebar-open .hamburger span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.sidebar-open .hamburger span:nth-child(2) { opacity: 0; }
.sidebar-open .hamburger span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ────────────────────────────────────────────────────────────
   3b. Search
   ──────────────────────────────────────────────────────────── */

.search-wrapper {
  position: relative; width: 100%;
}
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-input {
  width: 100%; padding: 8px 12px 8px 40px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-pill); color: var(--text-primary);
  font-size: 0.875rem; font-family: inherit; outline: none;
  transition: var(--transition-base);
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15); }

.search-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  max-height: 360px; overflow-y: auto; z-index: 200;
}
.search-dropdown.active { display: block; }

.search-dropdown__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; transition: var(--transition-fast);
  text-decoration: none; color: var(--text-primary);
}
.search-dropdown__item:hover { background: var(--bg-tertiary); text-decoration: none; }

.search-dropdown__badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 0.7rem; font-weight: 600; color: #0f172a; flex-shrink: 0;
}
.search-dropdown__text { font-size: 0.875rem; }
.search-dropdown__empty { padding: 16px; text-align: center; color: var(--text-muted); font-size: 0.875rem; }

/* ────────────────────────────────────────────────────────────
   3c. Theme Toggle
   ──────────────────────────────────────────────────────────── */

.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--text-secondary); transition: var(--transition-base);
}
.theme-toggle:hover { background: var(--bg-tertiary); color: var(--accent-primary); }

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* Language Toggle */
.lang-toggle {
  display: flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 10px; border-radius: var(--radius-md);
  background: none; border: 1px solid var(--border); cursor: pointer;
  color: var(--text-secondary); transition: var(--transition-base);
  font-family: 'Space Grotesk', sans-serif; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.04em;
}
.lang-toggle:hover { background: var(--bg-tertiary); color: var(--accent-primary); }

/* ────────────────────────────────────────────────────────────
   4. Sidebar
   ──────────────────────────────────────────────────────────── */

.sidebar-backdrop {
  display: none; position: fixed; inset: 0; z-index: 80;
  background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px);
}

.sidebar {
  position: fixed; top: var(--top-bar-h); left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto; z-index: 90;
  transition: transform var(--transition-slow);
}

.sidebar__nav { padding: 12px 0; }
.sidebar__section { padding: 4px 12px; }
.sidebar__heading {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.7rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); padding: 8px 8px 4px; margin: 0;
}
.sidebar__divider { height: 1px; background: var(--border); margin: 8px 16px; }
.sidebar__list { list-style: none; padding: 0; margin: 0; }

/* Pillar Tabs */
.pillar-tabs {
  display: flex; gap: 2px; padding: 8px 12px; margin-bottom: 4px;
}
.pillar-tab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 4px; border: none; border-radius: var(--radius-md);
  background: transparent; color: var(--text-muted); cursor: pointer;
  font-family: 'Space Grotesk', sans-serif; font-size: 0.72rem;
  font-weight: 600; transition: var(--transition-base);
}
.pillar-tab:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pillar-tab.active { color: #0f172a; }
.pillar-tab--historia.active { background: var(--accent-historia); }
.pillar-tab--tutoriales.active { background: var(--accent-tutoriales); }
.pillar-tab--wiki.active { background: var(--accent-wiki); }

/* Sidebar Items */
.sidebar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0; border-radius: var(--radius-md);
  text-decoration: none; color: var(--text-secondary);
  font-size: 0.84rem; transition: var(--transition-fast); cursor: pointer;
}
.sidebar-item:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.sidebar-item--active { background: var(--bg-tertiary); color: var(--text-primary); font-weight: 600; }
.sidebar-item--dimmed { opacity: 0.4; pointer-events: none; }

.sidebar-item__num {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--radius-sm);
  font-size: 0.72rem; font-weight: 700; color: #0f172a; flex-shrink: 0;
}
.sidebar-item__title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-item__check {
  flex-shrink: 0; color: #22c55e;
}

/* Sidebar Links (recursos) */
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; margin: 1px 0; border-radius: var(--radius-md);
  text-decoration: none; color: var(--text-secondary); font-size: 0.84rem;
  transition: var(--transition-fast);
}
.sidebar__link:hover { background: var(--bg-tertiary); color: var(--text-primary); text-decoration: none; }
.sidebar__link--active { background: var(--bg-tertiary); color: var(--accent-primary); font-weight: 600; }
.sidebar__link svg { flex-shrink: 0; }

/* ────────────────────────────────────────────────────────────
   5. Main Content
   ──────────────────────────────────────────────────────────── */

.main {
  margin-left: var(--sidebar-w); margin-top: var(--top-bar-h);
  min-height: calc(100vh - var(--top-bar-h));
}

.content {
  max-width: var(--content-max-w); margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ────────────────────────────────────────────────────────────
   6. Landing Page
   ──────────────────────────────────────────────────────────── */

.landing-hero { text-align: center; padding: 48px 0 32px; }
.landing-title {
  font-size: 3rem; font-weight: 800; line-height: 1.1;
  font-family: 'Space Grotesk', sans-serif;
  background: linear-gradient(135deg, var(--accent-historia), var(--accent-tutoriales), var(--accent-wiki));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}
.landing-subtitle {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem; color: var(--text-secondary); margin-bottom: 16px;
}
.landing-desc { color: var(--text-muted); max-width: 540px; margin: 0 auto; line-height: 1.8; }

/* Progress */
.landing-progress { padding: 16px 0 32px; }
.progress-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 8px; text-align: center; }
.progress-bar-track {
  height: 8px; background: var(--bg-tertiary); border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%; border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent-historia), var(--accent-tutoriales), var(--accent-wiki));
  transition: width 0.5s ease;
}

/* Pillar Cards */
.pillar-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
  margin: 32px 0;
}
.pillar-card {
  padding: 24px 20px; border-radius: var(--radius-xl);
  background: var(--bg-secondary); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition-base);
  text-decoration: none; color: var(--text-primary);
  display: flex; flex-direction: column; gap: 12px;
}
.pillar-card:hover {
  transform: translateY(-4px); box-shadow: var(--shadow-lg);
  text-decoration: none; border-color: var(--accent-primary);
}
.pillar-card__icon {
  width: 48px; height: 48px; border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.pillar-card__icon--historia { background: rgba(245, 158, 11, 0.15); color: var(--accent-historia); }
.pillar-card__icon--tutoriales { background: rgba(59, 130, 246, 0.15); color: var(--accent-tutoriales); }
.pillar-card__icon--wiki { background: rgba(139, 92, 246, 0.15); color: var(--accent-wiki); }

.pillar-card__title { font-family: 'Space Grotesk', sans-serif; font-size: 1.15rem; font-weight: 700; }
.pillar-card__count { font-size: 0.8rem; color: var(--text-muted); }
.pillar-card__desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* Chapter/Tutorial Cards */
.landing-section { margin-top: 48px; }
.landing-section__title {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.3rem;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.landing-section__badge {
  display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: 0.7rem; font-weight: 700; color: #0f172a;
}

.landing-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }

.class-card {
  padding: 16px; border-radius: var(--radius-lg);
  background: var(--bg-secondary); border: 1px solid var(--border);
  cursor: pointer; transition: var(--transition-base);
  position: relative; overflow: hidden;
}
.class-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.class-card--coming-soon { opacity: 0.4; cursor: default; }
.class-card--coming-soon:hover { transform: none; box-shadow: none; }
.class-card--studied { border-color: #22c55e; }

.class-card__badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 700; color: #0f172a; margin-bottom: 8px;
}
.class-card__title { font-family: 'Space Grotesk', sans-serif; font-size: 0.92rem; font-weight: 600; line-height: 1.3; }
.class-card__period { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.class-card__lock, .class-card__check {
  position: absolute; top: 12px; right: 12px;
}
.class-card__lock { color: var(--text-muted); }
.class-card__check { color: #22c55e; }

/* ────────────────────────────────────────────────────────────
   7. Chapter/Tutorial Header + Tabs
   ──────────────────────────────────────────────────────────── */

.cap-header {
  display: flex; align-items: flex-start; gap: 16px;
  padding: 24px 0 16px;
}
.cap-header__badge {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; border-radius: var(--radius-lg);
  font-size: 1.25rem; font-weight: 800; color: #0f172a; flex-shrink: 0;
  font-family: 'Space Grotesk', sans-serif;
}
.cap-header__text { flex: 1; }
.cap-header__title { font-size: 1.5rem; margin: 0; }
.cap-header__period { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* Tab Bar */
.tabs-bar {
  display: flex; gap: 0; overflow-x: auto;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px; -webkit-overflow-scrolling: touch;
}
.tabs-bar::-webkit-scrollbar { display: none; }

.tab {
  padding: 10px 16px; white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif; font-size: 0.84rem; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: var(--transition-fast);
}
.tab:hover { color: var(--text-primary); text-decoration: none; }
.tab--active { font-weight: 700; }
.tab--active.tab--historia { color: var(--accent-historia); border-bottom-color: var(--accent-historia); }
.tab--active.tab--tutoriales { color: var(--accent-tutoriales); border-bottom-color: var(--accent-tutoriales); }
.tab--active.tab--wiki { color: var(--accent-wiki); border-bottom-color: var(--accent-wiki); }

/* ────────────────────────────────────────────────────────────
   8. Article Content (rich text)
   ──────────────────────────────────────────────────────────── */

.cap-content { padding: 0 0 32px; }
.cap-content h2 { margin-top: 2rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); }
.cap-content h3 { margin-top: 1.75rem; }
.cap-content p { margin-bottom: 1rem; color: var(--text-secondary); }
.cap-content ul, .cap-content ol { margin: 0.75rem 0; padding-left: 1.75rem; }
.cap-content li { margin-bottom: 0.4rem; color: var(--text-secondary); }
.cap-content strong { color: var(--text-primary); }

.cap-content blockquote {
  margin: 1.5rem 0; padding: 16px 20px;
  border-left: 4px solid var(--accent-primary); background: var(--bg-secondary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-style: italic; color: var(--text-secondary);
}

.cap-content code {
  padding: 2px 6px; background: var(--bg-tertiary);
  border-radius: var(--radius-sm); font-size: 0.88em; color: var(--accent-primary);
}
.cap-content pre {
  margin: 1rem 0; padding: 16px; background: var(--bg-tertiary);
  border-radius: var(--radius-md); overflow-x: auto;
}
.cap-content pre code { padding: 0; background: none; }

.cap-content hr {
  margin: 2rem 0; border: none; border-top: 1px solid var(--border);
}

.cap-content dl { margin: 1.5rem 0; }
.cap-content dt {
  font-weight: 700; color: var(--text-primary); margin-top: 1.25rem;
  padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.cap-content dt:first-child { margin-top: 0; }
.cap-content dd {
  margin: 0.5rem 0 0 0; padding-left: 1rem;
  color: var(--text-secondary); line-height: 1.7;
  border-left: 3px solid var(--accent-primary); padding-bottom: 0.25rem;
}

.table-wrapper { overflow-x: auto; margin: 1rem 0; }
.cap-content table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
.cap-content th, .cap-content td {
  padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border);
}
.cap-content th {
  font-family: 'Space Grotesk', sans-serif; font-weight: 600;
  background: var(--bg-secondary); color: var(--text-primary);
}
.cap-content td { color: var(--text-secondary); }
.cap-content__empty { color: var(--text-muted); font-style: italic; padding: 32px 0; text-align: center; }

/* ────────────────────────────────────────────────────────────
   9. Studied Toggle
   ──────────────────────────────────────────────────────────── */

.studied-toggle { padding: 16px 0; text-align: center; }
.studied-toggle__btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border: 2px solid var(--border);
  border-radius: var(--radius-pill); background: transparent;
  color: var(--text-secondary); font-family: 'Space Grotesk', sans-serif;
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: var(--transition-base);
}
.studied-toggle__btn:hover { border-color: #22c55e; color: #22c55e; }
.studied-toggle__btn--active {
  background: #22c55e; border-color: #22c55e; color: #0f172a;
}

/* ────────────────────────────────────────────────────────────
   10. Prev/Next Navigation
   ──────────────────────────────────────────────────────────── */

.prev-next {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 24px 0; border-top: 1px solid var(--border); margin-top: 16px;
}
.prev-next__link {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none;
  color: var(--text-secondary); font-size: 0.875rem;
  transition: var(--transition-base); max-width: 48%;
}
.prev-next__link:hover { border-color: var(--accent-primary); color: var(--text-primary); text-decoration: none; }
.prev-next__arrow { font-size: 1.1rem; flex-shrink: 0; }
.prev-next__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ────────────────────────────────────────────────────────────
   11. Glossary
   ──────────────────────────────────────────────────────────── */

.resource-header { padding: 24px 0 16px; }
.resource-header h1 { font-size: 1.75rem; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filter-btn {
  padding: 5px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-pill); background: transparent;
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; transition: var(--transition-fast);
}
.filter-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.filter-btn--active { background: var(--accent-primary); border-color: var(--accent-primary); color: #0f172a; font-weight: 600; }

.filter-search { margin-bottom: 16px; }
.filter-search__input {
  width: 100%; padding: 8px 14px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-md); color: var(--text-primary);
  font-size: 0.875rem; font-family: inherit; outline: none;
}
.filter-search__input:focus { border-color: var(--accent-primary); }

.letter-anchors { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 20px; }
.letter-anchor {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--radius-sm);
  font-size: 0.8rem; font-weight: 600; color: var(--text-muted);
  text-decoration: none; transition: var(--transition-fast);
}
.letter-anchor:hover { background: var(--bg-tertiary); color: var(--accent-primary); text-decoration: none; }

.glosario-letter {
  font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem;
  font-weight: 700; color: var(--accent-primary);
  padding: 16px 0 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}

.glosario-card {
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.glosario-card__term {
  font-family: 'Space Grotesk', sans-serif; font-size: 1rem;
  font-weight: 600; display: inline; margin-right: 8px;
}
.glosario-card__badge {
  display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 0.7rem; font-weight: 600; background: var(--bg-tertiary);
  color: var(--text-muted); vertical-align: middle;
}
.glosario-card__def { margin-top: 4px; font-size: 0.875rem; color: var(--text-secondary); }

/* ────────────────────────────────────────────────────────────
   12. Personajes
   ──────────────────────────────────────────────────────────── */

.personajes-list { display: grid; grid-template-columns: 1fr; gap: 12px; }

.personaje-card {
  padding: 20px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
}
.personaje-card__header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.personaje-card__name { font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; }
.personaje-card__dates { font-size: 0.8rem; color: var(--text-muted); }
.personaje-card__who { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 4px; }
.personaje-card__why { font-size: 0.875rem; color: var(--text-muted); }

.personaje-card__classes { display: flex; gap: 6px; margin-top: 10px; }
.personaje-card__class-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: var(--radius-sm);
  font-size: 0.72rem; font-weight: 700; color: #0f172a;
  text-decoration: none; transition: var(--transition-fast);
}
.personaje-card__class-badge:hover { transform: scale(1.15); text-decoration: none; }

.personaje-card__details { padding: 12px 0 0; font-size: 0.875rem; color: var(--text-secondary); }
.personaje-card__expand {
  margin-top: 8px; background: none; border: none;
  color: var(--accent-primary); cursor: pointer; font-size: 0.84rem; font-weight: 600;
  padding: 0;
}
.personaje-card__expand:hover { text-decoration: underline; }

/* ────────────────────────────────────────────────────────────
   13. Timeline
   ──────────────────────────────────────────────────────────── */

.timeline-container { position: relative; padding: 16px 0; }
.timeline-line {
  position: absolute; left: 20px; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}

.timeline-event {
  position: relative; padding-left: 52px; margin-bottom: 24px;
}
.timeline-event__dot {
  position: absolute; left: 14px; top: 6px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-primary); border: 3px solid var(--bg-primary);
}
.timeline-event__year {
  font-family: 'Space Grotesk', sans-serif; font-size: 0.8rem;
  font-weight: 700; color: var(--accent-primary); margin-bottom: 2px;
}
.timeline-event__title {
  font-family: 'Space Grotesk', sans-serif; font-size: 1rem;
  font-weight: 600; color: var(--text-primary); margin-bottom: 4px;
}
.timeline-event__desc { font-size: 0.875rem; color: var(--text-secondary); line-height: 1.6; }

/* ────────────────────────────────────────────────────────────
   14. Wiki
   ──────────────────────────────────────────────────────────── */

.wiki-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 16px; }

.wiki-card {
  padding: 16px; background: var(--bg-secondary);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: pointer; transition: var(--transition-base);
  text-decoration: none; color: var(--text-primary);
  display: block;
}
.wiki-card:hover { border-color: var(--accent-wiki); transform: translateY(-2px); box-shadow: var(--shadow-md); text-decoration: none; }
.wiki-card__title { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.wiki-card__preview { font-size: 0.825rem; color: var(--text-muted); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.wiki-entry { padding: 0 0 32px; }
.wiki-entry__back {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.84rem; color: var(--text-muted); text-decoration: none;
  margin-bottom: 16px;
}
.wiki-entry__back:hover { color: var(--accent-wiki); text-decoration: none; }

/* ────────────────────────────────────────────────────────────
   15. Search Results Page
   ──────────────────────────────────────────────────────────── */

.search-empty { color: var(--text-muted); font-style: italic; padding: 32px 0; text-align: center; }
.search-query { margin-bottom: 24px; color: var(--text-secondary); }
.search-query strong { color: var(--text-primary); }

.search-result {
  display: block; padding: 14px 16px; margin-bottom: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none;
  color: var(--text-primary); transition: var(--transition-fast);
}
.search-result:hover { border-color: var(--accent-primary); text-decoration: none; }
.search-result__header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.search-result__badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 0.7rem; font-weight: 600; color: #0f172a;
}
.search-result__title { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 0.95rem; }
.search-result__snippet { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; }

/* ────────────────────────────────────────────────────────────
   16. Cross-ref & Tooltip
   ──────────────────────────────────────────────────────────── */

.cross-ref {
  border-bottom: 1px dashed var(--accent-primary); cursor: help;
  transition: var(--transition-fast);
}
.cross-ref:hover { background: rgba(245, 158, 11, 0.1); }

.tooltip {
  display: none; position: fixed; z-index: 300;
  max-width: 320px; padding: 14px 16px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xl);
}
.tooltip.active { display: block; }
.tooltip__header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tooltip__title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.95rem; }
.tooltip__badge {
  display: inline-block; padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 0.65rem; font-weight: 600; background: var(--accent-primary); color: #0f172a;
}
.tooltip__body { font-size: 0.84rem; color: var(--text-secondary); line-height: 1.6; }
.tooltip__footer { margin-top: 8px; }
.tooltip__link { font-size: 0.8rem; font-weight: 600; color: var(--accent-primary); }

/* ────────────────────────────────────────────────────────────
   17. Loading & Error
   ──────────────────────────────────────────────────────────── */

.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 64px 0; gap: 16px; }
.loading__spinner {
  width: 36px; height: 36px; border: 3px solid var(--border);
  border-top-color: var(--accent-primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading p { color: var(--text-muted); font-size: 0.875rem; }

.error-page { text-align: center; padding: 64px 0; }
.error-page h2 { margin-bottom: 8px; }
.error-page p { color: var(--text-muted); }

/* Coming Soon */
.coming-soon-placeholder {
  text-align: center; padding: 64px 0;
}
.coming-soon-placeholder__icon { color: var(--text-muted); margin-bottom: 16px; }
.coming-soon-placeholder h2 { font-size: 1.25rem; margin-bottom: 8px; }
.coming-soon-placeholder p { color: var(--text-muted); }

/* ────────────────────────────────────────────────────────────
   18. Scrollbar
   ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ────────────────────────────────────────────────────────────
   19. Responsive
   ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-open .sidebar-backdrop { display: block; }
  .main { margin-left: 0; }
  .landing-title { font-size: 2rem; }
  .pillar-grid { grid-template-columns: 1fr; }
  .landing-grid { grid-template-columns: 1fr 1fr; }
  .content { padding: 20px 16px 48px; }
  .cap-header { padding: 16px 0 12px; }
  .cap-header__badge { width: 40px; height: 40px; font-size: 1rem; }
  .cap-header__title { font-size: 1.25rem; }
  .prev-next { flex-direction: column; }
  .prev-next__link { max-width: 100%; }
  .logo-text { display: none; }
}

@media (max-width: 480px) {
  .landing-grid { grid-template-columns: 1fr; }
  .wiki-grid { grid-template-columns: 1fr; }
  .tabs-bar { gap: 0; }
  .tab { padding: 8px 10px; font-size: 0.78rem; }
}
