/* =====================================================
   MAP OF SCIENCES — CORE STYLESHEET
   Academic, minimal, layout-safe
   ===================================================== */

/* ---------- RESET ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #111827;
  background: #f9fafb;
}

/* ---------- LINKS ---------- */

a {
  color: #1e40af;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---------- GLOBAL HEADINGS ---------- */

h1 {
  text-align: center;
  font-size: 2.4rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 20px;
}

h2 {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 600;
  color: #334155;
  margin: 48px 0 24px;
}

h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #475569;
  margin: 24px 0 8px;
}

/* ---------- HEADER ---------- */

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  z-index: 1000;
}

.site-title a {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
}

/* ---------- MAIN OFFSET ---------- */

main {
  padding-top: 72px;
}

/* =====================================================
   TOPIC PAGE LAYOUT (CRITICAL FIX)
   ===================================================== */

/* Breadcrumb bar */
#breadcrumb {
  padding: 6px 20px;
  font-size: 0.85rem;
  color: #475569;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

/* Main horizontal container */
#container {
  display: flex;
  height: calc(100vh - 52px - 34px);
  overflow: hidden; /* PREVENT SVG OVERLAP */
}

/* ---------- MAP PANEL + SVG ---------- */

#map-panel {
  flex: 1;
  position: relative;
  overflow: hidden;
  height: 100%;
}

#mindmap {
  width: 100%;
  height: 100%;
  display: block;
  background: #ffffff;
  cursor: grab;
}

/* ---------- CONTEXT SIDEBAR ---------- */

#context {
  width: 546px;
  min-width: 546px;
  max-width: 546px;
  padding: 24px 20px;
  border-left: 1px solid #e5e7eb;
  overflow-y: auto;
  background: #fafafa;
  font-size: 0.95rem;
  line-height: 1.6;
}

#context h3 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.2rem;
  font-weight: 600;
}

#context p {
  margin: 0 0 16px;
  color: #334155;
}

#context ul {
  padding-left: 18px;
  margin: 0 0 16px;
}

#context li {
  margin-bottom: 6px;
}

#context a {
  color: #1e40af;
}

/* ---------- TOOLTIP ---------- */

#tooltip {
  position: fixed;
  max-width: 280px;
  background: #ffffff;
  border: 1px solid #cbd5f5;
  padding: 8px 10px;
  font-size: 0.8rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: none;
  z-index: 2000;
  pointer-events: none;
}

/* =====================================================
   SEARCH
   ===================================================== */

.search-container {
  position: relative;
  width: 360px;
}

#global-search {
  width: 100%;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #cbd5f5;
}

#search-results {
  position: absolute;
  top: 110%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
}

.search-item {
  padding: 8px 12px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
}

.search-item:hover {
  background: #f8fafc;
}

.search-item small {
  color: #6b7280;
}

/* =====================================================
   HOMEPAGE SECTIONS (UNCHANGED VISUALLY)
   ===================================================== */

.hero {
  padding: 80px 24px 64px;
  background: #f1f5f9;
}

.hero-content {
  max-width: 900px;
  margin: 0 auto;
  text-align: center;
}

.subtitle,
.description,
.why-card p,
.preview-text {
  color: #475569;
}

.why {
  padding: 64px 24px;
}

.preview {
  padding: 64px 24px;
  background: #eef2f7;
}

.audience {
  padding: 64px 24px;
}

/* ---------- FOOTER ---------- */

.site-footer {
  padding: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: #6b7280;
  border-top: 1px solid #e5e7eb;
}
/* =====================================================
   HOMEPAGE STRUCTURE RESTORATION
   (Does NOT affect topic pages)
   ===================================================== */

/* ---------- WHY SECTION GRID ---------- */

.why {
  padding: 64px 24px;
}

.why-grid {
  max-width: 1000px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 32px;
}

.why-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 24px;
  border-radius: 6px;
}

.why-card h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.why-card p {
  margin: 0;
  font-size: 0.95rem;
  color: #475569;
}

/* ---------- HERO ACTIONS / LINKS AS BOXES ---------- */

.hero-actions {
  margin-top: 28px;
  text-align: center;
}

.primary-btn,
.preview-box,
.hero-actions a {
  display: inline-block;
  padding: 12px 20px;
  border: 1.5px solid #1e293b;
  border-radius: 6px;
  font-weight: 500;
  color: #1e293b;
  background: #ffffff;
  transition: background 0.15s ease, color 0.15s ease;
}

