/* ===================================
   Investment Guide - Styles
   =================================== */

/* --- Variables --- */
:root {
  --white: #ffffff;
  --bg: #ffffff;
  --bg-sidebar: #f9fafb;
  --bg-code: #f4f5f7;
  --bg-callout-blue: #eff6ff;
  --bg-callout-amber: #fffbeb;
  --bg-callout-green: #f0fdf4;
  --bg-callout-gray: #f8fafc;
  --border: #e5e7eb;
  --border-light: #f0f0f0;
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-link: #4f46e5;
  --text-link-hover: #4338ca;
  --accent: #4f46e5;
  --accent-light: #eef2ff;
  --green: #059669;
  --amber: #d97706;
  --sidebar-width: 260px;
  --header-height: 56px;
}

/* --- Reset & Base --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 24px);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--text-primary);
  background: var(--bg);
  line-height: 1.7;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* --- Header --- */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 24px;
}

.header-logo {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

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

.header-tag {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 10px;
  letter-spacing: 0.02em;
}

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

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.sidebar-section {
  padding: 0 20px;
  margin-bottom: 20px;
}

.sidebar-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 0 8px 0;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li {
  margin: 1px 0;
}

.sidebar-nav a {
  display: block;
  padding: 6px 10px;
  font-size: 0.84rem;
  font-weight: 400;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1.45;
}

.sidebar-nav a:hover {
  color: var(--text-primary);
  background: rgba(0, 0, 0, 0.04);
}

.sidebar-nav a.active {
  color: var(--accent);
  background: var(--accent-light);
  font-weight: 500;
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

.content {
  max-width: 720px;
  padding: 40px 48px 80px;
}

.content h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}

.content h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 48px 0 16px;
  padding-top: 32px;
  border-top: 1px solid var(--border-light);
}

.content h2:first-of-type {
  border-top: none;
  padding-top: 0;
  margin-top: 32px;
}

.content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 32px 0 12px;
  letter-spacing: -0.01em;
}

.content p {
  color: var(--text-secondary);
  margin-bottom: 16px;
  font-weight: 400;
}

.content p strong {
  color: var(--text-primary);
  font-weight: 600;
}

.content > .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: 32px;
  line-height: 1.65;
}

.section-anchor {
  display: block;
  height: 0;
  visibility: hidden;
}

