/* ============================================
   THORIUMAI — Global Navigation System
   Universal reachability layer
   ============================================ */

/* ── Global Nav Bar (non-hub pages) ── */
.gnav {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 56px;
  background: var(--near-black);
  border-right: 1px solid var(--border-mid);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0;
  z-index: 9900;
  transition: width 0.2s ease;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.4);
}

.gnav-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--white);
  background: var(--accent);
  border-radius: 7px;
  text-decoration: none;
  margin-bottom: 20px;
  transition: transform 0.15s;
  flex-shrink: 0;
}

.gnav-logo:hover { transform: scale(1.08); }

.gnav-items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  width: 100%;
  padding: 0 6px;
}

.gnav-items::-webkit-scrollbar { display: none; }

.gnav-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  flex-shrink: 0;
  text-decoration: none;
}

.gnav-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gnav-btn:hover {
  background: rgba(255,255,255,0.04);
  color: var(--off-white);
}

.gnav-btn.active {
  background: rgba(232, 64, 28, 0.12);
  color: var(--accent);
}

.gnav-btn.active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.gnav-tip {
  display: none;
  position: absolute;
  left: 48px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--dark);
  border: 1px solid var(--border-mid);
  padding: 4px 10px;
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--off-white);
  white-space: nowrap;
  border-radius: 5px;
  pointer-events: none;
  z-index: 500;
}

.gnav-btn:hover .gnav-tip { display: block; }

.gnav-sep {
  width: 22px;
  height: 1px;
  background: var(--border);
  margin: 6px 0;
  flex-shrink: 0;
}

.gnav-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
  width: 100%;
  padding-left: 6px;
  padding-right: 6px;
}

.gnav-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--off-white);
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.15s;
  overflow: hidden;
  flex-shrink: 0;
}

.gnav-avatar:hover { border-color: var(--accent); }
.gnav-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

/* Push content for gnav on non-hub pages */
body.has-gnav {
  padding-left: 56px;
}

body.has-gnav .ticker-bar {
  margin-left: -56px;
  padding-left: 56px;
  width: calc(100% + 56px);
}

body.has-gnav .nav {
  position: sticky;
  top: 32px;
}

/* ── Command Palette ── */
.cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
}

.cmd-overlay.open { display: flex; }

.cmd-palette {
  width: 580px;
  max-width: 92vw;
  max-height: 70vh;
  background: var(--near-black);
  border: 1px solid var(--border-mid);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03);
  animation: cmd-enter 0.15s ease-out;
}

@keyframes cmd-enter {
  from { opacity: 0; transform: translateY(-12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cmd-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.cmd-input-wrap svg {
  width: 18px;
  height: 18px;
  stroke: var(--muted);
  fill: none;
  stroke-width: 2;
  flex-shrink: 0;
}

.cmd-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--off-white);
  font-family: var(--sans);
  font-size: 0.95rem;
  caret-color: var(--accent);
}

.cmd-input::placeholder { color: var(--muted); }

.cmd-shortcut-hint {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
  background: var(--dark);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.cmd-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-mid) transparent;
}

.cmd-section {
  margin-bottom: 4px;
}

.cmd-section-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 12px 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
  color: inherit;
}

.cmd-item:hover,
.cmd-item.cmd-active {
  background: rgba(255,255,255,0.04);
}

.cmd-item.cmd-active {
  background: rgba(232, 64, 28, 0.08);
}

.cmd-item-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  border: 1px solid var(--border);
  border-radius: 7px;
  flex-shrink: 0;
}

.cmd-item-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--mid);
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cmd-item.cmd-active .cmd-item-icon svg,
.cmd-item:hover .cmd-item-icon svg {
  stroke: var(--accent);
}

.cmd-item-text {
  flex: 1;
  min-width: 0;
}

.cmd-item-label {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--off-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-item-desc {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}

.cmd-item-shortcut {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--muted);
  background: var(--dark);
  padding: 2px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.cmd-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--muted);
}

.cmd-footer-key {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cmd-footer-key kbd {
  background: var(--dark);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 0.58rem;
}

/* Search results in command palette */
.cmd-search-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.cmd-search-result:hover {
  background: rgba(255,255,255,0.04);
}

.cmd-search-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--off-white);
  flex-shrink: 0;
}

.cmd-empty {
  text-align: center;
  padding: 32px 16px;
  font-family: var(--sans);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── Mobile: Bottom Control Bar ── */
@media (max-width: 768px) {
  .gnav {
    width: 100%;
    height: 52px;
    flex-direction: row;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 0 8px;
    gap: 0;
  }

  .gnav-logo {
    margin-bottom: 0;
    margin-right: 8px;
    width: 28px;
    height: 28px;
    font-size: 0.55rem;
  }

  .gnav-items {
    flex-direction: row;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0;
  }

  .gnav-btn {
    width: 36px;
    height: 36px;
  }

  .gnav-btn svg {
    width: 16px;
    height: 16px;
  }

  .gnav-btn.active::before {
    left: 50%;
    top: -6px;
    transform: translateX(-50%);
    width: 16px;
    height: 2px;
  }

  .gnav-tip { display: none !important; }

  .gnav-sep {
    width: 1px;
    height: 20px;
    margin: 0 4px;
  }

  .gnav-bottom {
    flex-direction: row;
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 0 0 0 8px;
    margin-top: 0;
    margin-left: auto;
    gap: 4px;
  }

  body.has-gnav {
    padding-left: 0;
    padding-bottom: 52px;
  }

  body.has-gnav .ticker-bar {
    margin-left: 0;
    padding-left: 0;
    width: 100%;
  }

  /* Command palette mobile */
  .cmd-overlay { padding-top: 4vh; }

  .cmd-palette {
    max-width: 96vw;
    max-height: 80vh;
    border-radius: 12px;
  }

  .cmd-footer { display: none; }
}

/* ── Hub page overrides: hide gnav since shell-rail exists ── */
body.hub-page .gnav { display: none; }
body.hub-page { padding-left: 0; }

/* ── Landing page adjustments ── */
body.landing.has-gnav .landing-nav {
  margin-left: -56px;
  padding-left: 56px;
  width: calc(100% + 56px);
}

@media (max-width: 768px) {
  body.landing.has-gnav .landing-nav {
    margin-left: 0;
    padding-left: 0;
    width: 100%;
  }
}

/* ── Floating Command Palette Trigger ── */
.cmd-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9800;
  box-shadow: 0 4px 16px rgba(232, 64, 28, 0.3), 0 2px 4px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s, box-shadow 0.15s;
}

.cmd-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(232, 64, 28, 0.4), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.cmd-fab svg {
  width: 20px;
  height: 20px;
  stroke: #fff;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cmd-fab-hint {
  position: absolute;
  right: 52px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--dark);
  border: 1px solid var(--border-mid);
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--off-white);
  white-space: nowrap;
  border-radius: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.cmd-fab:hover .cmd-fab-hint { opacity: 1; }

@media (max-width: 768px) {
  .cmd-fab {
    bottom: 68px;
    right: 16px;
    width: 40px;
    height: 40px;
  }

  .cmd-fab-hint { display: none; }
}
