/* Centro de ayuda, guía inicial e impresión del manual. Usa las variables de styles.css. */

/* Barra superior: botón ¿Cómo usar? */
.topbar-right { display: flex; align-items: center; gap: 8px; }
.help-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid rgba(34, 211, 238, 0.5); background: rgba(34, 211, 238, 0.1);
  color: var(--cyan); font-weight: 700; font-size: 0.88rem; cursor: pointer; white-space: nowrap;
  transition: background-color 0.2s, transform 0.2s var(--ease);
}
.help-btn:hover { background: rgba(34, 211, 238, 0.18); transform: translateY(-1px); }
.back { white-space: nowrap; }
@media (max-width: 479px) {
  .back-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .topbar-inner { gap: 8px; }
  .topbar-right { gap: 6px; }
  .demo-badge { padding: 5px 8px; font-size: 0.66rem; letter-spacing: 0.04em; }
  .help-btn { padding: 6px 12px; font-size: 0.82rem; }
  .help-btn svg { display: none; } /* ahorra espacio en pantallas de 360–390px */
}
@media (max-width: 379px) {
  .topbar .wrap, .topbar-inner { padding-inline: 12px; }
  .back { gap: 4px; }
  .help-btn { padding: 6px 9px; }
  .demo-badge { padding: 4px 6px; font-size: 0.62rem; letter-spacing: 0.02em; }
}

/* Panel del manual: pantalla completa en celular, lateral en computadora */
dialog.help {
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; margin: 0; border-radius: 0;
  display: none; flex-direction: column; overflow: hidden; border: 0;
}
dialog.help[open] { display: flex; animation: help-in-mobile 0.3s var(--ease); }
@keyframes help-in-mobile { from { opacity: 0; transform: translateY(16px); } }
@media (min-width: 900px) {
  dialog.help {
    width: min(920px, 92vw); margin-left: auto; margin-right: 0;
    border-left: 1px solid var(--line-strong);
  }
  dialog.help[open] { animation-name: help-in-side; }
  @keyframes help-in-side { from { opacity: 0; transform: translateX(32px); } }
}
.help-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.help-kicker { color: var(--cyan); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.help-head h2 { font-size: clamp(1.15rem, 4vw, 1.45rem); margin-top: 4px; }
.help-head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.help-close {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none;
  border-radius: 12px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); cursor: pointer;
}
.help-close:hover { border-color: var(--cyan); }
@media (max-width: 479px) { #btn-help-print { display: none; } } /* imprimir es poco común en celular */

.help-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 8px; padding: 18px; }
@media (min-width: 900px) { .help-body { grid-template-columns: 220px 1fr; gap: 28px; padding: 24px 28px; } }

.help-toc { font-size: 0.9rem; }
.help-toc > p { font-weight: 700; color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; }
.help-toc ol { margin: 8px 0 12px; padding-left: 22px; display: grid; gap: 2px; color: var(--muted); }
.help-toc a { display: inline-block; padding: 5px 0; color: var(--text); text-decoration: none; }
.help-toc a:hover { color: var(--cyan); text-decoration: underline; }
@media (min-width: 900px) { .help-toc { position: sticky; top: 0; align-self: start; } }
@media (max-width: 899px) {
  .help-toc { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(5, 11, 26, 0.5); }
  .help-toc ol { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); column-gap: 24px; }
}

