/* ==========================================================================
   Faana Growth OS Platform Guide — Styles
   Brand: Ink (#1B2A4A), Teal (#2EC4B6), Stone (#F5F0EB), Coral (#FF6B6B)
   ========================================================================== */

/* --- CSS Variables --- */
:root {
  --ink: #1B2A4A;
  --ink-light: #2A3D66;
  --teal: #2EC4B6;
  --teal-dark: #25A89C;
  --stone: #F5F0EB;
  --stone-dark: #E8E0D8;
  --coral: #FF6B6B;
  --coral-dark: #E55A5A;
  --white: #FFFFFF;
  --text: #2D3748;
  --text-light: #718096;
  --border: #E2E8F0;
  --code-bg: #F7FAFC;
  --sidebar-w: 280px;
  --header-h: 64px;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(27,42,74,0.08);
  --shadow-md: 0 4px 12px rgba(27,42,74,0.1);
  --shadow-lg: 0 8px 24px rgba(27,42,74,0.12);
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 24px);
  font-size: 16px;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--white);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.5em;
}

h1 { font-size: 2.25rem; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; letter-spacing: -0.01em; border-bottom: 2px solid var(--teal); padding-bottom: 0.4em; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.1rem; color: var(--ink-light); }

p { margin: 0 0 1em; }

a {
  color: var(--teal-dark);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
a:hover { border-bottom-color: var(--teal); }

strong { font-weight: 600; }
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--ink);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* --- Site Header --- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--ink);
  color: var(--white);
  display: flex;
  align-items: center;
  padding: 0 24px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(27,42,74,0.2);
}

.site-header .logo {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-header .logo span {
  color: var(--teal);
}

.site-header .subtitle {
  margin-left: 16px;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.78);
}

.site-header .version {
  margin-left: auto;
  font-size: 0.75rem;
  background: rgba(255,255,255,0.12);
  padding: 4px 10px;
  border-radius: 12px;
}

/* --- Sidebar / TOC --- */
.sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--header-h));
  background: var(--stone);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 0;
  z-index: 50;
}

.sidebar nav { padding: 0 16px; }

.sidebar .toc-section {
  margin-bottom: 4px;
}

.sidebar .toc-section > a {
  display: block;
  padding: 8px 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink);
  border-radius: 6px;
  border-bottom: none;
}

.sidebar .toc-section > a:hover {
  background: var(--stone-dark);
}

.sidebar .toc-section > a.active {
  background: var(--teal);
  color: var(--white);
}

.sidebar .toc-sub {
  list-style: none;
  padding: 0;
  margin: 0 0 0 12px;
}

.sidebar .toc-sub li a {
  display: block;
  padding: 4px 12px;
  font-size: 0.8rem;
  color: #4A5568;
  border-radius: 4px;
  border-bottom: none;
}

.sidebar .toc-sub li a:hover {
  color: var(--ink);
  background: var(--stone-dark);
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 40px 48px 80px;
  max-width: 960px;
}

/* --- Hero Section --- */
.hero {
  background: linear-gradient(135deg, var(--ink) 0%, var(--ink-light) 100%);
  color: var(--white);
  padding: 48px;
  border-radius: var(--radius);
  margin-bottom: 48px;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(46,196,182,0.2) 0%, transparent 70%);
  border-radius: 50%;
}

.hero h1 {
  color: var(--white);
  margin-top: 0;
  font-size: 2.5rem;
}

.hero .tagline {
  font-size: 1.15rem;
  color: rgba(255,255,255,0.8);
  max-width: 600px;
  line-height: 1.6;
}

