/* =========================================
   SkillOpt — Styles
   Inspired by autoresearch.lol design system
   ========================================= */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #0f0f18;
  --bg-card: #13131f;
  --bg-card-hover: #1a1a2e;
  --border-color: #1e1e32;
  --border-hover: #2a2a45;
  --text-primary: #ededef;
  --text-secondary: #888899;
  --text-muted: #555566;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.15);
  --green: #00d4aa;
  --green-dim: rgba(0, 212, 170, 0.12);
  --red-dim: rgba(255, 107, 107, 0.08);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --max-width: 1060px;
  --nav-height: 64px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--nav-height);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

/* =========================================
   Navigation
   ========================================= */

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.nav-links::-webkit-scrollbar {
  display: none;
}

.nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  flex-direction: column;
  gap: 4px;
}

.nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 2px;
  transition: 0.2s;
}

/* =========================================
   Buttons
   ========================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  border: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #7c6df7;
  box-shadow: 0 0 24px var(--accent-glow);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-outline:hover {
  border-color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
}

.btn-sm {
  font-size: 13px;
  padding: 6px 14px;
  height: 34px;
}

.btn-lg {
  font-size: 15px;
  padding: 10px 24px;
  height: 44px;
}

/* =========================================
   Tags
   ========================================= */

.tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.tag-purple {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-light);
  border: 1px solid rgba(108, 92, 231, 0.25);
}

.tag-outline {
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

/* =========================================
   Sections
   ========================================= */

.section {
  padding: 100px 24px;
  border-bottom: 1px solid var(--border-color);
}

.section-dark {
  background: var(--bg-secondary);
}

.section-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.section-header {
  margin-bottom: 56px;
  max-width: 720px;
}

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

.section-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.section-desc {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* =========================================
   Hero
   ========================================= */

.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 100px 24px 80px;
  position: relative;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 40%, rgba(108, 92, 231, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 70% 60%, rgba(162, 155, 254, 0.05), transparent),
    radial-gradient(ellipse 50% 50% at 30% 70%, rgba(108, 92, 231, 0.04), transparent);
  pointer-events: none;
}

.hero-content {
  position: relative;
  text-align: center;
  max-width: 720px;
}

.hero-title {
  margin-bottom: 24px;
}

.gradient-text {
  display: block;
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -2px;
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.1;
}

.hero-subtitle {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 8px;
  letter-spacing: -0.2px;
}

.hero-desc {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 36px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 48px;
}

.hero-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  flex-wrap: wrap;
}

.meta-item {
  text-align: center;
}

.meta-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.meta-value {
  display: block;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

/* =========================================
   Loop grid
   ========================================= */

.loop-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}

.loop-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  transition: all 0.25s;
}

.loop-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
}

.loop-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.loop-icon-rollout { background: rgba(108, 92, 231, 0.12); color: var(--accent-light); }
.loop-icon-reflect { background: rgba(0, 212, 170, 0.1); color: var(--green); }
.loop-icon-edit    { background: rgba(255, 159, 67, 0.1); color: #ff9f43; }
.loop-icon-gate    { background: rgba(108, 92, 231, 0.12); color: var(--accent-light); }

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

.loop-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.loop-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding-top: 44px;
}

/* =========================================
   Feature / Pillar grid
   ========================================= */

.feature-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 40px;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
}

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

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

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.pillar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.pillar-number {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.5;
  margin-bottom: 12px;
  font-feature-settings: "tnum";
}

.pillar-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.pillar-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =========================================
   Method grid
   ========================================= */

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.method-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
}

.method-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--accent-light);
}

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

/* =========================================
   Tables
   ========================================= */

.table-wrapper {
  overflow-x: auto;
  margin-bottom: 40px;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  white-space: nowrap;
}

.results-table thead th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.results-table thead th:first-child {
  border-radius: var(--radius-md) 0 0 0;
}

.results-table thead th:last-child {
  border-radius: 0 var(--radius-md) 0 0;
}

.results-table tbody tr {
  transition: background 0.15s;
}

