/* ============================================
   ASTRO.CSS — Laniakea Field Guide shared styles
   Used by: laniakea.html, virgo.html, hydra.html,
            centaurus.html, pavo-indus.html
   ============================================ */

/* ===== BASE VARIABLES ===== */
:root {
  --bg-primary: #111116;
  --bg-secondary: #16161c;
  --bg-tertiary: #1c1c24;
  --bg-card: #151520;
  --text-primary: #e8e6e1;
  --text-secondary: #9e9a91;
  --text-tertiary: #6b6860;
  --accent: #c8c2b4;
  --accent-dim: #847f73;
  --accent-faint: rgba(200, 194, 180, 0.06);
  --accent-gold: #c9a84c;
  --accent-gold-dim: #8a7234;
  --sc-virgo: #7BA4C9;
  --sc-hydra: #C9A84C;
  --sc-centaurus: #C97B7B;
  --sc-pavo: #A07BC9;
  --sc-virgo-dim: #4e7a9e;
  --sc-hydra-dim: #8a7234;
  --sc-centaurus-dim: #8a5252;
  --sc-pavo-dim: #6e5299;
  --border-subtle: #252530;
  --border-faint: #1e1e28;
}

/* ===== RESET & BODY ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 300;
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== ATMOSPHERE BACKGROUND ===== */
.atmosphere {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: hidden;
}

/* ===== LAYOUT ===== */
.page-wrapper {
  position: relative; z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== BACK NAV ===== */
.back-nav { padding: 20px 0 0; }
.back-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-color-dim); text-decoration: none;
  transition: color 0.3s ease;
}
.back-link:hover { color: var(--accent-color); }
.back-link::before { content: '← '; }

/* ===== HERO ===== */
.hero { text-align: center; padding: 80px 0 20px; }
.hero-title {
  font-family: 'Fraunces', serif;
  font-size: 3.2rem; font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--text-primary); margin-bottom: 12px;
}
.hero-stats {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem; font-weight: 400;
  letter-spacing: 0.1em; color: var(--accent-dim);
}
.hero-stats .sep { color: var(--border-subtle); margin: 0 6px; }

/* ===== CHART SECTIONS ===== */
.chart-section { margin: 48px 0; }
.chart-toggle-bar {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-bottom: 12px;
}
.chart-toggle-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-tertiary); background: none;
  border: 1px solid transparent; border-radius: 2px;
  padding: 6px 14px; cursor: pointer; transition: all 0.3s ease;
}
.chart-toggle-btn:hover { color: var(--text-secondary); }
.chart-toggle-btn.active {
  color: var(--accent-color);
  border-color: var(--accent-color-dim);
  background: var(--accent-color-faint);
}
.chart-container {
  width: 100%; border: 1px solid var(--accent-color-dim);
  border-radius: 2px; overflow: hidden;
  background: #141418; position: relative; cursor: zoom-in;
}
.chart-container img { width: 100%; height: auto; display: block; }
.chart-container img.hidden { display: none; }

/* ===== TEXT SECTIONS ===== */
.text-section {
  margin: 56px 0; max-width: 720px;
  margin-left: auto; margin-right: auto;
}
.section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem; font-weight: 400;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--accent-color-dim); margin-bottom: 20px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-faint);
}
.text-section p {
  font-size: 0.95rem; color: var(--text-secondary);
  line-height: 1.85; margin-bottom: 20px;
}
.text-section p:last-child { margin-bottom: 0; }
.text-section p strong { color: var(--text-primary); font-weight: 400; }
.text-section p em { font-style: italic; color: var(--text-primary); }
.text-section::after { content: ''; display: table; clear: both; }

/* ===== REFERENCES ===== */
.ref {
  font-size: 0.65em; vertical-align: super; line-height: 0;
  color: var(--accent-color-dim); cursor: default;
  font-family: 'IBM Plex Mono', monospace; font-weight: 400;
}

/* ===== HERO IMAGE & CAPTIONS ===== */
.hero-image {
  width: 100%; margin: 28px 0 4px; overflow: hidden;
  border-radius: 3px; border: 1px solid var(--accent-color-dim);
  background: var(--bg-secondary); cursor: zoom-in;
}
.hero-image img { width: 100%; height: auto; display: block; }
.hero-caption {
  margin-top: 6px; margin-bottom: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem; font-weight: 400;
  color: var(--text-tertiary); letter-spacing: 0.03em;
  line-height: 1.6; padding: 0 4px;
}

