/* ── Full-screen graph: override main container ───────────────────────── */

main:has(.graph-page) {
  max-width: 100% !important;
  width: 100% !important;
  min-height: 0 !important;
}

main:has(.graph-page) ~ footer {
  display: none;
}

/* ── Graph page wrapper ──────────────────────────────────────────────── */

.graph-page {
  margin: 0;
  width: 100%;
}

/* ── Canvas ──────────────────────────────────────────────────────────── */

#graph-canvas {
  position: relative;
  width: 100%;
  height: 100vh;
  margin-top: calc(-1 * (4.5rem + 1.5rem + 1.5rem)); /* offset header spacer */
  overflow: hidden;
  background: transparent;
}

@media (min-width: 1024px) {
  #graph-canvas {
    height: 100vh;
    margin-top: calc(-1 * (4.5rem + 2rem + 1.5rem));
  }
}

#graph { width: 100%; height: 100%; }

/* ── Overlay stats (bottom-right, below zoom controls) ──────────────── */

.graph-overlay-header {
  position: absolute;
  bottom: 60px;
  right: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  z-index: 10;
  pointer-events: none;
  max-width: calc(100% - 72px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.graph-overlay-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.graph-overlay-meta {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

/* ── Loading ─────────────────────────────────────────────────────────── */

#graph-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  pointer-events: none;
}

/* ── Detail panel ────────────────────────────────────────────────────── */

#tag-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 260px;
  max-height: calc(100% - 28px);
  overflow-y: auto;
  border-radius: 10px;
  padding: 14px 16px;
  display: none;
  z-index: 20;
  scrollbar-width: thin;

  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: inherit;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  scrollbar-color: var(--card-border) transparent;
}

html.dark #tag-panel {
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#tag-panel::-webkit-scrollbar { width: 4px; }
#tag-panel::-webkit-scrollbar-track { background: transparent; }
#tag-panel::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 2px; }

#tag-panel.visible {
  display: block;
  animation: panel-in 0.18s ease;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateX(6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.tp-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.tp-meta {
  margin-top: 3px;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.tp-close {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  border: none;
  border-radius: 50%;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
  margin-left: 6px;
  color: var(--text-secondary);
}
.tp-close:hover { background: var(--card-border); }

.tp-view-all {
  display: inline-block;
  margin-bottom: 12px;
  font-size: 0.72rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.15s;
  color: var(--accent);
}
.tp-view-all:hover { color: var(--accent-hover); }

.tp-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 0 6px;
  color: var(--text-secondary);
}

.tp-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tp-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}
.tp-tag:hover { background: var(--accent-bg-hover); }

.tp-tag-count { font-size: 0.62rem; opacity: 0.6; }

.tp-articles { display: flex; flex-direction: column; }

.tp-article {
  display: block;
  padding: 5px 0;
  font-size: 0.75rem;
  text-decoration: none;
  border-bottom: 1px solid var(--divider);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.15s;
  color: var(--text-secondary);
}
.tp-article:last-child { border-bottom: none; }
.tp-article:hover { color: var(--accent); }

/* ── Zoom controls ───────────────────────────────────────────────────── */

#graph-controls {
  position: absolute;
  bottom: 60px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 20;
}

.graph-ctrl-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  color: var(--text-secondary);
  backdrop-filter: blur(8px);
}
.graph-ctrl-btn:hover {
  background: var(--card-border);
  color: var(--text-primary);
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #tag-panel {
    width: calc(100% - 28px);
    top: auto;
    bottom: 54px;
    right: 14px;
    max-height: 42vh;
  }
}