/* --- Callouts --- */
.callout {
  padding: 16px 18px;
  border-radius: 8px;
  margin: 20px 0;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.callout strong {
  color: var(--text-primary);
}

.callout-blue {
  background: var(--bg-callout-blue);
  border-left: 3px solid #6366f1;
}

.callout-amber {
  background: var(--bg-callout-amber);
  border-left: 3px solid var(--amber);
}

.callout-green {
  background: var(--bg-callout-green);
  border-left: 3px solid var(--green);
}

.callout-gray {
  background: var(--bg-callout-gray);
  border-left: 3px solid var(--border);
}

/* --- Cards --- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 20px 0;
}

.card-grid-2 {
  grid-template-columns: 1fr 1fr;
}

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  transition: border-color 0.15s;
}

.card:hover {
  border-color: #c7c9ce;
}

.card-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 6px;
}

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.card-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.card-desc strong {
  color: var(--text-primary);
  font-weight: 600;
}

.card-highlight {
  border-color: var(--accent);
  border-width: 1.5px;
  background: #fcfcff;
}

/* --- Steps --- */
.steps {
  margin: 20px 0;
}

.step {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}

.step:last-child {
  border-bottom: none;
}

.step-n {
  width: 28px;
  height: 28px;
  min-width: 28px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 500;
  margin-top: 2px;
}

.step-body h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.step-body p {
  font-size: 0.86rem;
  margin-bottom: 0;
}

/* --- Tables --- */
.table-wrap {
  margin: 20px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

thead {
  background: var(--bg-sidebar);
}

th {
  text-align: left;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background: #fafbfc;
}

/* --- Utility classes --- */
.mono {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 500;
}

.sym {
  color: var(--accent);
}

.pct {
  color: var(--text-primary);
  font-weight: 600;
}

.text-green {
  color: var(--green);
}

.weight-vis {
  display: flex;
  align-items: center;
  gap: 8px;
}

.weight-bar {
  height: 5px;
  border-radius: 3px;
  background: var(--accent);
  opacity: 0.5;
}

/* --- ETF Blocks --- */
.etf-block {
  margin: 16px 0;
  padding: 20px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.etf-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.etf-sym {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 4px;
}

.etf-pct {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--amber);
  background: var(--bg-callout-amber);
  padding: 3px 10px;
  border-radius: 4px;
  font-weight: 500;
}

.etf-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.etf-desc {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.etf-desc strong {
  color: var(--text-primary);
}

.etf-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.etf-tag {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
}

/* --- DCA Visual --- */
.dca-visual {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
}

.dca-visual h4 {
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dca-visual .dca-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.dca-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.dca-input-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.dca-input-wrap {
  position: relative;
  flex: 1;
  max-width: 200px;
}

.dca-input-prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dca-input {
  width: 100%;
  padding: 9px 12px 9px 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
}

.dca-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.dca-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.dca-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

.dca-item .sym {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 500;
}

.dca-item .amt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 2px;
}

.dca-item .pctlabel {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* --- CTA Block --- */
.cta-block {
  margin: 32px 0;
  padding: 28px;
  background: var(--accent-light);
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  text-align: center;
}

.cta-block h3 {
  margin: 0 0 8px;
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 1.2rem;
}

.cta-block p {
  font-size: 0.88rem;
  max-width: 440px;
  margin: 0 auto 18px;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 22px;
  background: var(--accent);
  color: var(--white);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: background 0.15s;
}

.cta-btn:hover {
  background: var(--text-link-hover);
}

/* --- Calculator --- */
.calc-box {
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  margin: 24px 0;
}

.calc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.calc-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.calc-field input,
.calc-field select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.calc-field input:focus,
.calc-field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

.calc-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.calc-btn:hover {
  background: var(--text-link-hover);
}

.calc-results {
  display: none;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.calc-results.show {
  display: block;
}

.results-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.result-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
}

.result-item .rlabel {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.result-item .rval {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.2rem;
  font-weight: 600;
}

.rval-indigo {
  color: var(--accent);
}

.rval-green {
  color: var(--green);
}

.rval-amber {
  color: var(--amber);
}

.rval-dark {
  color: var(--text-primary);
}

/* --- Chart --- */
.chart-wrap {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-top: 16px;
}

.chart-wrap canvas {
  width: 100% !important;
  max-height: 280px;
}

/* --- Footer --- */
.footer-doc {
  margin-top: 48px;
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-doc p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* --- Inline links --- */
a.inline-link {
  color: var(--text-link);
  text-decoration: none;
  font-weight: 500;
}

a.inline-link:hover {
  text-decoration: underline;
  color: var(--text-link-hover);
}

/* --- AI prompt block --- */
.ai-prompt {
  color: var(--text-primary);
  background: var(--bg-code);
  padding: 8px 12px;
  border-radius: 4px;
  display: block;
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.6;
  font-style: italic;
}

/* --- FAQ --- */
.faq-list {
  margin: 20px 0;
}

.faq-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}

.faq-item:hover {
  border-color: #c7c9ce;
}

.faq-item[open] {
  border-color: var(--accent);
}

.faq-question {
  padding: 16px 20px;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-primary);
  user-select: none;
}

.faq-question::-webkit-details-marker {
  display: none;
}

.faq-question::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 300;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.faq-item[open] .faq-question::after {
  content: '−';
  color: var(--accent);
}

.faq-answer {
  padding: 0 20px 16px;
}

.faq-answer p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 8px;
}

.faq-answer p:last-child {
  margin-bottom: 0;
}

/* --- Mobile toggle --- */
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(79, 70, 229, 0.3);
  align-items: center;
  justify-content: center;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 90;
    background: var(--white);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  }

  .main {
    margin-left: 0;
  }

  .content {
    padding: 32px 20px 80px;
  }

  .mobile-toggle {
    display: flex;
  }

  .calc-fields {
    grid-template-columns: 1fr;
  }

  .card-grid-2 {
    grid-template-columns: 1fr;
  }

  .dca-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .results-row {
    grid-template-columns: 1fr;
  }
}