/* ===== INLINE IMAGES ===== */
.inline-image {
  float: right; width: 300px;
  margin: 4px 0 16px 24px; border-radius: 3px; overflow: hidden;
}
.inline-image.float-left {
  float: left; margin: 4px 24px 16px 0;
}
.inline-image.expandable { cursor: zoom-in; }
.inline-image .img-frame {
  width: 100%; border: 1px solid var(--border-subtle);
  border-radius: 3px; overflow: hidden; background: var(--bg-secondary);
}
.inline-image.expandable .img-frame { border-color: var(--accent-color-dim); }
.inline-image .img-frame img { width: 100%; height: auto; display: block; }
.inline-caption {
  margin-top: 5px; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem; font-weight: 400;
  color: var(--text-tertiary); letter-spacing: 0.02em; line-height: 1.5;
}

/* ===== GROUPS LIST ===== */
.groups-list {
  margin-top: 16px; padding-top: 12px;
  border-top: 1px solid var(--border-faint);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem; color: var(--text-tertiary);
  letter-spacing: 0.03em; line-height: 1.7;
}
.groups-list strong { color: var(--text-secondary); font-weight: 400; }

/* ===== GALLERY ITEMS ===== */
.gallery-item {
  border-radius: 3px; overflow: hidden; background: var(--bg-secondary);
}
.gallery-item.expandable { cursor: zoom-in; }
.gallery-item .img-frame {
  border: 1px solid var(--border-subtle); border-radius: 3px; overflow: hidden;
}
.gallery-item.expandable .img-frame,
.gallery-item.gold-frame .img-frame,
.gallery-item.accent-frame .img-frame {
  border-color: var(--accent-color-dim);
}
.gallery-item .img-frame img {
  width: 100%; height: auto; display: block;
  aspect-ratio: 1 / 1; object-fit: cover;
}
.gallery-caption {
  padding: 6px 4px 2px; font-family: 'IBM Plex Mono', monospace;
  font-size: 0.6rem; color: var(--text-tertiary);
  letter-spacing: 0.02em; line-height: 1.4;
}

/* ===== EXPAND/COLLAPSE TOGGLE ===== */
.detail-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer;
  background: var(--accent-color-faint);
  border: 1px solid rgba(200, 194, 180, 0.15);
  border-radius: 4px; padding: 8px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem; font-weight: 400;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-color-dim);
  margin-top: 16px; margin-bottom: 20px;
  transition: color 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}
.detail-toggle:hover {
  color: var(--accent-color);
}
.detail-toggle .toggle-icon {
  font-size: 0.72rem; transition: transform 0.3s ease; display: inline-block;
}
.detail-toggle.open .toggle-icon { transform: rotate(45deg); }
.detail-toggle .toggle-label-collapse { display: none; }
.detail-toggle.open .toggle-label-expand { display: none; }
.detail-toggle.open .toggle-label-collapse { display: inline; }

.detail-content {
  max-height: 0; overflow: hidden;
  transition: max-height 0.6s ease, margin-top 0.3s ease;
  margin-top: 0;
}
.detail-content.open { max-height: 2000px; margin-top: 16px; }
.detail-content .detail-body {
  padding: 16px 0 8px 16px;
  border-left: 2px solid var(--accent-color-dim);
}
.detail-content .detail-body p {
  font-size: 0.9rem; color: var(--text-secondary);
  line-height: 1.8; margin-bottom: 16px;
}
.detail-content .detail-body p:last-child { margin-bottom: 0; }
.detail-content .detail-body p strong { color: var(--text-primary); font-weight: 400; }

.detail-content .detail-image {
  width: 100%; margin: 12px 0; overflow: hidden;
  border-radius: 3px; border: 1px solid var(--accent-color-dim);
  background: var(--bg-secondary);
}
.detail-content .detail-image.expandable { cursor: zoom-in; }
.detail-content .detail-image img { width: 100%; height: auto; display: block; }
.detail-content .detail-image-caption {
  margin-top: 5px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem; font-weight: 400;
  color: var(--text-tertiary); letter-spacing: 0.02em; line-height: 1.5;
}