.results-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

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

.results-table tbody td:first-child {
  font-weight: 500;
  color: var(--text-primary);
}

.gain {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}

.gain.highlight {
  color: var(--green);
}

.model-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.result-summary {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.result-stat {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 8px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* =========================================
   Insights
   ========================================= */

.insight-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 40px;
}

.insight-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.insight-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.insight-bounded { background: rgba(108, 92, 231, 0.1); color: var(--accent-light); }
.insight-gated   { background: rgba(0, 212, 170, 0.1); color: var(--green); }
.insight-buffered { background: rgba(255, 159, 67, 0.1); color: #ff9f43; }

.insight-card h4 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
}

.insight-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* =========================================
   Evolution
   ========================================= */

.evolution-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.evolution-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.evolution-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.evolution-legend {
  display: flex;
  gap: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-train { background: var(--accent-light); }
.dot-sel   { background: var(--green); }

.evolution-chart {
  margin-bottom: 24px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.chart-bars::before {
  content: '';
  display: flex;
  gap: 8px;
  width: 100%;
  height: 100%;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

/* We style bars inline via JS, provide fallback */
.chart-bars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 200px;
  margin-bottom: 8px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}

.bar-train {
  width: 60%;
  max-width: 36px;
  background: linear-gradient(to top, var(--accent), var(--accent-light));
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.bar-sel {
  width: 60%;
  max-width: 36px;
  background: linear-gradient(to top, #00b894, var(--green));
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  min-height: 4px;
}

.bar-value {
  position: absolute;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.evolution-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.meta-row {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.meta-key {
  font-weight: 600;
  color: var(--text-primary);
  margin-right: 8px;
}

/* =========================================
   Transfer
   ========================================= */

.transfer-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.transfer-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
}

.transfer-value {
  display: block;
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-light), var(--green));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.1;
}

.transfer-card p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 16px;
}

.transfer-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  background: rgba(108, 92, 231, 0.08);
  border-radius: 12px;
}

.transfer-note {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

/* =========================================
   Citation
   ========================================= */

.citation-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.citation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}

.citation-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.citation-card pre {
  padding: 24px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-secondary);
  -webkit-overflow-scrolling: touch;
}

.citation-card code {
  color: var(--text-secondary);
}

/* =========================================
   Footer
   ========================================= */

.footer {
  padding: 48px 24px;
  border-top: 1px solid var(--border-color);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.footer-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.footer-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--text-primary);
}

.footer-bottom {
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.footer-bottom p {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================
   Responsive
   ========================================= */

@media (max-width: 1024px) {
  .loop-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .loop-arrow {
    display: none;
  }
  .pillar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .transfer-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 900px) {
  .nav-links {
    display: none;
  }
  .nav-links.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: rgba(10, 10, 15, 0.98);
    backdrop-filter: blur(16px);
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    gap: 4px;
  }
  .nav-toggle {
    display: flex;
  }
  .hero-meta {
    gap: 24px;
  }
  .gradient-text {
    font-size: 44px;
  }
  .section-title {
    font-size: 26px;
  }
}

@media (max-width: 640px) {
  .section {
    padding: 60px 20px;
  }
  .loop-grid {
    grid-template-columns: 1fr;
  }
  .pillar-grid {
    grid-template-columns: 1fr;
  }
  .method-grid {
    grid-template-columns: 1fr;
  }
  .insight-grid {
    grid-template-columns: 1fr;
  }
  .transfer-grid {
    grid-template-columns: 1fr;
  }
  .result-summary {
    flex-direction: column;
  }
  .nav-actions .btn {
    font-size: 12px;
    padding: 5px 10px;
  }
  .gradient-text {
    font-size: 36px;
  }
  .hero-subtitle {
    font-size: 15px;
  }
  .hero-actions {
    flex-direction: column;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .hero-meta {
    gap: 16px;
  }
  .section-title {
    font-size: 22px;
  }
  .evolution-header {
    flex-direction: column;
  }
  .footer-top {
    flex-direction: column;
  }
}

/* Toast for copy */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
