/* ==========================================================================
   TRAVERSE — Uncertain Archive Stylesheet
   Inspired by Olafur Eliasson's "Your uncertain archive"
   ========================================================================== */

:root {
  --bg-deep: #090a0f;
  --bg-glass: rgba(14, 17, 24, 0.72);
  --bg-glass-heavy: rgba(12, 14, 20, 0.90);
  --border-subtle: rgba(255, 255, 255, 0.11);
  --border-highlight: rgba(255, 255, 255, 0.32);
  --text-main: #f3f5f8;
  --text-muted: #949ba8;
  --text-dim: #5d6472;
  --accent-warm: #f59e0b;
  --accent-cyan: #38bdf8;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Space Grotesk', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* WebGL Canvas */
#canvas-container {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

#canvas-container.hovering-node {
  cursor: pointer;
}

/* Ambient Subtle Vignette */
.ambient-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(5, 6, 9, 0.65) 100%);
}

/* ==========================================================================
   TOP HUD
   ========================================================================== */

.hud-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  pointer-events: none;
  gap: 16px;
}

.brand-cluster,
.controls-cluster {
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

.back-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

.back-pill:hover {
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(-2px);
}

.title-block h1 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.title-block .subtitle {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

.stats-line {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stats-line #visible-count {
  color: var(--text-main);
  font-weight: 500;
}

.stats-line .sep {
  margin: 0 4px;
  color: var(--text-dim);
}

#active-filter-label {
  color: var(--accent-warm);
}

/* Search Box */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box .search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

#search-input {
  width: 240px;
  padding: 8px 30px 8px 34px;
  border-radius: 999px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  outline: none;
  transition: all 0.22s ease;
}

#search-input::placeholder {
  color: var(--text-dim);
}

#search-input:focus {
  width: 290px;
  border-color: var(--border-highlight);
  background: rgba(20, 24, 34, 0.88);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

.clear-btn:hover {
  color: var(--text-main);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.hud-btn.icon-only {
  padding: 8px 10px;
}

.hud-btn:hover {
  color: var(--text-main);
  border-color: var(--border-highlight);
  background: rgba(255, 255, 255, 0.08);
}

.hud-btn.active {
  color: var(--text-main);
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.14);
}

/* ==========================================================================
   LEFT TAG CLUSTER RAIL
   ========================================================================== */

.hud-tags {
  position: fixed;
  top: 84px;
  left: 24px;
  z-index: 10;
  width: 190px;
  max-height: calc(100vh - 180px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.tags-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.mono-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.tag-reset-btn {
  background: none;
  border: none;
  color: var(--accent-warm);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
  text-decoration: underline;
}

.tag-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: none;
}

.tag-list::-webkit-scrollbar {
  display: none;
}

.tag-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 11px;
  border-radius: 999px;
  background: rgba(14, 17, 24, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-muted);
  font-size: 0.76rem;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.tag-pill:hover {
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateX(3px);
}

.tag-pill.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--tag-color, var(--accent-warm));
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.18);
}

.tag-pill-left {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tag-color, #888);
  flex-shrink: 0;
}

.tag-count {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-dim);
  margin-left: 6px;
}

/* ==========================================================================
   BOTTOM HUD: MODE SWITCHER & TIMELINE
   ========================================================================== */

.hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  pointer-events: none;
  gap: 16px;
}

.mode-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  pointer-events: auto;
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  color: var(--text-main);
}

.mode-btn.active {
  background: rgba(255, 255, 255, 0.13);
  color: var(--text-main);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.mode-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.mode-btn.active .mode-dot {
  background: var(--accent-warm);
  opacity: 1;
  box-shadow: 0 0 8px var(--accent-warm);
}

.mode-btn kbd,
.nav-hints kbd {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Timeline Bar */
.timeline-bar {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  pointer-events: auto;
  overflow-x: auto;
  max-width: 52vw;
}

.year-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 2px 5px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border-radius: 4px;
}

.year-btn:hover {
  color: var(--text-main);
}

.year-btn.active {
  color: var(--accent-warm);
  font-weight: 600;
}

.year-spark {
  width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.22);
  transition: all 0.2s ease;
}

.year-btn:hover .year-spark {
  background: rgba(255, 255, 255, 0.6);
}

.year-btn.active .year-spark {
  background: var(--accent-warm);
  box-shadow: 0 0 6px var(--accent-warm);
}

.nav-hints {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ==========================================================================
   3D HOVER TOOLTIP
   ========================================================================== */

.hover-tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  max-width: 260px;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(10, 12, 18, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  transform: translate(16px, -50%);
  transition: opacity 0.12s ease;
}

.tooltip-date {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--accent-warm);
  margin-bottom: 3px;
}

.tooltip-title {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.25;
}

.tooltip-tags {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}

/* ==========================================================================
   SLIDE-OUT POST PREVIEW DRAWER (RIGHT)
   ========================================================================== */

.preview-drawer {
  position: fixed;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 400px;
  max-width: calc(100vw - 32px);
  z-index: 30;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 32px));
  transition: transform 0.36s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  user-select: text;
}

.preview-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--accent-warm);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.drawer-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.drawer-nav-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;
}

.icon-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--border-highlight);
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

.drawer-image-wrap {
  position: relative;
  display: block;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  aspect-ratio: 16 / 10;
}

.drawer-image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.drawer-image-wrap:hover img {
  transform: scale(1.03);
}

.img-zoom-hint {
  position: absolute;
  bottom: 10px;
  right: 10px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(10, 12, 18, 0.8);
  backdrop-filter: blur(6px);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-image-wrap:hover .img-zoom-hint {
  opacity: 1;
}

.drawer-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-main);
}

.drawer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.drawer-tag-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.drawer-tag-chip:hover {
  color: var(--text-main);
  border-color: var(--accent-warm);
}

.drawer-excerpt {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #c4cad4;
}

.drawer-actions {
  margin-top: 4px;
}

.primary-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--text-main);
  color: var(--bg-deep);
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.primary-action-btn:hover {
  background: var(--accent-warm);
  color: #000;
  transform: translateY(-1px);
}

/* Related Constellation Posts */
.related-section {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.18s ease;
}

.related-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-highlight);
}

.related-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: 6px;
  background: #111;
}

.related-card-title {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.related-card-date {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--text-dim);
}

/* ==========================================================================
   LOADING OVERLAY
   ========================================================================== */

.loader-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loader-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loader-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.compass-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent-warm);
  animation: spin 1.1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loader-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  color: var(--text-main);
}

.loader-sub {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ==========================================================================
   RESPONSIVE ADJUSTMENTS
   ========================================================================== */

@media (max-width: 900px) {
  .hud-tags {
    display: none;
  }
  .timeline-bar {
    display: none;
  }
  .nav-hints {
    display: none;
  }
  .hud-top {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
  }
  .controls-cluster {
    justify-content: space-between;
  }
  #search-input, #search-input:focus {
    width: 100%;
  }
}