/* ===== HIERARCHY TREE ===== */
.tree-section {
  margin: 56px 0; max-width: 720px;
  margin-left: auto; margin-right: auto;
}
.tree-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem; font-weight: 400;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-dim); margin-bottom: 20px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-faint);
}
.tree {
  padding: 24px 28px; background: #141418;
  border: 1px solid var(--accent-gold-dim);
  border-radius: 2px; max-width: 480px; margin: 0 auto;
}
.tree-root-label {
  font-family: 'Fraunces', serif; font-size: 1.2rem;
  font-weight: 400; color: var(--text-primary); margin-bottom: 4px;
}
.tree-root-meta {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.68rem;
  color: var(--text-tertiary); letter-spacing: 0.04em; margin-bottom: 20px;
}
.tree-branches { padding-left: 20px; border-left: 1px solid var(--border-subtle); }
.tree-sc { position: relative; margin-bottom: 4px; }
.tree-sc:last-child { margin-bottom: 0; }
.tree-sc::before {
  content: ''; position: absolute; left: -20px; top: 16px;
  width: 16px; height: 1px; background: var(--border-subtle);
}
.tree-sc-header {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; cursor: pointer; border-radius: 3px;
  transition: background 0.2s ease; user-select: none;
}
.tree-sc-header:hover { background: var(--bg-tertiary); }
.tree-sc-indicator {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.7rem;
  color: var(--text-tertiary); transition: transform 0.25s ease;
  flex-shrink: 0; width: 12px; text-align: center;
}
.tree-sc.expanded .tree-sc-indicator { transform: rotate(90deg); }
.tree-sc-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tree-sc-dot.virgo { background: var(--sc-virgo); }
.tree-sc-dot.hydra { background: var(--sc-hydra); }
.tree-sc-dot.centaurus { background: var(--sc-centaurus); }
.tree-sc-dot.pavo { background: var(--sc-pavo); }
.tree-sc-name {
  font-family: 'Fraunces', serif; font-size: 1.05rem; font-weight: 400;
  color: var(--text-primary); text-decoration: none; transition: color 0.2s ease;
}
a.tree-sc-name:hover { color: var(--accent); }
.tree-sc-distance {
  font-family: 'IBM Plex Mono', monospace; font-size: 0.65rem;
  color: var(--text-tertiary); letter-spacing: 0.03em; margin-left: auto;
}
.tree-regions {
  max-height: 0; overflow: hidden;
  transition: max-height 0.35s ease; padding-left: 30px;
}
.tree-sc.expanded .tree-regions { max-height: 500px; }
.tree-region {
  position: relative; padding: 3px 0 3px 16px;
  border-left: 1px solid var(--border-faint);
}
.tree-region::before {
  content: ''; position: absolute; left: 0; top: 12px;
  width: 12px; height: 1px;
}
.tree-region.virgo::before { background: var(--sc-virgo-dim); }
.tree-region.hydra::before { background: var(--sc-hydra-dim); }
.tree-region.centaurus::before { background: var(--sc-centaurus-dim); }
.tree-region.pavo::before { background: var(--sc-pavo-dim); }
.tree-region a {
  font-family: 'IBM Plex Sans', sans-serif; font-size: 0.82rem;
  font-weight: 300; color: var(--text-secondary);
  text-decoration: none; transition: color 0.2s ease;
}
.tree-region a:hover { color: var(--text-primary); }

/* ===== FOOTER ===== */
.page-footer {
  margin-top: 64px; padding: 24px 0 48px;
  border-top: 1px solid var(--border-faint);
  max-width: 720px; margin-left: auto; margin-right: auto;
}
.footer-attribution {
  font-size: 0.75rem; color: var(--text-tertiary);
  font-style: italic; line-height: 1.7; margin-bottom: 16px;
}
.footer-attribution a { color: var(--accent-dim); text-decoration: none; }
.footer-attribution a:hover { color: var(--accent); }
.footer-references {
  font-size: 0.7rem; color: var(--text-tertiary);
  line-height: 1.8; font-family: 'IBM Plex Sans', sans-serif; font-weight: 300;
}
.footer-references .ref-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem; color: var(--accent-color-dim); margin-right: 4px;
}

/* ===== LIGHTBOX ===== */
.lightbox {
  display: none; position: fixed; inset: 0; z-index: 1000;
  background: rgba(10, 10, 14, 0.92);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  cursor: zoom-out; align-items: center; justify-content: center; padding: 24px;
}
.lightbox.active { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  border-radius: 2px; box-shadow: 0 0 60px rgba(0, 0, 0, 0.5);
}
.lightbox-close {
  position: absolute; top: 20px; right: 24px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-tertiary); background: none; border: none;
  cursor: pointer; transition: color 0.2s ease; padding: 8px;
}
.lightbox-close:hover { color: var(--text-primary); }

/* ===== FIELD GUIDE GALLERY LINK ===== */
.field-guide-gallery-link {
  display: inline-block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem; font-weight: 400;
  letter-spacing: 0.1em; text-transform: uppercase;
  text-decoration: none;
  color: var(--accent-color-dim);
  transition: color 0.3s ease;
}
.field-guide-gallery-link:hover { color: var(--accent-color); }
.field-guide-gallery-link::after { content: ' →'; }

/* ===== RESPONSIVE — SUBPAGES ===== */
@media (max-width: 600px) {
  .inline-image, .inline-image.float-left { float: none; width: 100%; margin: 20px 0; }
  .hero-title { font-size: 2.2rem; }
  .hero { padding: 48px 0 16px; }
  .chart-section { margin: 32px 0; }
  .text-section { margin: 40px 0; }
  .tree { padding: 18px 16px; }
  .tree-branches { padding-left: 14px; }
  .tree-regions { padding-left: 20px; }
  .tree-sc-distance { display: none; }
}
