/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-dim: #1f6feb;
  --highlight: #f0883e;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 8px;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;

  height: 100vh;
  overflow-y: scroll;
  overflow-x: hidden;
}

.snap-panel {
  min-height: 100vh;

  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
 }

.panel-inner {
  width: min(1200px, calc(100% - 48px));
  margin: 0 auto;
  padding: 30px 0 90px 0;
}

.free-scroll {
  scroll-snap-align: start;
  min-height: auto;
}

/* ===== HEADER ===== */
#hero {
  text-align: center;
  background: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
  border-bottom: 1px solid var(--border);
}

#hero h1 {
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--accent), var(--highlight));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#hero .panel-inner,
.section .panel-inner,
footer .panel-inner {
  animation: fadeUp 0.7s ease;
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.intro {
  max-width: 650px;
  margin: 20px auto 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hero-steps {
  display: flex;
  gap: 20px;
  max-width: 700px;
  margin: 32px auto 0;
  text-align: left;
}

.hero-step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .hero-steps { flex-direction: column; }
}

/* ===== SECTIONS ===== */
.section {
  /*max-width: 1200px;
  margin: 0 auto;
  padding: 60px 24px;*/

  width: 100%;
}

.section h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.section-nav {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-nav a {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.3);
  transition: transform 0.2s, background 0.2s;
}

.section-nav a:hover {
  background: var(--accent);
  transform: scale(1.2);
}

.section-nav a.active {
  background: var(--accent);
  transform: scale(1.3);
}

.section-desc {
  color: var(--text-muted);
  margin-bottom: 30px;
}

.disease-highlight {
  color: var(--highlight);
  font-weight: 600;
}

.hidden {
  display: none;
}

/* ===== VIS 1: EXPLORE ===== */
.explore-layout {
  display: flex;
  gap: 24px;
  align-items: stretch;
}

.symptom-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 24px;
  max-height: 80vh;
  overflow-y: auto;
}

.symptom-search {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.symptom-search:focus {
  border-color: var(--accent);
}

.vis-tabs {
  display: flex;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: fit-content;
  margin-bottom: 20px;
}

.vis-tab {
  padding: 8px 28px;
  font-size: 0.85rem;
  font-weight: 600;
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.vis-tab:hover {
  background: rgba(88, 166, 255, 0.08);
  color: var(--text);
}

.vis-tab.active {
  background: var(--accent);
  color: #fff;
}

.vis-panel {
  display: none;
}

.vis-panel.active {
  display: block;
}

.panel-desc {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 16px;
  line-height: 1.6;
}

.diagnostic-disclaimer {
  font-size: 0.82rem;
  color: #f85149;
  border: 1px solid rgba(248, 81, 73, 0.35);
  background: rgba(248, 81, 73, 0.08);
  border-radius: var(--radius);
  padding: 8px 12px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.bubble-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  align-items: center;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-circle {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
}

.click-cta {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.scroll-cue {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 40, 55, 0.9);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  pointer-events: none;
  animation: cue-in 0.4s ease-out;
  z-index: 10;
}
.scroll-cue strong { color: var(--accent); }
.scroll-cue.fade-out {
  animation: cue-out 0.5s ease-in forwards;
}
@keyframes cue-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes cue-out { from { opacity: 1; } to { opacity: 0; } }

.symptom-list {
  max-height: 50vh;
  overflow-y: auto;
  margin-top: 12px;
}

.symptom-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}

.symptom-list label:hover {
  background: rgba(88, 166, 255, 0.08);
  color: var(--text);
}

.symptom-list input[type="checkbox"] {
  accent-color: var(--accent);
}

.symptom-list label.symptom-unavailable {
  display: none !important;
}

.symptom-exhausted-msg {
  margin: 10px 4px 6px;
  padding: 10px 12px;
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(255,215,0,0.08), rgba(240,136,62,0.12));
  border: 1px solid rgba(255,215,0,0.25);
  color: #c8a84b;
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: exhaustedFadeIn 0.5s ease;
}

.exhausted-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
  animation: exhaustedSpin 3s linear infinite;
}

@keyframes exhaustedFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes exhaustedSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.selected-symptoms {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.symptom-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--accent-dim);
  color: white;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
}

.symptom-tag:hover {
  background: var(--danger);
}

.bubble-container {
  flex: 1;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 70vh;
}

.bubble-svg {
  width: 100%;
  height: 70vh;
  cursor: grab;
}

.bubble-svg:active {
  cursor: grabbing;
}

.zoom-reset-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  z-index: 5;
  transition: background 0.15s, color 0.15s;
}

.zoom-reset-btn:hover {
  background: var(--accent-dim);
  color: var(--text);
}

.diagnostic-reset-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 7px 0;
  font-size: 0.8rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.diagnostic-reset-btn:hover {
  background: rgba(229, 115, 115, 0.1);
  border-color: #e57373;
  color: #e57373;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 10;
  white-space: nowrap;
}

/* ===== VIS 2: BODY EXPLORER ===== */
.explorer-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.nav-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}

.nav-btn:hover {
  background: var(--accent-dim);
}

#explorer-viewport {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(220px, 320px);
  grid-template-areas:
    "label label"
    "canvas annotations";
  align-items: start;
  gap: 16px 24px;
  max-width: 900px;
  width: 100%;
}

