/* premium-spine.css — left-rail "field-dossier spine" navigation.
 *
 * Replaces the top header bar with a fixed left sidebar (220 px) that
 * looks like the bound edge of a leather field journal. Each nav link
 * is rendered as a horizontal "index tab" glued to the spine; the
 * active tab pushes out slightly with a colored ribbon notch.
 *
 * Layout:
 *   .nx-spine               — fixed 220px sidebar, full-height, scroll-y
 *     .nx-spine__brand      — clickable home link with mark + name
 *     .nx-spine__live       — live status panel (count / weather)
 *     .nx-spine__nav        — vertical stack of .nx-spine__link
 *     .nx-spine__foot       — theme switch + locale + JOIN cta
 *
 * The page-content shift (margin-left: 220px on main + footer) is
 * handled below. Mobile (<900 px) collapses to a 56-px icon rail; the
 * full label slides out on hover/focus via a CSS-only flyout.
 *
 * Theming: every visual property reads from the active theme tokens
 * (--bg, --panel, --ink, --accent, --rule, --font-display, etc.) so
 * the spine paints itself correctly under all 10 Phase-6 palettes.
 */

/* ── 1. Layout shift ────────────────────────────────────────────────── */

main, footer, .footer-bottom {
  margin-left: 220px;
}

@media (max-width: 900px) {
  main, footer, .footer-bottom {
    margin-left: 56px;
  }
}

@media (max-width: 480px) {
  main, footer, .footer-bottom {
    margin-left: 0;
    margin-top: 56px;       /* horizontal mobile dock */
  }
}

/* ── 2. Spine container ─────────────────────────────────────────────── */

