/* ============================================================
   Banco de Protocolos — Mobile-first, colores corporativos
   ============================================================ */

:root {
  --bg:       #060606;
  --bg2:      #0f0f0f;
  --accent:   #FF6B00;
  --accent2:  #FF8C3A;
  --text:     #ffffff;
  --muted:    #94a3b8;
  --card-bg:  rgba(255,255,255,0.04);
  --card-bd:  rgba(255,255,255,0.08);
  --radius:   18px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

/* ---- VIEWS ---- */
.view { display: none; min-height: 100vh; flex-direction: column; }
.view.active { display: flex; }

.hidden { display: none !important; }

/* ---- TOPBAR ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(6,6,6,0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 56px;
}

.topbar-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.03em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  padding: 0 8px;
}

.topbar-counter {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.2s;
  white-space: nowrap;
}
.btn-back:hover { color: var(--text); }

.btn-library {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 10px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-library:hover { background: rgba(255,107,0,0.12); color: var(--accent); border-color: rgba(255,107,0,0.3); }

/* ============================================================
   HOME VIEW
   ============================================================ */
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 32px;
  gap: 0;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.home-heading {
  margin-bottom: 28px;
}

.home-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.home-question {
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.home-sub {
  font-size: 0.95rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ---- CATEGORIAS ---- */
.categorias {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: var(--radius);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.cat-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--cat-color, var(--accent));
  border-radius: 0 4px 4px 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.cat-btn:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.14);
  transform: translateX(2px);
}
.cat-btn:hover::before { opacity: 1; }

.cat-btn:active { transform: scale(0.98); }

.cat-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 40px;
  text-align: center;
}

.cat-texto {
  flex: 1;
  min-width: 0;
}

.cat-titulo {
  font-size: 0.97rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 2px;
}

.cat-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.3;
}

.cat-arrow {
  color: var(--muted);
  flex-shrink: 0;
  opacity: 0.5;
}

.cat-count {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--cat-color, var(--accent));
  background: rgba(255,107,0,0.1);
  border-radius: 999px;
  padding: 2px 8px;
  flex-shrink: 0;
}

.btn-ver-todos {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: none;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ver-todos:hover {
  border-color: rgba(255,107,0,0.4);
  color: var(--accent);
  background: rgba(255,107,0,0.06);
}

/* ============================================================
   CARDS VIEW
   ============================================================ */
.cards-area {
  flex: 1;
  display: flex;
  align-items: stretch;
  padding: 16px;
  overflow: hidden;
}

.card-wrapper {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

/* ---- PROTOCOL CARD ---- */
.proto-card {
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 22px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  min-height: 420px;
  position: relative;
  overflow: hidden;
  animation: cardIn 0.25s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.proto-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--cat-color, var(--accent));
  border-radius: 22px 22px 0 0;
}

.proto-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.proto-bloque {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cat-color, var(--accent));
}

.proto-codigo {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 8px;
  padding: 3px 8px;
  white-space: nowrap;
}

.proto-titulo {
  font-size: clamp(1.3rem, 5vw, 1.7rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.proto-objetivo {
  font-size: 0.93rem;
  color: var(--muted);
  line-height: 1.6;
  flex: 1;
}

/* ---- Badge tipo: EN EL PUESTO / PARA PENSAR ---- */
.badge-tipo {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  border-radius: 999px;
  padding: 5px 12px;
  width: fit-content;
}

.badge-puesto {
  background: rgba(255,107,0,0.12);
  color: #FF6B00;
  border: 1px solid rgba(255,107,0,0.3);
}

.badge-reflexion {
  background: rgba(139,92,246,0.12);
  color: #a78bfa;
  border: 1px solid rgba(139,92,246,0.3);
}

/* ---- Visual SVG ilustración ---- */
.proto-visual-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  min-height: 70px;
}

.proto-visual {
  width: 100%;
  max-width: 240px;
  height: auto;
}

/* ---- Frase clave / quote ---- */
.proto-quote {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--card-bd);
  border-left: 3px solid var(--cat-color, var(--accent));
  border-radius: 12px;
  padding: 12px 14px;
  flex: 1;
}

