/* ═══════════════════════════════════════════════════════
   HubFlow index.html — persistent shell grid (desktop sidebar column)
   ═══════════════════════════════════════════════════════ */
html, body { height: 100%; height: 100dvh; overflow: hidden; }
body { max-height: 100dvh; }
body > .shell { flex: 1 1 auto; min-height: 0; width: 100%; }

.shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.shell > .sidebar {
  position: static;
  inset: auto;
  width: auto;
  transform: none;
  box-shadow: none;
  height: 100%;
}
.navigation-launcher {
  display: none;
  position: fixed;
  top: var(--lp-navbtn-offset-top);
  left: var(--lp-navbtn-offset-left);
  z-index: var(--lp-navbtn-z);
  font-size: 1rem;
}
.nav-mode-toggle {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 1rem;
  opacity: 0.6;
  transition: opacity var(--lp-duration-fast, 150ms) var(--lp-ease);
}
.nav-mode-toggle:hover { opacity: 1; }
.sb-item .sb-spine { display: none; }
.sb-item.active .sb-spine { display: none; }

/* ═══════════════════════════════════════════════════════
   HubFlow — Off-canvas sidebar + footer for exercise/guide pages
   Ported from index.html's floating-nav-mode sidebar so exercise
   pages get the same navigation drawer, always off-canvas (no
   persistent desktop column here — these pages don't have the
   .shell grid index.html uses).
   ═══════════════════════════════════════════════════════ */

.sidebar-scrim {
  position: fixed; inset: 0; z-index: 39;
  background: color-mix(in srgb, var(--lp-ink) 45%, transparent);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 320ms cubic-bezier(0.22, 0.9, 0.36, 1), visibility 320ms;
}
.sidebar-scrim.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.sidebar {
  display: flex; flex-direction: column; height: 100%; min-height: 0;
  background: var(--lp-bg-paper); border-right: 1.5px solid var(--lp-border);
  padding: 22px 14px 16px; box-sizing: border-box;
  position: fixed; inset: 0 auto 0 0; z-index: 40;
  width: min(232px, 86vw);
  transform: translate3d(-100%, 0, 0);
  transition: transform 320ms cubic-bezier(0.22, 0.9, 0.36, 1);
  box-shadow: var(--lp-shadow-md);
  backface-visibility: hidden;
}
.sidebar.is-open { transform: translate3d(0, 0, 0); }

.sb-brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 16px; border-bottom: 1px solid var(--lp-border); }
.sb-brand > div { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.sb-brand .nav-mode-toggle { flex-shrink: 0; margin-left: auto; }
.sb-mark { width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center; border-radius: 50%; background: var(--lp-accent); color: var(--lp-ink-inverse); font-size: 1.05rem; font-weight: 700; letter-spacing: -0.03em; box-shadow: 0 4px 14px color-mix(in srgb, var(--lp-accent) 22%, transparent); }
.sb-brand h1 { font-family: var(--lp-font-display); font-weight: 500; font-size: 18px; line-height: 1; }
.sb-brand .sb-tag { font-size: 10px; color: var(--lp-muted); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-top: 2px; }

.sb-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; margin-top: 14px; padding: 4px; }
.sidebar-footer { display: grid; gap: 2px; padding: 12px 0 0; border-top: 1px solid var(--lp-border); margin-top: auto; }

