/* ============================================================
   Shared styles — network map + document pages
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --border: #2d3147;
  --text: #e2e4ed;
  --text-muted: #7b8099;
  --accent: #4A90D9;
  --link: #6aaee8;
  --link-hover: #9ecbf5;
  --doc-bg: #f9f9fb;
  --doc-text: #1a1d27;
  --doc-muted: #5a5e72;
  --doc-border: #d8dae8;
  --nav-bg: #1a1d27;
  --nav-text: #e2e4ed;
}

/* ============================================================
   Network map page (body.map-page)
   ============================================================ */

body.map-page {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#map-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.6rem 1.2rem;
  background: rgba(26, 29, 39, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

#map-header h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

#map-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#map-header .spacer {
  flex: 1;
}

/* Search input */
#search-input {
  height: 28px;
  padding: 0 10px;
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 0.8rem;
  width: 180px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
#search-input::placeholder { color: var(--text-muted); }
#search-input:focus { border-color: var(--accent); background: rgba(255,255,255,0.10); }

/* Surprise button */
#surprise-btn {
  background: none;
  border: 1px solid #444;
  border-radius: 4px;
  color: #ccc;
  font-size: 0.8rem;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
#surprise-btn:hover { color: #fff; border-color: #888; }

.index-link {
  color: #ccc;
  font-size: 0.8rem;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #444;
  border-radius: 4px;
  white-space: nowrap;
}
.index-link:hover { color: #fff; border-color: #888; }

#site-version {
  font-size: 0.7rem;
  color: #555;
  font-family: monospace;
  white-space: nowrap;
  padding: 0 4px;
  letter-spacing: 0.03em;
}

.legend {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  flex-basis: 100%;
  padding-top: 0.35rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: -0.2rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  border-radius: 3px;
  padding: 2px 4px;
  transition: color 0.12s;
  user-select: none;
}
.legend-item:hover { color: var(--text); }
.legend-item.active { color: var(--text); background: rgba(255,255,255,0.08); }

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Content area: graph + optional detail panel */
#content-area {
  position: fixed;
  top: 42px; /* fallback; updated to real offsetHeight by JS on load + resize */
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: stretch;
}

#graph-container {
  flex: 1;
  min-width: 0;
  height: 100%;
}

/* Detail panel (right half on wide screens) */
#detail-panel {
  width: 50%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--doc-bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

#detail-panel.hidden {
  display: none;
}

#detail-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.8rem;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

#detail-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}

#detail-close:hover {
  color: var(--text);
  background: rgba(255,255,255,0.08);
}

#detail-fullpage {
  font-size: 0.8rem;
  color: var(--link);
  text-decoration: none;
  margin-left: auto;
}

#detail-fullpage:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

#detail-iframe {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

/* Tooltip */
#tooltip {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  max-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  display: none;
}

#tooltip.visible {
  display: block;
}

#tooltip .tt-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
  line-height: 1.3;
}

#tooltip .tt-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}

#tooltip .tt-cat {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Home panel */
#home-panel {
  width: 50%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

#home-panel.hidden {
  display: none;
}

#home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.2rem;
  background: rgba(26, 29, 39, 0.95);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#home-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.7;
}

#home-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
}
#home-close:hover { color: var(--text); background: rgba(255,255,255,0.08); }

#home-quote {
  padding: 1.6rem 1.4rem 1.2rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#quote-why {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.quote-mark {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--accent);
  opacity: 0.4;
  margin-bottom: -0.5rem;
  font-family: Georgia, serif;
}

#quote-text {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--text);
  font-style: italic;
  margin-bottom: 0.6rem;
}

.quote-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.quote-source a {
  color: var(--link);
  text-decoration: none;
}
.quote-source a:hover { color: var(--link-hover); }

#quote-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  line-height: 1;
}
#quote-refresh:hover { color: var(--text); border-color: #666; }

/* Home stats line */
#home-stats {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}

/* Concept spotlight strip */
#concept-spotlight {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
  padding: 0.65rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(74,144,217,0.05);
  flex-shrink: 0;
  font-size: 0.8rem;
}
.concept-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
#concept-term {
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
#concept-term:hover { text-decoration: underline; }
#concept-desc {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.4;
  flex: 1;
}
#concept-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}
#concept-refresh:hover { color: var(--text); border-color: #666; }

/* Persona nav cards */
#home-nav {
  padding: 1rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-content: flex-start;
}

.nav-section {
  flex: 1 1 42%;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  transition: border-color 0.15s;
}
.nav-section:hover { border-color: rgba(255,255,255,0.15); }

.nav-section-q {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.nav-primary {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--accent) !important;
  text-decoration: none;
  padding: 0.2rem 0;
  line-height: 1.4;
}
.nav-primary:hover { text-decoration: underline !important; }

.nav-secondary {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-section-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

#home-nav a {
  font-size: 0.8rem;
  color: var(--link);
  text-decoration: none;
  padding: 0.1rem 0;
  line-height: 1.4;
}
#home-nav a:hover { color: var(--link-hover); text-decoration: underline; }

/* Diagram carousel */
#home-diagrams {
  padding: 0.75rem 1.4rem 0.6rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.home-diagrams-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--map-muted);
  margin-bottom: 0.55rem;
}