.hero .badge-row {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-complete { background: #C6F6D5; color: #22543D; }
.badge-partial  { background: #FEFCBF; color: #744210; }
.badge-planned  { background: #E9D8FD; color: #553C9A; }
.badge-stub     { background: #FED7D7; color: #9B2C2C; }
.badge-deprecated { background: #E2E8F0; color: #4A5568; text-decoration: line-through; }
.badge-teal     { background: var(--teal); color: var(--white); }
.badge-ink      { background: var(--ink); color: var(--white); }
.badge-coral    { background: var(--coral); color: var(--white); }

/* --- Cards --- */
/* --- Feature Grid --- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.feature-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.feature-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--teal);
}

.feature-card h4 {
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--text-light);
  margin: 0;
}

/* --- Screenshot Figures --- */
.screenshot {
  margin: 24px 0;
  text-align: center;
}

.screenshot img {
  max-width: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.screenshot.mobile img {
  width: 100%;
  max-width: 320px;
}

.screenshot figcaption {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
}

/* --- Diagram Figures --- */
.diagram {
  margin: 32px 0;
  text-align: center;
}

.diagram img {
  max-width: 100%;
  border-radius: var(--radius);
  background: var(--white);
}

.diagram figcaption {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
}

/* --- Architecture Diagram (HTML/CSS) --- */
.arch-diagram {
  margin: 32px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 24px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}

.arch-diagram .arch-caption {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 24px;
  margin-bottom: 0;
}

.arch-tiers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 800px;
  margin: 0 auto;
}

.arch-tier {
  display: flex;
  align-items: stretch;
  gap: 0;
}

.arch-tier-label {
  min-width: 120px;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--white);
  display: flex;
  align-items: center;
  border-radius: var(--radius) 0 0 var(--radius);
  flex-shrink: 0;
}

.arch-tier-label.tier-frontend { background: var(--teal-dark); }
.arch-tier-label.tier-api { background: var(--ink); }
.arch-tier-label.tier-data { background: #4A6FA5; }
.arch-tier-label.tier-ai { background: var(--coral-dark); }
.arch-tier-label.tier-infra { background: #6B7280; }

.arch-tier-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  flex: 1;
  background: var(--stone);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  align-items: center;
}

.arch-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  color: var(--text);
}

.arch-arrow {
  display: flex;
  justify-content: center;
  padding: 2px 0;
  color: var(--text-light);
  font-size: 0.9rem;
}

/* --- Data Pipeline Diagram (HTML/CSS) --- */
.pipeline-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 24px 0;
  padding: 20px;
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  justify-content: center;
}

.pipeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 90px;
  text-align: center;
}

.pipeline-step .step-icon {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.pipeline-step .step-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink);
}

.pipeline-step .step-detail {
  font-size: 0.65rem;
  color: var(--text-light);
  margin-top: 2px;
}

.pipeline-arrow {
  color: var(--teal);
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* --- Entity Model Diagram (HTML/CSS) --- */
.entity-diagram {
  margin: 24px 0;
  padding: 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.entity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 700px;
  margin: 0 auto;
}

.entity-type-card {
  padding: 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  text-align: center;
}

.entity-type-card.org { border-color: var(--teal); background: rgba(46,196,182,0.06); }
.entity-type-card.person { border-color: var(--ink); background: rgba(27,42,74,0.04); }
.entity-type-card.program { border-color: var(--coral); background: rgba(255,107,107,0.06); }
.entity-type-card.community { border-color: #9F7AEA; background: rgba(159,122,234,0.06); }

.entity-type-card h4 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.entity-type-card p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-light);
}

.entity-relationships {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.entity-relationships .rel-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 4px 8px;
  font-size: 0.8rem;
  color: var(--text);
}

.entity-relationships .rel-label {
  padding: 2px 8px;
  background: var(--stone);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.7rem;
  color: var(--ink);
}

.entity-relationships .rel-arrow {
  color: var(--teal);
  font-weight: 700;
}

/* --- Tables --- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.9rem;
}

thead {
  background: var(--stone);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-weight: 600;
  color: var(--ink);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:hover { background: var(--stone); }

/* --- Collapsible Details --- */
details {
  background: var(--stone);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 16px 0;
  padding: 0;
}

details summary {
  padding: 14px 20px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

details summary::before {
  content: '▸ ';
  color: var(--teal);
}

details[open] summary::before {
  content: '▾ ';
}

details summary::-webkit-details-marker { display: none; }
details summary::marker { display: none; content: ''; }

details .details-content {
  padding: 0 20px 20px;
}

/* --- Callouts --- */
.callout {
  border-left: 4px solid var(--teal);
  background: rgba(46,196,182,0.06);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 16px 0;
}

.callout-title {
  font-weight: 600;
  color: var(--teal-dark);
  margin-bottom: 4px;
}

.callout.warning {
  border-left-color: var(--coral);
  background: rgba(255,107,107,0.06);
}

.callout.warning .callout-title {
  color: var(--coral-dark);
}

.callout.info {
  border-left-color: var(--ink);
  background: rgba(27,42,74,0.04);
}

.callout.info .callout-title {
  color: var(--ink);
}

/* --- Two-App Comparison --- */
.app-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}

.app-box {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.app-box.workbench {
  border-color: var(--teal);
  background: rgba(46,196,182,0.04);
}

.app-box.hub {
  border-color: var(--ink);
  background: rgba(27,42,74,0.03);
}

.app-box .app-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}

.app-box .app-desc {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* --- Glossary --- */
.glossary-term {
  margin-bottom: 20px;
}

.glossary-term dt {
  font-weight: 700;
  color: var(--ink);
  font-size: 1rem;
}

.glossary-term dd {
  margin: 4px 0 0 0;
  font-size: 0.9rem;
  color: var(--text);
}

/* --- API Link Button --- */
.api-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ink);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius);
  font-weight: 600;
  border: none;
}

.api-link:hover {
  background: var(--ink-light);
  border-bottom-color: transparent;
}

/* --- Lightbox (click-to-expand images) --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(27, 42, 74, 0.92);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-overlay img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 10000;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox-caption {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.85rem;
  max-width: 80vw;
  text-align: center;
  z-index: 10000;
  padding: 8px 16px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 6px;
}

/* Make all figure images show zoom cursor */
figure img {
  cursor: zoom-in;
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--white);
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 200;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .sidebar {
    width: 240px;
  }
  .main-content {
    margin-left: 240px;
    padding: 32px 32px 60px;
  }
}

/* --- Mobile Nav Toggle --- */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.9);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

@media (max-width: 768px) {
  .mobile-nav-toggle { display: block; }
  .sidebar {
    display: none;
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--header-h));
    z-index: 150;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    display: block;
  }
  .main-content {
    margin-left: 0;
    padding: 24px 20px 60px;
  }
  .app-compare {
    grid-template-columns: 1fr;
  }
  .hero { padding: 32px 24px; }
  .hero h1 { font-size: 1.75rem; }
}

/* --- Print --- */
@media print {
  .site-header,
  .sidebar,
  .back-to-top { display: none !important; }

  .main-content {
    margin-left: 0;
    padding: 0;
    max-width: 100%;
  }

  body { font-size: 11pt; }

  h2 { page-break-before: always; }
  h2:first-of-type { page-break-before: avoid; }

  .hero {
    background: var(--stone) !important;
    color: var(--ink) !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .hero h1 { color: var(--ink) !important; }
  .hero .tagline { color: var(--text) !important; }

  .screenshot img { max-width: 80%; box-shadow: none; }
  .screenshot.mobile img { max-width: 40%; }

  a[href^="http"]::after { content: ' (' attr(href) ')'; font-size: 0.8em; color: #999; }
  a[href^="#"]::after { content: none; }

  details { border: 1px solid #ccc; }
  details[open] summary { border-bottom: 1px solid #ccc; }

  .badge {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
