:root {
  --side-nav-bg: rgba(255, 255, 255, 0.07);
  --side-nav-border: rgba(255, 255, 255, 0.15);
  --side-nav-glow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 14px -4px rgba(0, 0, 0, 0.6), 0 0 32px -10px rgba(160, 130, 255, 0.35);
  --side-active: #b88dff;
  --side-text: #e5effa;
  --side-text-dim: #97adc4;
  --transition-fast: 140ms cubic-bezier(.4, .2, .2, 1);
  --transition-slow: 360ms cubic-bezier(.4, .2, .2, 1);
  --nav-width-collapsed: 54px;
  --nav-width-expanded: 168px; /* will be measured and overridden by JS */
  --nav-pad-l: 16px;
  --nav-pad-r: 14px;
  --nav-label-buffer: 6px; /* extra breathing room so text doesn't touch edge */
}

/* Contenedor */
.side-nav {
  position: fixed;
  top: 50%;
  left: 12px;
  transform: translateY(-50%);
  z-index: 1200;
  width: var(--nav-width-collapsed);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  /* center items vertically inside the glass container */
  gap: 6px;
  pointer-events: auto;
  transition: width 240ms ease, opacity 200ms ease;
  /* also animate opacity for hide/show */
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  background: linear-gradient(145deg, rgba(20, 22, 34, 0.78), rgba(40, 28, 58, 0.28)) var(--side-nav-bg);
  border: 1px solid var(--side-nav-border);
  border-radius: 18px;
  box-shadow: var(--side-nav-glow);
  overflow: hidden;
  /* prevent anchor box bleed when collapsed */
}

/* Hidden while scrolling (keeps hoverable so it can reappear on pointer over) */
.side-nav.nav--hidden {
  opacity: 0;
}

/* Lista */
.side-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  /* stretch items full width */
  width: 100%;
}

/* Item base */
.side-nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* centrado en ambos estados */
  gap: 10px;
  /* espacio entre dot y label cuando se expande */
  font: 600 15px/1 "Inter", system-ui, sans-serif;
  color: var(--side-text-dim);
  text-decoration: none;
  width: 100%;
  /* fill inner nav width */
  height: 42px;
  border-radius: 12px;
  letter-spacing: .5px;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
  overflow: hidden;
  transition: background var(--transition-fast), color var(--transition-fast);
  padding: 0;
  /* keep exact width without extra horizontal overflow */
  box-sizing: border-box;
}

/* Desktop default (collapsed): center the initial only */
.side-nav a .nav-initial,
.side-nav a .nav-label { pointer-events: none; white-space: nowrap; }
.side-nav a .nav-label { display: none; }
.side-nav a .nav-initial { display: inline-block; }

/* Remove legacy dot/label visibility rules; overlay handles visibility */

/* Remove left active bar pseudo */
.side-nav a::before { content: none; }

/* Hover/focus */
.side-nav a:hover,
.side-nav a:focus-visible {
  color: var(--side-text);
  background: linear-gradient(135deg, rgba(184, 141, 255, 0.28), rgba(60, 52, 110, 0.3));
}

/* Activo */
.side-nav a.active {
  color: var(--side-active);
  background: linear-gradient(135deg, rgba(184, 141, 255, 0.38), rgba(60, 52, 110, 0.42));
  box-shadow: 0 0 0 1px rgba(184, 141, 255, 0.5), 0 6px 22px -8px rgba(184, 141, 255, 0.55);
}

/* Legacy dot/left bar styles removed */

/* No pseudo-element text */
.side-nav a::after { content: none !important; }

/* Desktop hover/focus color only (initial or label depending on state) */
.side-nav a:hover,
.side-nav a:focus-visible {
  color: var(--side-text);
}

.side-nav a:hover::after,
.side-nav a:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Desktop: expand on hover/focus-within and reveal labels inline */
@media (hover: hover) and (min-width: 781px) {
  .side-nav { width: var(--nav-width-collapsed); }
  .side-nav:hover,
  .side-nav:focus-within { width: var(--nav-width-expanded); }
  /* Default (collapsed): center content, hide label */
  .side-nav a { justify-content: center; padding: 0; gap: 0; }
  .side-nav a .nav-initial { display: inline-block; }
  .side-nav a .nav-label { display: none; }
  /* Expanded state (hover/focus-within): left-align, show label, hide initial */
  .side-nav:hover a,
  .side-nav:focus-within a { justify-content: flex-start; padding: 0 var(--nav-pad-r) 0 var(--nav-pad-l); gap: 10px; }
  .side-nav:hover a .nav-label,
  .side-nav:focus-within a .nav-label { display: inline-block; color: var(--side-text); font-size: 13px; font-weight: 500; }
  .side-nav:hover a .nav-initial,
  .side-nav:focus-within a .nav-initial { display: none; }
}

