/* ========== CSS Variables ========== */
:root {
  --bg: #F8FAFB;
  --surface: #FFFFFF;
  --surface-alt: #F1F5F9;
  --surface-hover: #F8FAFC;
  --border: #E2E8F0;
  --border-hover: #CBD5E1;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-tertiary: #94A3B8;
  --accent: #2563EB;
  --accent-hover: #1D4ED8;
  --accent-light: #EFF6FF;
  --accent-rgb: 37, 99, 235;
  --bg-rgb: 248, 250, 251;
  --success: #16A34A;
  --success-light: #F0FDF4;
  --error: #DC2626;
  --error-light: #FEF2F2;
  --warning: #F59E0B;
  --warning-light: #FFFBEB;
  --star-fill: #F59E0B;
  --star-empty: #E2E8F0;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  letter-spacing: 0.02em;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover { color: var(--accent-hover); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ========== Layout ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.container-narrow {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ========== Navigation ========== */
.nav {
  position: sticky;
  top: 0;
  background: rgba(var(--bg-rgb), 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  padding: 16px 0;
  z-index: 100;
  transition: all 0.3s ease;
}

.nav.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.04);
}

.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}

.nav-logo svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

/* ========== Hero ========== */
.hero {
  padding: 100px 0 80px;
  text-align: center;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 24px;
}

.hero-title {
  font-size: 52px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 20px;
}

.hero-title span {
  color: var(--accent);
}

.hero-desc {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto 48px;
  line-height: 1.7;
}

/* ========== Search Box ========== */
.search-box {
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 18px 140px 18px 52px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  font-size: 18px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  transition: all 0.2s ease;
}
.search-input:hover {
  border-color: var(--border-hover);
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.1);
}
.search-input::placeholder {
  color: var(--text-tertiary);
  font-family: 'Noto Sans SC', sans-serif;
  font-size: 16px;
}

.search-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  padding: 10px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Noto Sans SC', sans-serif;
}
.search-btn:hover {
  background: var(--accent-hover);
}
.search-btn:disabled {
  background: var(--border);
  color: var(--text-tertiary);
  cursor: not-allowed;
}

.search-hint {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-tertiary);
}
.search-hint code {
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ========== Features ========== */
.features {
  padding: 80px 0;
  background: var(--surface);
}

.section-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

.section-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

.section-desc {
  font-size: 16px;
  color: var(--text-secondary);
  max-width: 560px;
  margin-bottom: 48px;
}

.features-header {
  text-align: center;
}

.features-header .section-desc {
  margin-left: auto;
  margin-right: auto;
}

.grid-features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.feature-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  transition: all 0.3s ease;
  text-align: center;
}
.feature-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06);
}

.feature-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-light);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: var(--accent);
}

.feature-card h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ========== How It Works ========== */
.how-it-works {
  padding: 80px 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
  margin-top: 48px;
}

.step {
  text-align: center;
  position: relative;
}

.step-number {
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  margin: 0 auto 20px;
  font-family: 'JetBrains Mono', monospace;
}

.step h3 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.step p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.step-arrow {
  position: absolute;
  right: -20px;
  top: 24px;
  color: var(--text-tertiary);
  display: none;
}

/* ========== Books ========== */
.books {
  padding: 80px 0;
  background: var(--surface);
}

.book-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 32px;
}

.book-tag {
  padding: 8px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.2s;
}
.book-tag:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

/* ========== Footer ========== */
.footer {
  padding: 40px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 14px;
  color: var(--text-tertiary);
}

.footer a { color: var(--text-secondary); }
.footer a:hover { color: var(--accent); }

/* ========== Analysis Page ========== */
.analysis-header {
  padding: 32px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.analysis-search {
  display: flex;
  gap: 12px;
  max-width: 480px;
}

.analysis-search .search-input {
  padding: 12px 16px 12px 44px;
  font-size: 16px;
  border-radius: 12px;
}

.analysis-search .search-btn {
  position: static;
  transform: none;
  white-space: nowrap;
  padding: 12px 24px;
}

.analysis-content {
  padding: 40px 0 80px;
}

/* Loading State */
.loading-container {
  padding: 48px 0;
}

.loading-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 16px;
}