.diagram-carousel {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.diagram-slides {
  display: flex;
  transition: transform 0.4s cubic-bezier(0.4,0,0.2,1);
}

.diagram-slide {
  min-width: 100%;
  display: flex;
  flex-direction: column;
  text-decoration: none;
}
.diagram-slide:hover .diagram-img-wrap { background: #dce4f0; }
.diagram-slide:hover span { color: #fff; }

.diagram-img-wrap {
  width: 100%;
  height: 240px;
  background: #eef1f7;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
}

.diagram-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  padding: 6px;
  box-sizing: border-box;
}

.diagram-slide span {
  font-size: 0.7rem;
  color: rgba(180,195,220,0.9);
  padding: 0.32rem 0.7rem 0.38rem;
  line-height: 1.3;
  text-align: center;
  background: rgba(0,0,0,0.18);
  transition: color 0.15s;
}

.diagram-dots {
  display: flex;
  justify-content: center;
  gap: 5px;
  padding: 0.3rem 0 0.35rem;
  background: rgba(0,0,0,0.18);
}

.diagram-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.diagram-dot.active {
  background: rgba(255,255,255,0.75);
  transform: scale(1.3);
}

#home-footer {
  padding: 1rem 1.4rem 1.4rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#home-footer a {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
#home-footer a:hover { text-decoration: underline; }

@media (max-width: 899px) {
  #home-panel { display: none !important; }
}

/* Guidance panel slot (v2) */
#guidance-panel {
  position: fixed;
  top: 48px;
  right: 0;
  bottom: 0;
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 50;
  overflow-y: auto;
  padding: 1.2rem;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}

#guidance-panel.open {
  transform: translateX(0);
}

#guidance-panel.hidden {
  display: none;
}

/* ============================================================
   Document pages (body.doc-page)
   ============================================================ */

body.doc-page {
  margin: 0;
  padding: 0;
  background: var(--doc-bg);
  color: var(--doc-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
}

.doc-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: var(--nav-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.nav-back {
  color: var(--link);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  flex-shrink: 0;
}

.nav-back:hover {
  color: var(--link-hover);
}

.nav-title {
  font-size: 0.875rem;
  color: var(--nav-text);
  opacity: 0.7;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-content {
  max-width: 740px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

/* Typography */
.doc-content h1 {
  font-size: 1.75rem;
  line-height: 1.3;
  margin-top: 0;
  margin-bottom: 1rem;
  color: #0f1117;
}

.doc-content h2 {
  font-size: 1.25rem;
  margin-top: 2.2rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--doc-border);
  color: #1a1d27;
}

.doc-content h3 {
  font-size: 1.05rem;
  margin-top: 1.6rem;
  margin-bottom: 0.4rem;
  color: #2a2d3f;
}

.doc-content p {
  margin: 0 0 1rem;
}

.doc-content a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.doc-content a:hover {
  color: #1d4ed8;
}

.doc-content ul, .doc-content ol {
  margin: 0 0 1rem 1.5rem;
  padding: 0;
}

.doc-content li {
  margin-bottom: 0.35rem;
}

.doc-content ul.task-list {
  list-style: none;
  margin-left: 0.25rem;
}

.doc-content .task-list-item {
  margin-bottom: 0.5rem;
}

.doc-content .task-list-item p {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin: 0;
}

.doc-content .task-list-item input[type="checkbox"] {
  flex-shrink: 0;
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  accent-color: #4a7fa5;
  cursor: default;
}

.doc-content blockquote {
  margin: 1.6rem 0;
  padding: 1rem 1.4rem;
  border-left: 4px solid #E0A030;
  color: var(--doc-text);
  background: #fdf8ed;
  border-radius: 0 6px 6px 0;
  font-size: 0.97em;
}

.doc-content code {
  font-family: "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 0.875em;
  background: #eef0f7;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  color: #2a2d3f;
}

.doc-content pre {
  background: #1a1d27;
  color: #c9d1e0;
  padding: 1rem 1.2rem;
  border-radius: 6px;
  overflow-x: auto;
  margin: 1.2rem 0;
  font-size: 0.875rem;
  line-height: 1.6;
}

.doc-content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: 1em;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2rem 0;
  font-size: 0.9rem;
}

.doc-content th {
  background: #eef0f7;
  padding: 0.5rem 0.8rem;
  text-align: left;
  border: 1px solid var(--doc-border);
  font-weight: 600;
}

.doc-content td {
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--doc-border);
  vertical-align: top;
}

.doc-content hr {
  border: none;
  border-top: 1px solid var(--doc-border);
  margin: 2rem 0;
}

.doc-content strong {
  font-weight: 600;
}

.doc-content img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  margin: 1.5rem auto;
  border: 1px solid var(--doc-border);
}

.doc-content figure {
  margin: 1.5rem 0;
  text-align: center;
}

.doc-content figcaption {
  font-size: 0.85rem;
  color: var(--doc-muted);
  margin-top: 0.5rem;
  font-style: italic;
}

/* Category badge in doc nav */
.nav-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  opacity: 0.85;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-cat-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.doc-footer {
  max-width: 740px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  border-top: 1px solid var(--doc-border);
  font-size: 0.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-version {
  font-size: 0.75rem;
  color: var(--doc-muted);
  font-family: monospace;
  letter-spacing: 0.03em;
}

.doc-footer a {
  color: #2563eb;
  text-decoration: none;
}

.doc-footer a:hover {
  text-decoration: underline;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 899px) {
  /* On narrow screens the detail panel is never shown; clicks navigate away */
  #detail-panel {
    display: none !important;
  }
}


@media (max-width: 600px) {
  .legend {
    display: none;
  }

  .doc-content {
    padding: 1.5rem 1rem 3rem;
  }

  .doc-content h1 {
    font-size: 1.4rem;
  }
}

/* ============================================================
   Deck illustration lightbox
   ============================================================ */

.doc-content img[src*="deck"] {
  cursor: zoom-in;
  transition: opacity 0.15s, box-shadow 0.15s;
  display: block;
}

.doc-content img[src*="deck"]:hover {
  opacity: 0.88;
  box-shadow: 0 0 0 2px var(--accent);
}

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.18s ease;
}

#lightbox.open { opacity: 1; }

#lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.7);
}