.sb-item {
  --spine: var(--lp-accent);
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: none; background: transparent; cursor: pointer;
  border-radius: 10px; padding: 10px 12px; min-height: 44px;
  font-family: var(--lp-font-body); font-size: 0.82rem; font-weight: 500;
  color: var(--lp-ink); text-decoration: none; box-sizing: border-box;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.sb-item:hover { background: var(--lp-surface); color: var(--lp-ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sb-item:active { transform: scale(0.98); }
.sb-item:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.sb-item .sb-icon { width: 20px; height: 20px; flex: 0 0 20px; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 400; color: var(--spine, currentColor); }
.sb-item .sb-icon .lp-nav-svg { width: 18px; height: 18px; display: block; }
.lp-icon-btn .lp-nav-svg { width: 20px; height: 20px; display: block; }
.sb-item .sb-label { font-size: inherit; font-weight: inherit; padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
[data-theme="dark"] .sb-item:hover:not(.active) {
  background: var(--lp-surface);
  color: var(--lp-ink);
}
[data-theme="dark"] .sidebar-footer .sb-icon {
  color: var(--lp-accent-text);
}
.sb-item.v { --spine: var(--lp-cat-purple); }
.sb-item.p { --spine: var(--lp-cat-blue); }
.sb-item.g { --spine: var(--lp-cat-amber); }
.sb-item.a { --spine: var(--lp-cat-teal); }
.sb-item.r { --spine: var(--lp-cat-green); }
.sb-item.path { --spine: var(--lp-accent); }

/* Agrupa módulos temáticos — en mobile colapsable; desktop: lista plana */
.sb-nav-group { display: flex; flex-direction: column; gap: 3px; }
.sb-nav-group__toggle {
  --spine: var(--lp-accent);
  display: none;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  font-family: var(--lp-font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--lp-ink);
  transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.sb-nav-group__toggle:hover { background: var(--lp-surface); color: var(--lp-ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.sb-nav-group__toggle:active { transform: scale(0.98); }
.sb-nav-group__toggle:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.sb-nav-group__toggle .sb-icon { color: var(--spine, currentColor); }
.sb-nav-group__chev {
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
  color: var(--lp-muted);
  transition: transform 0.2s var(--lp-ease);
}
.sb-nav-group__items { display: flex; flex-direction: column; gap: 3px; }

@media (min-width: 861px) {
  .sb-nav-group { display: contents; }
  .sb-nav-group__toggle { display: none !important; }
  .sb-nav-group__items { display: contents; }
}

/* Close button inside brand row */
.nav-mode-toggle {
  flex-shrink: 0; font-size: 1rem; opacity: 0.6;
  transition: opacity var(--lp-duration-fast, 150ms) var(--lp-ease);
}
.nav-mode-toggle:hover { opacity: 1; }

/* ─── EXERCISE PAGE FOOTER ─── */
.exercise-foot {
  position: relative; z-index: 1;
  width: 100%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px clamp(16px, 3vw, 34px);
  border-top: 1.5px solid var(--lp-border);
  background: var(--lp-bg);
  margin-top: auto;
}
.foot-meta { font-family: var(--lp-font-mono); font-size: 9px; font-weight: 700; color: var(--lp-muted); letter-spacing: .08em; text-transform: uppercase; }

@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-scrim { transition: none; }
}

/* ─── PERSISTENT MODE (desktop + sidebar mode) ─── */
.sidebar.is-persistent {
  transform: translateX(0);
  box-shadow: none;
  border-right: 1.5px solid var(--lp-border);
}
body.has-sidebar {
  padding-left: 232px;
}

@media (max-width: 860px) {
  body.has-sidebar { padding-left: 0; }

  .shell { grid-template-columns: 1fr; }
  .navigation-launcher {
    display: flex;
    top: calc(var(--lp-navbtn-offset-top-compact) + env(safe-area-inset-top, 0px));
    left: var(--lp-navbtn-offset-left);
  }
  .shell > .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    width: min(232px, 86vw);
    transform: translate3d(-100%, 0, 0);
    transition: transform 320ms cubic-bezier(0.22, 0.9, 0.36, 1);
    box-shadow: var(--lp-shadow-md);
    backface-visibility: hidden;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-sizing: border-box;
  }
  .shell > .sidebar.is-open { transform: translate3d(0, 0, 0); }

  .sidebar {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-top: max(22px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .sb-brand { flex-shrink: 0; }
  .sidebar-footer { flex-shrink: 0; margin-top: 0; }
  .sb-nav {
    flex: 1 1 auto;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  .sb-nav:not(.is-scroll-end)::after {
    content: '';
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    display: block;
    height: 18px;
    margin-top: -18px;
    pointer-events: none;
    background: linear-gradient(to bottom, transparent, var(--lp-bg-paper));
  }
  .sb-nav-group__toggle { display: flex; }
  .sb-nav-group__items { display: none; padding-left: 6px; }
  .sb-nav-group.is-open .sb-nav-group__items,
  .sb-nav-group:has(.sb-item.active) .sb-nav-group__items { display: flex; }
  .sb-nav-group.is-open .sb-nav-group__chev,
  .sb-nav-group:has(.sb-item.active) .sb-nav-group__chev { transform: rotate(90deg); }
  .sb-nav-group.is-open .sb-nav-group__toggle,
  .sb-nav-group:has(.sb-item.active) .sb-nav-group__toggle {
    color: var(--lp-accent-text);
    font-weight: 600;
  }
  .sb-item[data-target="guides"] { display: none; }
}

/* ─── Depth banner (toast — bottom center, manual dismiss) ─── */
.depth-banner {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 50;
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: 6px; padding: 10px 20px;
  background: color-mix(in srgb, var(--lp-ink) 92%, var(--lp-surface));
  border: 1px solid color-mix(in srgb, var(--lp-ink) 60%, transparent);
  border-radius: var(--lp-radius-full);
  font-size: .72rem; font-weight: 500; color: var(--lp-ink-inverse);
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  animation: depthSlideUp .4s var(--lp-ease);
  transition: opacity .6s ease, transform .6s ease;
}
[data-theme="dark"] .depth-banner {
  background: var(--lp-surface-raised);
  border-color: var(--lp-border-strong);
  color: var(--lp-ink);
}
body.has-sidebar .depth-banner {
  left: calc(232px + (100% - 232px) / 2);
}
.depth-banner strong { color: var(--lp-ink-inverse); font-weight: 700; }
[data-theme="dark"] .depth-banner strong { color: var(--lp-ink); }
.depth-banner__sep { opacity: .5; }
.depth-banner__battle {
  background: rgba(255,255,255,.12);
  color: #fff; font-weight: 700;
  padding: 2px 8px; border-radius: 4px; font-size: .65rem;
}
[data-theme="dark"] .depth-banner__battle {
  background: color-mix(in srgb, var(--lp-cat-teal) 22%, transparent);
  color: var(--lp-cat-teal);
}
.depth-banner__close {
  margin-left: 6px; background: none; border: none; color: var(--lp-ink-inverse);
  font-size: 1.1rem; line-height: 1; cursor: pointer; opacity: .6;
  padding: 4px 6px; border-radius: 4px;
  transition: opacity .2s, background .2s;
}
[data-theme="dark"] .depth-banner__close { color: var(--lp-muted); }
.depth-banner__close:hover { opacity: 1; background: rgba(255,255,255,.12); }
[data-theme="dark"] .depth-banner__close:hover { background: rgba(255,255,255,.06); color: var(--lp-ink); }
.depth-banner__close:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }
.depth-banner--fade { opacity: 0; transform: translateX(-50%) translateY(16px); pointer-events: none; }
@keyframes depthSlideUp { from { opacity: 0; transform: translateX(-50%) translateY(20px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .depth-banner { animation: none; }
  .depth-banner--fade { transition: opacity .3s; transform: translateX(-50%); }
}

/* ─── Depth bell (re-show toast) ─── */
.depth-bell {
  background: none; border: none; cursor: pointer;
  font-size: .65rem; line-height: 1; padding: 0; margin: 0;
  opacity: .5; transition: opacity .2s, transform .2s;
}
.depth-bell:hover { opacity: 1; transform: scale(1.15); }
.depth-bell:focus-visible { outline: 2px solid var(--lp-accent); outline-offset: 2px; }

/* En mobile el footer de firma y el sistema de toast/campana de profundidad
   de módulo se ocultan — son ruido secundario en pantallas chicas y el resto
   de las apps no tiene equivalente en su vista mobile. */
@media (max-width: 860px) {
  .exercise-foot,
  .depth-banner,
  .depth-bell { display: none; }
}