.help-content { display: grid; gap: 26px; max-width: 62ch; padding-bottom: 32px; }
.help-content section { scroll-margin-top: 12px; }
.help-content h3 { font-size: 1.15rem; margin-bottom: 10px; color: var(--text); }
.help-content h3:focus { outline: none; }
.help-content p, .help-content li { color: #c9d5ec; }
.help-content p + p, .help-content p + ul, .help-content ul + p, .help-content ol + p { margin-top: 10px; }
.help-content ul, .help-content ol { margin: 8px 0 0; padding-left: 22px; display: grid; gap: 6px; }
.help-content strong { color: var(--text); }
.steps { counter-reset: none; }
.steps li::marker { color: var(--cyan); font-weight: 800; }
.ui {
  display: inline-block; padding: 0 8px; border-radius: 6px; font-weight: 700; font-size: 0.92em; white-space: nowrap;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--line-strong);
}
.ui-pill { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 0.78em; font-weight: 700; color: var(--bg); background: var(--warn); }
.help-content code, .help-content kbd {
  font-family: Consolas, 'Cascadia Mono', monospace; font-size: 0.88em; padding: 1px 6px; border-radius: 5px;
  background: rgba(5, 11, 26, 0.8); border: 1px solid var(--line); color: var(--cyan);
}
.tip { padding: 10px 12px; border-left: 3px solid var(--cyan); border-radius: 0 8px 8px 0; background: rgba(34, 211, 238, 0.06); font-size: 0.93rem; }
.help-content details { border: 1px solid var(--line); border-radius: 12px; background: rgba(11, 22, 48, 0.6); }
.help-content details + details { margin-top: 8px; }
.help-content summary { padding: 12px 14px; min-height: 44px; font-weight: 650; cursor: pointer; color: var(--text); }
.help-content summary:hover { color: var(--cyan); }
.help-content details p { padding: 0 14px 14px; }
.help-limits { padding: 16px; border-radius: var(--radius); border: 1px dashed rgba(251, 191, 36, 0.5); background: rgba(251, 191, 36, 0.05); }
.help-limits h3 { color: var(--warn); }

/* Guía inicial: tarjeta flotante que no bloquea la demo */
.tour {
  position: fixed; z-index: 40; right: 16px; bottom: 16px; width: min(360px, calc(100% - 32px));
  padding: 16px 18px; border-radius: 16px; border: 1px solid rgba(34, 211, 238, 0.45);
  background: rgba(11, 22, 48, 0.97); box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.85), 0 0 40px -18px rgba(34, 211, 238, 0.6);
  animation: tour-in 0.4s var(--ease);
}
@keyframes tour-in { from { opacity: 0; transform: translateY(16px); } }
.tour-top { display: flex; align-items: center; justify-content: space-between; }
.tour-step { color: var(--cyan); font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.tour .help-close { width: 36px; height: 36px; border-radius: 10px; }
.tour h2 { font-size: 1.1rem; margin-top: 6px; }
.tour p#tour-text { margin-top: 6px; color: #c9d5ec; font-size: 0.93rem; }
.tour-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; justify-content: flex-end; }
.tour-actions .btn-quiet { margin-right: auto; }
.tour-actions [hidden] { display: none; }
@media (max-width: 479px) { .tour { right: 16px; left: 16px; width: auto; } }

/* Impresión: solo el manual, en blanco y negro legible */
@media print {
  body.printing-help > *:not(#dlg-help) { display: none !important; }
  body.printing-help { background: #fff; color: #000; }
  dialog.help[open] {
    position: static; display: block; width: auto; height: auto; max-height: none; overflow: visible;
    margin: 0; border: 0; box-shadow: none; background: #fff; color: #000; animation: none;
  }
  dialog.help::backdrop { display: none; }
  .help-head { border-bottom: 2px solid #000; background: #fff; padding: 0 0 10px; }
  .help-head-actions, .help-tour-again { display: none !important; }
  .help-body { display: block; overflow: visible; padding: 16px 0 0; }
  .help-toc { border: 1px solid #999; background: #fff; margin-bottom: 16px; }
  .help-toc a, .help-content p, .help-content li, .help-content h3, .help-content strong, .help-content summary,
  .help-kicker, .help-head h2, .help-limits h3, .help-toc > p { color: #000 !important; }
  .help-content { max-width: none; }
  .help-content section { break-inside: avoid; }
  .ui, .help-content code, .help-content kbd, .ui-pill { background: #fff; color: #000; border: 1px solid #000; }
  .tip, .help-content details, .help-limits { background: #fff; border-color: #000; }
}