#system-label {
  grid-area: label;
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--accent);
  text-align: left;
}

#explorer-canvas {
  grid-area: canvas;
  position: relative;
  display: block;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

#system-image {
  display: block;
  width: 100%;
  max-width: 100%;
  max-height: 500px;
  object-fit: contain;
  margin: 0 auto;
}

#explorer-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#symptom-annotations {
  grid-area: annotations;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  justify-content: flex-start;
  align-items: stretch;
  max-height: 500px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding-right: 4px;
}

.annotation-tag {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
}

.annotation-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid currentColor;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.annotation-name {
  flex: 1;
  color: var(--text);
  text-transform: capitalize;
}

.annotation-value {
  font-weight: 700;
}

.annotation-empty {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  background: var(--surface);
  text-align: left;
}

#system-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.system-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.system-dot.active {
  background: var(--accent);
}

/* ===== VIS 3: INFOGRAPHIC ===== */
.profile-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 24px;
  align-items: start;
}

.info-left,
.info-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

#disease-info {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

#disease-info h3 {
  font-size: 1.5rem;
  text-transform: capitalize;
  color: var(--highlight);
  margin-bottom: 12px;
}

#info-description {
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.7;
}

#info-link, .wiki-outlink {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

#info-link:hover, .wiki-outlink:hover {
  text-decoration: underline;
}

.wiki-outlink {
  display: block;
  text-align: center;
  margin-top: 16px;
}

#wordcloud-container {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

#wordcloud-container h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

#wordcloud-svg {
  width: 100%;
  height: 420px;
}

/* ===== PLACEHOLDER CARDS ===== */
.info-extras {
  display: block;
}

.placeholder-card {
  flex: 1;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.placeholder-card h4 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.placeholder-text {
  color: var(--border);
  font-size: 0.85rem;
  font-style: italic;
}

/* ===== INFO EXTRA CARDS (Risk Factors / Prevalence / Treatment) ===== */
.info-extra-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.info-extra-card h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Risk factors */
.rf-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rf-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  border: 1px solid;
  line-height: 1.5;
}
.rf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.72rem;
  align-items: center;
  opacity: 0.8;
}
.rf-legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 3px;
}

/* Prevalence gauge */
.prevalence-gauge {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}
.prev-step {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: var(--border);
  transition: background 0.3s;
}
.prevalence-label {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 3px;
}
.prevalence-context {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Treatment */
.tx-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tx-tag {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  background: rgba(88,166,255,0.12);
  color: var(--accent);
  border: 1px solid rgba(88,166,255,0.28);
}
.tx-summary {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Systems Affected chart */
.sys-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sys-label {
  width: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sys-bar-track {
  flex: 1;
  height: 14px;
  background: rgba(255,255,255,0.04);
  border-radius: 3px;
  overflow: hidden;
}
.sys-bar {
  height: 100%;
  border-radius: 3px;
  opacity: 0.75;
  transition: width 0.4s ease;
}
.sys-count {
  width: 22px;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  flex-shrink: 0;
}

/* ===== RELATED DISEASES RIBBON ===== */

.ribbon-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0;
  overflow: hidden;
  min-height: 480px;
}

.ribbon-card-inner {
  display: flex;
  align-items: flex-start;
  min-height: 480px;
}

.ribbon-card-right {
  margin-left: auto;
  width: 58%;
  margin-top: 20px;
  padding: 20px 24px 16px;
}

.ribbon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px;
}

.ribbon-card h3 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-muted);
}

.ribbon-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.ribbon-slider-wrap input[type="range"] {
  -webkit-appearance: none;
  width: 90px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.ribbon-slider-wrap input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

#related-n-label {
  min-width: 14px;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
}

.ribbon-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

#related-ribbon-container {
  width: 100%;
}

#related-ribbon-svg {
  display: block;
  width: 100%;
  overflow: visible;
}

.ribbon-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ribbon-center-label {
  fill: var(--accent);
  font-size: 12px;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ribbon-legend-label {
  fill: var(--text);
  font-size: 10px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.ribbon-back-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 4px;
  padding: 2px 10px;
  font-size: 0.78rem;
  cursor: pointer;
}
.ribbon-back-btn:hover { background: var(--border); }

/* Button to go back to Explore */

.floating-back-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 200;

  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(22, 27, 34, 0.92);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px);
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.floating-back-btn:hover {
  background: var(--accent-dim);
  transform: translateY(-2px);
}

.floating-back-btn.hidden-btn {
  opacity: 0;
  pointer-events: none;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  /*padding: 30px 20px;*/
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  /*margin-top: 40px;*/
}

.footer-panel {
  min-height: 40vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .explore-layout, .explorer-layout { flex-direction: column; }
  .symptom-panel { width: 100%; position: static; }
  .profile-grid { grid-template-columns: 1fr; }
  .floating-back-btn {
    right: 16px;
    bottom: 16px;
    font-size: 0.82rem;
    padding: 10px 14px;
  }
  #explorer-viewport {
    grid-template-columns: 1fr;
    grid-template-areas:
      "label"
      "canvas"
      "annotations";
  }
}
