/*
 * Cube Student · canonical sidebar — shared visual rules
 *
 * Per-page CSS still controls the sidebar's gradient, brand block, and
 * footer row. This stylesheet adds only the cross-page behavior the
 * canonical sidebar needs:
 *   1. A hover/focus tooltip for collapsed-state nav items, driven by
 *      data-tooltip set by cube-student-canonical-sidebar.js. The tooltip
 *      is rendered as #kGlobalTooltip / #kGlobalTooltipArrow elements
 *      attached directly to <body> by cube-student-shell.js — same DOM
 *      pattern Tetrahedron uses (tetra-shell-v2.css / tetra-shell-v2.js).
 *      We mirror Tetra's styles here so the look matches across portals.
 *   2. A safe collapsed-state alignment for nav anchors so labels can
 *      disappear without the row shifting.
 *
 * Earlier versions of this stylesheet shipped a ::after pseudo-tooltip
 * positioned absolutely inside the sidebar. That tooltip clipped behind
 * sibling cards/topbars whenever an ancestor created a new stacking
 * context (transform/filter/will-change) or set overflow:hidden, no
 * matter the z-index. Switching to the body-attached, position:fixed
 * #kGlobalTooltip pattern with z-index:2147483647 makes the tooltip
 * always sit above every other portal surface.
 *
 * Several Cube Student pages still carry the legacy `body.sidebar-collapsed
 * .nav a:hover::after { content: attr(data-tooltip); ... }` block in their
 * per-page <style>. Without an explicit defuser, that pseudo would render
 * a second grey/black tooltip alongside the purple #kGlobalTooltip and
 * confuse the visual. The broader defuser below covers every legacy
 * shape we have shipped on Cube Student so a single canonical tooltip
 * is the only thing the user sees.
 */

body.sidebar-collapsed .sidebar .nav a {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
  position: relative;
}

body.sidebar-collapsed .sidebar {
  overflow: visible;
}

/* ===== Defuse every legacy sidebar pseudo-tooltip on Cube Student =====
   The selectors below cover all variants that have shipped:
     .sidebar .nav a[data-tooltip]::before|::after        (attribute-keyed)
     .nav     a[data-tooltip]::before|::after             (no .sidebar prefix)
     .sidebar .nav a:hover::before|::after                (hover-keyed)
     body.sidebar-collapsed .sidebar .nav a:hover::*      (scoped to collapsed)
     body.sidebar-collapsed .nav a:hover::*               (collapsed, no .sidebar)
   We deliberately do not defuse `.card-cta:hover::after` /
   `.ch-cta:hover::after` / `.node-cta:hover::after` — those are page-content
   arrow animations, not sidebar tooltips. */
.sidebar .nav a[data-tooltip]::before,
.sidebar .nav a[data-tooltip]::after,
.nav a[data-tooltip]::before,
.nav a[data-tooltip]::after,
.sidebar .nav a:hover::before,
.sidebar .nav a:hover::after,
body.sidebar-collapsed .sidebar .nav a:hover::before,
body.sidebar-collapsed .sidebar .nav a:hover::after,
body.sidebar-collapsed .nav a:hover::before,
body.sidebar-collapsed .nav a:hover::after {
  content: none !important;
  display: none !important;
}

/* ===== Global tooltip (Cube — visually matches Tetrahedron) =====
   The protective properties (position, z-index, background, color,
   pointer-events) carry !important so per-page styles can never push
   the tooltip behind other layout layers or repaint it in the wrong
   palette. JS only sets `left` / `top` inline at hover-time. */
#kGlobalTooltip {
  position: fixed !important;
  left: 0;
  top: 0;
  transform: translate3d(0, 0, 0);
  z-index: 2147483647 !important;
  pointer-events: none !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity .14s ease, visibility .14s ease;
  padding: 10px 14px;
  border-radius: 14px;
  white-space: nowrap;
  color: #fff !important;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  background: rgba(75, 42, 173, .72) !important;
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 14px 40px rgba(20, 10, 60, .30);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#kGlobalTooltip.is-visible {
  opacity: 1;
  visibility: visible;
}

#kGlobalTooltipArrow {
  position: fixed !important;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  transform: translate3d(0, 0, 0) rotate(45deg);
  z-index: 2147483646 !important;
  pointer-events: none !important;
  opacity: 0;
  visibility: hidden;
  background: rgba(75, 42, 173, .72) !important;
  border-left: 1px solid rgba(255, 255, 255, .18);
  border-top: 1px solid rgba(255, 255, 255, .18);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

#kGlobalTooltipArrow.is-visible {
  opacity: 1;
  visibility: visible;
}


/* Force Cube sidebar tooltip above every layout layer. */
body #kGlobalTooltip,
html body #kGlobalTooltip{
  position:fixed !important;
  z-index:2147483647 !important;
  isolation:isolate;
  color:#fff !important;
  background:rgba(75,42,173,.88) !important;
}

body #kGlobalTooltipArrow,
html body #kGlobalTooltipArrow{
  position:fixed !important;
  z-index:2147483646 !important;
  background:rgba(75,42,173,.88) !important;
}

/* ── Guide slot face ─────────────────────────────────────────────────────────
 * The last nav item carries the chosen philosopher's face (kairos-guides.js
 * rig) instead of a generic glyph, ringed in that guide's accent color
 * (--guide-accent, set inline by cube-student-canonical-sidebar.js).
 * Scoped tightly under .nav-icon: home's "Your guide" card sizes the same
 * .guide-avatar/.gf-disc classes at 72px, so these rules must win here. */
.sidebar .nav .nav-icon .nav-guide-face{display:block;width:20px;height:20px;flex-shrink:0;}
.sidebar .nav .nav-icon .nav-guide-face .guide-avatar{position:relative;display:block;width:20px;height:20px;border-radius:50%;}
.sidebar .nav .nav-icon .nav-guide-face .gf-disc{
  position:absolute;inset:0;border-radius:50%;overflow:hidden;display:block;
  background:#0b0918;
  box-shadow:0 0 0 1.5px var(--guide-accent,#7b6cf6);
}
.sidebar .nav .nav-icon .nav-guide-face .gf-disc svg{width:100%;height:100%;display:block;}
.sidebar .nav .nav-icon .nav-guide-face .gf-bg{fill:color-mix(in srgb,var(--guide-accent,#7b6cf6) 24%,#0b0918);}

/* Guide face outside the nav: any element tagged data-guide-face gets the
   same markup the nav slot uses (filled by cube-student-canonical-sidebar.js).
   Pages set --guide-size; the ring color rides on --guide-accent, which the
   script writes inline per guide. */
[data-guide-face]{display:inline-block;width:var(--guide-size,28px);height:var(--guide-size,28px);flex-shrink:0;vertical-align:middle;}
[data-guide-face] .nav-guide-face{display:block;width:100%;height:100%;}
[data-guide-face] .guide-avatar{position:relative;display:block;width:100%;height:100%;border-radius:50%;}
[data-guide-face] .gf-disc{position:absolute;inset:0;border-radius:50%;overflow:hidden;display:block;background:#0b0918;
  box-shadow:0 0 0 1.5px var(--guide-accent,#7b6cf6);}
[data-guide-face] .gf-disc svg{width:100%;height:100%;display:block;}
[data-guide-face] .gf-bg{fill:color-mix(in srgb,var(--guide-accent,#7b6cf6) 24%,#0b0918);}