.quote-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.quote-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(255,255,255,0.75);
  font-style: italic;
  margin: 0;
}

/* ---- Stats (duración, dificultad) ---- */
.proto-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card-stat {
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-bd);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---- Carta "Ver más" ---- */
.card-ver-mas {
  justify-content: center;
}

.ver-mas-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  flex: 1;
  padding: 20px 0;
}

.ver-mas-num {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}

.ver-mas-texto {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.ver-mas-sub {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  max-width: 240px;
}

/* dot especial para "ver más" */
.dot.dot-more {
  width: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
}

.btn-ver-completo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: auto;
}
.btn-ver-completo:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-ver-completo:active { transform: scale(0.98); }

/* ---- NAVIGATION ---- */
.cards-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}
.nav-btn:hover { background: rgba(255,107,0,0.12); border-color: rgba(255,107,0,0.3); color: var(--accent); }
.nav-btn:disabled { opacity: 0.3; cursor: default; pointer-events: none; }

.nav-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: all 0.2s;
  cursor: pointer;
}
.dot.active {
  width: 20px;
  border-radius: 3px;
  background: var(--accent);
}

/* ============================================================
   LIBRARY VIEW
   ============================================================ */
.library-search {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  top: 56px;
  z-index: 50;
  background: var(--bg);
}

.library-search input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.library-search input:focus {
  border-color: rgba(255,107,0,0.5);
}
.library-search input::placeholder { color: var(--muted); }

.library-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.library-block {
  margin-bottom: 24px;
}

.library-block-title {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  padding: 0 4px;
}

.library-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-bd);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}
.library-item:hover {
  background: rgba(255,107,0,0.06);
  border-color: rgba(255,107,0,0.2);
}

.library-item-code {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--muted);
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
  padding: 3px 7px;
  white-space: nowrap;
  min-width: 56px;
  text-align: center;
}

.library-item-title {
  flex: 1;
  font-size: 0.93rem;
  font-weight: 700;
  line-height: 1.3;
}

.library-item-arrow {
  color: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.library-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ============================================================
   MODAL — Bottom sheet (protocolo completo)
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
}

.modal.hidden { display: none; }

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  background: #111111;
  border-radius: 24px 24px 0 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 12px auto 8px;
  flex-shrink: 0;
}

.modal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  padding: 12px 20px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.btn-modal-close {
  width: 100%;
  padding: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-modal-close:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* ---- Modal content ---- */
.modal-proto-header {
  padding: 16px 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 20px;
}

.modal-proto-bloque {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.modal-proto-titulo {
  font-size: clamp(1.2rem, 5vw, 1.6rem);
  font-weight: 900;
  line-height: 1.15;
  margin-bottom: 12px;
}

.modal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-chip {
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--card-bd);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.modal-section-text {
  font-size: 0.93rem;
  line-height: 1.7;
  color: rgba(255,255,255,0.85);
}

.modal-section-text p {
  margin: 0 0 12px;
}
.modal-section-text p:last-child { margin-bottom: 0; }

.modal-highlight {
  background: rgba(255,107,0,0.08);
  border: 1px solid rgba(255,107,0,0.2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: rgba(255,255,255,0.85);
  margin-top: 8px;
}

/* ============================================================
   UTILITIES
   ============================================================ */
@media (max-width: 400px) {
  .cat-btn { padding: 14px 14px; }
  .cat-emoji { font-size: 1.3rem; width: 32px; }
  .cat-titulo { font-size: 0.9rem; }
}

@media (min-width: 600px) {
  .home-body { padding: 32px 24px; }
  .proto-card { padding: 32px; }
  .cards-area { padding: 20px 24px; }
}

/* Scrollbar fina */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