/* No special expansion on touch; mobile rules below handle layout */

/* Responsive inferior */
@media (max-width: 780px) {
  /* Ensure page content isn't obscured by the fixed bottom nav */
  body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  /* Transform vertical glass pill into a bottom navigation bar */
  .side-nav {
    top: auto;
    bottom: 12px;
    left: 12px;
    right: 12px;
    transform: none;
    flex-direction: row;
    width: auto;
    padding: 10px 14px 8px;
    justify-content: space-between;
    border-radius: 22px;
  }

  .side-nav ul {
    flex-direction: row;
    width: 100%;
    gap: 4px; /* tighter gap for limited horizontal space */
  }

  .side-nav li { /* make each item take equal available width */
    flex: 1 1 0;
    display: flex;
  }

  .side-nav a {
    flex: 1 1 auto;
    width: 100%;
    height: 64px; /* larger touch target */
    min-height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    font-size: 18px; /* initial (letter) size */
    letter-spacing: .8px;
    font-weight: 600;
    padding: 0 4px;
    background: radial-gradient(circle at 50% 30%, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
    transition: background var(--transition-fast), color var(--transition-fast), transform 220ms ease;
  }

  /* Mobile layout: stack initial above label (no overlay swap) */
  .side-nav a {
    position: relative;
  }
  .side-nav a .nav-initial,
  .side-nav a .nav-label { position: static; transform: none; opacity: 1 !important; pointer-events: none; }
  /* Ensure label is visible on mobile (override base display:none) */
  .side-nav a .nav-label { display: inline-block; }
  .side-nav a .nav-initial { display: inline-block; }
  .side-nav a .nav-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .3px;
    color: var(--side-text-dim);
    margin-top: 2px;
  }

  /* Override desktop hover rule that hides the initial */
  .side-nav a:hover,
  .side-nav a:focus-visible {
    color: var(--side-text);
    background: linear-gradient(135deg, rgba(184, 141, 255, 0.38), rgba(60, 52, 110, 0.42));
  }

  .side-nav a:hover::after,
  .side-nav a:focus-visible::after {
    color: var(--side-text);
  }

  .side-nav a.active {
    color: var(--side-active);
    background: linear-gradient(135deg, rgba(184, 141, 255, 0.48), rgba(60, 52, 110, 0.52));
    box-shadow: 0 0 0 1px rgba(184, 141, 255, 0.55), 0 6px 18px -6px rgba(184, 141, 255, 0.55);
    outline: none; /* remove previous outline style */
  }

  .side-nav a.active::after {
    /* no ::after on mobile */
    color: inherit;
  }

  /* Disable width expansion interaction for mobile; keep consistent bar */
  /* no width expansion on mobile */

  /* Slight active scale for tactile feedback */
  .side-nav a:active {
    transform: scale(.95);
  }
}

/* Extra-small devices: tighten sizes */
@media (max-width: 480px) {
  .side-nav a {
    height: 58px;
    font-size: 16px;
  }
  .side-nav a::after {
    font-size: 10px;
    bottom: 5px;
  }
  .side-nav {
    padding: 8px 12px 6px;
  }
}

/* Allow smooth scroll globally if not already set */
html {
  scroll-behavior: smooth;
}

/* Scroll arrow button */
.scroll-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: 28px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #e5effa;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 180ms, transform 300ms;
  box-shadow: 0 6px 22px -8px rgba(0, 0, 0, 0.6);
}

.scroll-arrow:hover,
.scroll-arrow:focus-visible {
  background: rgba(184, 141, 255, 0.35);
  outline: none;
}

.scroll-arrow:active {
  transform: translateX(-50%) scale(.92);
}

.scroll-arrow .arrow-visual svg {
  display: block;
  stroke: currentColor;
}

@media (prefers-reduced-motion: reduce) {

  .side-nav,
  .side-nav a .nav-label,
  .scroll-arrow {
    transition: none;
  }
}