.nx-spine {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  height: 100vh;
  z-index: 50;

  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 14px 18px;
  /* Allow the theme-switch dropdown to fly out horizontally past the
   * spine edge. Vertical scroll stays handled inside the spine for
   * tall nav lists. */
  overflow-y: auto;
  overflow-x: visible;

  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--panel, #1A1815), var(--ink, #E8D9B0) 4%) 0%,
      var(--panel, #1A1815) 35%,
      color-mix(in srgb, var(--panel, #1A1815), #000 18%) 100%);
  border-right: 1px solid var(--rule, var(--panel-edge, rgba(201, 166, 107, 0.32)));
  box-shadow:
    1px 0 0 0 color-mix(in srgb, var(--accent, #C9A66B), transparent 78%),
    8px 0 24px -8px rgba(0, 0, 0, 0.45);
  overflow-y: auto;
  overscroll-behavior: contain;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);

  /* Slim themed scrollbar. */
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent, #C9A66B), transparent 60%) transparent;
}
.nx-spine::-webkit-scrollbar { width: 4px; }
.nx-spine::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--accent, #C9A66B), transparent 60%);
  border-radius: 2px;
}

/* ── 3. Brand block ─────────────────────────────────────────────────── */

.nx-spine__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 4px 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 70%);
  text-decoration: none;
  color: var(--ink, #E8D9B0);
  font-family: var(--font-display, 'Cormorant Garamond', Georgia, serif);
  letter-spacing: 0.05em;
}
.nx-spine__mark {
  display: inline-flex;
  width: 28px; height: 28px;
  align-items: center; justify-content: center;
  border: 1px solid var(--accent, #C9A66B);
  background: color-mix(in srgb, var(--accent, #C9A66B), transparent 88%);
  color: var(--accent, #C9A66B);
  font-size: 0.78rem;
  flex: 0 0 auto;
  transition: transform 200ms ease, background 200ms ease;
}
.nx-spine__brand:hover .nx-spine__mark {
  transform: rotate(-6deg) scale(1.04);
  background: color-mix(in srgb, var(--accent, #C9A66B), transparent 75%);
}
.nx-spine__brand-text {
  display: flex; flex-direction: column;
  line-height: 1.05;
}
.nx-spine__brand-text strong {
  font-weight: var(--weight-display, 500);
  font-size: 1.05rem;
  color: var(--ink, #E8D9B0);
}
.nx-spine__brand-text small {
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: color-mix(in srgb, var(--ink, #E8D9B0), transparent 48%);
  margin-top: 2px;
}

/* ── 4. Live status panel ───────────────────────────────────────────── */

.nx-spine__live {
  padding: 10px 12px;
  background: color-mix(in srgb, var(--panel, #1A1815), #000 8%);
  border: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 70%);
  border-radius: 4px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.74rem;
  color: color-mix(in srgb, var(--ink, #E8D9B0), transparent 28%);
  letter-spacing: 0.04em;
}
.nx-spine__live-row {
  display: flex; align-items: center; gap: 6px;
}
.nx-spine__live-row + .nx-spine__live-row { margin-top: 4px; }
.nx-spine__live .live-status__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent, #C9A66B);
  box-shadow: 0 0 6px color-mix(in srgb, var(--accent, #C9A66B), transparent 30%);
  animation: nx-spine-pulse 1.6s ease-in-out infinite;
  flex: 0 0 auto;
}
.nx-spine__live .live-status__count {
  color: var(--accent, #C9A66B);
  font-weight: 600;
}
.nx-spine__live-cap {
  font-size: 0.66rem;
  color: color-mix(in srgb, var(--ink, #E8D9B0), transparent 60%);
}
.nx-spine__live-row--weather { font-size: 0.66rem; opacity: 0.78; }

@keyframes nx-spine-pulse {
  0%, 100% { opacity: 0.55; transform: scale(0.9); }
  50%      { opacity: 1;    transform: scale(1.1); }
}

/* ── 5. Nav tabs ────────────────────────────────────────────────────── */

.nx-spine__nav {
  display: flex; flex-direction: column;
  gap: 1px;
  margin-top: 4px;
}
.nx-spine__link {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 9px 14px;
  text-decoration: none;
  color: color-mix(in srgb, var(--ink, #E8D9B0), transparent 22%);
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-left: 2px solid transparent;
  transition: all 160ms ease;
}
.nx-spine__link:hover {
  color: var(--ink, #E8D9B0);
  background: color-mix(in srgb, var(--panel, #1A1815), var(--accent, #C9A66B) 6%);
  border-left-color: color-mix(in srgb, var(--accent, #C9A66B), transparent 50%);
  transform: translateX(2px);
}
.nx-spine__link.is-active {
  color: var(--accent, #C9A66B);
  background: linear-gradient(90deg,
    color-mix(in srgb, var(--accent, #C9A66B), transparent 80%) 0%,
    transparent 100%);
  border-left-color: var(--accent, #C9A66B);
  font-weight: 500;
}
.nx-spine__link.is-active::after {
  content: ''; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent, #C9A66B);
  box-shadow: 0 0 6px var(--accent, #C9A66B);
}
.nx-spine__glyph {
  display: inline-flex; width: 16px; flex: 0 0 auto;
  align-items: center; justify-content: center;
  font-size: 0.92rem;
  color: color-mix(in srgb, var(--accent, #C9A66B), transparent 35%);
  text-shadow: 0 0 8px color-mix(in srgb, var(--accent, #C9A66B), transparent 70%);
}
.nx-spine__link.is-active .nx-spine__glyph,
.nx-spine__link:hover .nx-spine__glyph {
  color: var(--accent, #C9A66B);
}

/* ── 6. Foot block (theme + locale + JOIN) ──────────────────────────── */

.nx-spine__foot {
  margin-top: auto;
  display: flex; flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 75%);
}
.nx-spine__theme-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nx-spine__theme-row [data-theme-switch] {
  display: block;
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.nx-spine__theme-row [data-nx-mute-toggle] {
  flex: 0 0 auto;
}
/* The dropdown is absolutely-positioned relative to its host. Inside
 * the spine (overflow:auto), an absolute child still gets clipped by
 * the scroll container — that hid bottom themes (solarpunk through
 * martian-survey). Promote to position:fixed so the menu escapes the
 * spine entirely and flies out to the right of the rail. */
.nx-spine .theme-switch__menu {
  position: fixed;
  left: 220px;
  bottom: 110px;
  top: auto;
  right: auto;
  min-width: 280px;
  max-height: min(70vh, 560px);
  overflow-y: auto;
  margin-left: 6px;
  z-index: 1200;
  box-shadow:
    0 12px 36px rgba(0, 0, 0, 0.55),
    0 0 0 1px color-mix(in srgb, var(--accent, #C9A66B), transparent 65%);
}
@media (max-width: 900px) {
  .nx-spine .theme-switch__menu {
    left: 56px;
    bottom: 70px;
  }
}
@media (max-width: 480px) {
  .nx-spine .theme-switch__menu {
    /* In top-dock mode, drop the menu BELOW the dock instead of right. */
    left: 8px; right: 8px;
    bottom: auto; top: 60px;
    min-width: 0;
  }
}
.nx-spine__foot .locale-switcher select {
  width: 100%;
  background: var(--panel, #1A1815);
  color: var(--ink, #E8D9B0);
  border: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 60%);
  padding: 6px 8px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  border-radius: 3px;
}
.nx-spine__join {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--accent, #C9A66B);
  color: var(--bg, #0E0F12);
  border: 1px solid color-mix(in srgb, var(--accent, #C9A66B), #000 18%);
  border-radius: 3px;
  text-decoration: none;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: transform 120ms ease, box-shadow 120ms ease;
  margin-top: 4px;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent, #C9A66B), transparent 60%);
}
.nx-spine__join:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent, #C9A66B), transparent 50%);
}
.nx-spine__join .nx-spine__glyph { color: var(--bg, #0E0F12); }

/* Discord-auth chip variant: outline, not solid — keeps the JOIN
 * cta as the primary affordance while the auth state pill sits
 * underneath it as secondary. */
.nx-spine__join--discord {
  background: color-mix(in srgb, var(--accent, #C9A66B), transparent 88%);
  color: var(--ink, #E8D9B0);
  box-shadow: none;
  font-weight: 500;
  letter-spacing: 0.08em;
  border-color: color-mix(in srgb, var(--accent, #C9A66B), transparent 50%);
}
.nx-spine__join--discord .nx-spine__glyph {
  color: var(--accent, #C9A66B);
}
.nx-spine__join--discord:hover {
  background: color-mix(in srgb, var(--accent, #C9A66B), transparent 75%);
  transform: none;
}

/* Logged-in user pill — avatar + username + [exit] link. */
.nx-spine__user {
  display: none; align-items: center; gap: 8px;
  padding: 7px 10px;
  background: color-mix(in srgb, var(--panel, #1A1815), var(--accent, #C9A66B) 4%);
  border: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 65%);
  border-radius: 3px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-size: 0.72rem;
  color: var(--accent, #C9A66B);
}
.nx-spine__user img {
  width: 18px; height: 18px; border-radius: 50%; flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--accent, #C9A66B), transparent 60%);
  background: var(--bg, #0E0F12);
}
.nx-spine__user span:not(.nx-spine__user-exit) {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nx-spine__user-exit {
  color: color-mix(in srgb, var(--ink, #E8D9B0), transparent 50%);
  font-size: 0.66rem;
  text-decoration: none;
  flex: 0 0 auto;
}
.nx-spine__user-exit:hover {
  color: var(--accent-2, var(--accent, #C9A66B));
}

@media (max-width: 900px) {
  .nx-spine__user span:not(.nx-spine__user-exit),
  .nx-spine__user-exit { display: none; }
  .nx-spine__user { padding: 4px; justify-content: center; }
}

/* ── 7. Mobile collapse (<900 px → icon rail; <480 → top dock) ──────── */

@media (max-width: 900px) {
  .nx-spine {
    width: 56px;
    padding: 14px 4px;
    gap: 8px;
  }
  .nx-spine__brand-text,
  .nx-spine__live-cap,
  .nx-spine__live-row--weather,
  .nx-spine__label,
  .nx-spine__foot .locale-switcher,
  .nx-spine__theme-row {
    display: none;
  }
  .nx-spine__brand { justify-content: center; padding: 4px 0 10px; }
  .nx-spine__live {
    padding: 6px 4px; text-align: center;
  }
  .nx-spine__link {
    justify-content: center;
    padding: 10px 6px;
  }
  .nx-spine__link .nx-spine__glyph { font-size: 1.1rem; }
  .nx-spine__join {
    padding: 10px 6px;
    justify-content: center;
  }

  /* Flyout label on hover/focus. */
  .nx-spine__link:hover .nx-spine__label,
  .nx-spine__link:focus-visible .nx-spine__label {
    display: block;
    position: absolute;
    left: calc(100% + 8px); top: 50%;
    transform: translateY(-50%);
    background: var(--panel, #1A1815);
    border: 1px solid var(--accent, #C9A66B);
    padding: 6px 10px;
    border-radius: 3px;
    white-space: nowrap;
    color: var(--ink, #E8D9B0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 480px) {
  /* Horizontal top dock. */
  .nx-spine {
    flex-direction: row;
    inset: 0 0 auto 0;
    width: auto;
    height: 56px;
    padding: 6px 8px;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--rule, rgba(201, 166, 107, 0.32));
  }
  .nx-spine__brand {
    border-bottom: none;
    padding: 0 6px;
    flex: 0 0 auto;
  }
  .nx-spine__live { display: none; }
  .nx-spine__nav {
    flex-direction: row;
    gap: 0;
  }
  .nx-spine__link {
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  .nx-spine__link.is-active {
    border-bottom-color: var(--accent, #C9A66B);
    border-left: none;
  }
  .nx-spine__foot {
    flex-direction: row;
    margin-top: 0; margin-left: auto;
    border-top: none;
    padding-top: 0;
    align-items: center;
    flex: 0 0 auto;
  }
}

/* ── 8. Hide legacy <header class="nav"> if it slips through ────────── */
.nav--legacy { display: none !important; }

/* ── 9. Hide legacy hero h1 cursor blink in non-Phase-6 themes ──────── */
.nx-spine + main .hero h1 .cursor { animation: none; }