.skeleton {
  background: linear-gradient(90deg,
    var(--surface-alt) 25%,
    var(--surface) 50%,
    var(--surface-alt) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  height: 16px;
  margin-bottom: 12px;
}
.skeleton.w-60 { width: 60%; }
.skeleton.w-80 { width: 80%; }
.skeleton.w-40 { width: 40%; }
.skeleton.h-24 { height: 24px; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Fund Info Card */
.fund-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.fund-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.fund-name {
  font-size: 22px;
  font-weight: 700;
}

.fund-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--text-tertiary);
  background: var(--surface-alt);
  padding: 4px 12px;
  border-radius: 8px;
}

.fund-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
}

.fund-stat {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border-radius: 12px;
}

.fund-stat-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
  font-weight: 500;
}

.fund-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 600;
}

.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

/* Report Content */
.report-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  line-height: 1.8;
}

.report-container h2 {
  font-size: 24px;
  font-weight: 700;
  margin: 40px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}
.report-container h2:first-child { margin-top: 0; }

.report-container h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 12px;
}

.report-container h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 8px;
}

.report-container p {
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.report-container strong {
  color: var(--text);
}

.report-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 14px;
}

.report-container th {
  background: var(--surface-alt);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.report-container td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.report-container tr:hover td {
  background: var(--surface-hover);
}

.report-container blockquote {
  border-left: 3px solid var(--warning);
  background: var(--warning-light);
  padding: 16px 20px;
  border-radius: 0 12px 12px 0;
  margin: 16px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.report-container ul, .report-container ol {
  padding-left: 24px;
  margin-bottom: 12px;
}

.report-container li {
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.report-container code {
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

.report-container hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

/* Typing cursor */
.typing-cursor::after {
  content: '▊';
  animation: blink 0.8s infinite;
  color: var(--accent);
  font-size: 14px;
}
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Error State */
.error-box {
  background: var(--error-light);
  border: 1px solid var(--error);
  border-radius: 12px;
  padding: 20px 24px;
  color: var(--error);
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-tertiary);
}

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 20px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-error { background: var(--error-light); color: var(--error); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* ========== Animations ========== */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

.reveal-stagger.in-view > *:nth-child(1) { transition-delay: 0s; }
.reveal-stagger.in-view > *:nth-child(2) { transition-delay: 0.08s; }
.reveal-stagger.in-view > *:nth-child(3) { transition-delay: 0.08s; }
.reveal-stagger.in-view > *:nth-child(4) { transition-delay: 0.16s; }
.reveal-stagger.in-view > *:nth-child(5) { transition-delay: 0.24s; }
.reveal-stagger.in-view > *:nth-child(6) { transition-delay: 0.32s; }

.reveal-stagger > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.reveal-stagger.in-view > * {
  opacity: 1;
  transform: translateY(0);
}

/* ========== Responsive ========== */
@media (min-width: 769px) {
  .step-arrow { display: block; }
}

@media (max-width: 1024px) {
  .grid-features { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .hero { padding: 60px 0 48px; }
  .hero-title { font-size: 32px; }
  .hero-desc { font-size: 16px; }
  .search-input {
    font-size: 16px;
    padding: 16px 16px 16px 44px;
  }
  .search-btn {
    position: static;
    transform: none;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border-radius: 12px;
  }
  .search-box {
    display: flex;
    flex-direction: column;
  }
  .search-box .search-icon {
    top: 28px;
  }
  .grid-features { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; gap: 24px; }
  .step-arrow { display: none !important; }
  .container { padding: 0 16px; }
  .container-narrow { padding: 0 16px; }
  .features, .how-it-works, .books { padding: 48px 0; }
  .report-container { padding: 20px; }
  .report-container table { font-size: 12px; display: block; overflow-x: auto; }
  .fund-stats { grid-template-columns: repeat(2, 1fr); }
  .analysis-search { flex-direction: column; }
  .nav-links { display: none; }
  .fund-info-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .reveal-stagger > * { opacity: 1; transform: none; }
}