.primary-btn:hover,
.preview-box:hover,
.hero-actions a:hover {
  background: #1e293b;
  color: #ffffff;
  text-decoration: none;
}

/* ---------- PREVIEW SECTION ---------- */

.preview {
  padding: 64px 24px;
  background: #eef2f7;
  text-align: center;
}

.preview-text {
  font-size: 0.95rem;
  color: #475569;
  margin-bottom: 16px;
}

/* ---------- AUDIENCE SECTION ---------- */

.audience {
  padding: 64px 24px;
}

.audience ul {
  max-width: 640px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
}

.audience li {
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.95rem;
}
/* ===============================
   TOPIC PAGE LAYOUT (CRITICAL)
   =============================== */

#container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 546px;
  height: calc(100vh - 52px - 34px); /* header + breadcrumb */
}

/* MAP SIDE */
#map-panel {
  position: relative;
  overflow: hidden;
}

/* SVG MUST FILL MAP PANEL */
#map-panel svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* CONTEXT SIDEBAR */
#context {
  border-left: 1px solid #e5e7eb;
  padding: 20px 24px;
  overflow-y: auto;
  background: #ffffff;
}
/* ===== TOPIC PAGE LAYOUT (FINAL, STABLE) ===== */

#container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 546px;
  height: calc(100vh - 52px - 34px);
}

/* MAP */
#map-panel {
  position: relative;
  overflow: hidden;
}

#map-panel svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* CONTEXT */
#context {
  border-left: 1px solid #e5e7eb;
  padding: 20px 24px;
  overflow-y: auto;
  background: #ffffff;
}
#container {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 546px;
  height: calc(100vh - 52px - 34px); /* header + breadcrumb */
}
#external-search-panel button {
  margin-right: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #c7d2fe;
  background: #f8fafc;
  cursor: pointer;
  font-size: 12px;
}

#external-search-panel button:hover {
  background: #e0e7ff;
}
/* =====================================================
   UI REFRESH v4 — LIGHTER HEADER/SIDEBAR
   ===================================================== */

.site-header {
  background: #2d3f55 !important;
  border-bottom: none !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.site-title a {
  color: #e2e8f0 !important;
  font-weight: 700;
}

.site-title a:hover { color: #ffffff !important; text-decoration: none; }

#global-search {
  background: #ffffff !important;
  border: 1.5px solid #6366f1 !important;
  color: #0f172a !important;
  border-radius: 5px;
}

#global-search::placeholder { color: #94a3b8 !important; }
#global-search:focus {
  outline: none !important;
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2) !important;
}

#search-results {
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 0 0 6px 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-item { color: #1e293b; border-bottom: 1px solid #f1f5f9; }
.search-item:hover { background: #f5f3ff !important; }
.search-item small { color: #94a3b8; }

body { background: #f8fafc; }
#mindmap { background: #f1f5f9 !important; }

#context {
  border-left: 2px solid #e2e8f0 !important;
  background: #ffffff !important;
}

#context h3 {
  color: #0f172a !important;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 8px;
  margin-bottom: 12px;
}

#context p { color: #475569; }
#context a { color: #6366f1; }

.ctx-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ffffff !important;
  background: #6366f1;
  padding: 3px 8px;
  border-radius: 4px;
  margin: 16px 0 8px;
}

#external-search-panel button {
  margin: 0 6px 8px 0;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  border-width: 1.5px;
  border-style: solid;
}

#external-search-panel button:nth-child(1) { background:#fef2f2; border-color:#ef4444; color:#b91c1c; }
#external-search-panel button:nth-child(1):hover { background:#ef4444; color:#ffffff; }
#external-search-panel button:nth-child(2) { background:#f0fdf4; border-color:#22c55e; color:#15803d; }
#external-search-panel button:nth-child(2):hover { background:#22c55e; color:#ffffff; }
#external-search-panel button:nth-child(3) { background:#eff6ff; border-color:#3b82f6; color:#1d4ed8; }
#external-search-panel button:nth-child(3):hover { background:#3b82f6; color:#ffffff; }
#external-search-panel button:nth-child(4) { background:#fffbeb; border-color:#f59e0b; color:#b45309; }
#external-search-panel button:nth-child(4):hover { background:#f59e0b; color:#ffffff; }

#tooltip {
  border-radius: 6px;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  color: #334155;
}