/* CSS Variables */
:root {
  --bg: #0a0a0a;
  --fg: #fafafa;
  --accent: #3b82f6;
  --muted: #71717a;
  --border: #27272a;
  --card: #18181b;
  --card-hover: #1f1f23;
}

html.light {
  --bg: #ffffff;
  --fg: #18181b;
  --accent: #2563eb;
  --muted: #71717a;
  --border: #e4e4e7;
  --card: #f4f4f5;
  --card-hover: #e4e4e7;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Open Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Typography */
h1, h2, h3 {
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

p {
  color: var(--muted);
  margin-bottom: 1rem;
}

strong {
  color: var(--fg);
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  background: var(--card);
  padding: 0.2em 0.5em;
  border-radius: 4px;
  color: var(--accent);
}

ul {
  list-style: none;
  padding-left: 0;
}

ul li {
  color: var(--muted);
  margin-bottom: 0.5rem;
  padding-left: 1em;
  position: relative;
}

ul li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* Sections */
.section {
  padding: 80px 0;
}

.section-intro {
  max-width: 700px;
  font-size: 1.1rem;
  margin-bottom: 2rem;
}

/* Hero */
.hero {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.hero-title {
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  background: linear-gradient(to right, var(--fg), var(--muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 1rem;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.md-badge {
  background: var(--card);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.text-link {
  font-size: 0.9rem;
  color: var(--muted);
}

.text-link:hover {
  color: var(--fg);
}

/* Grid Layouts */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
  }
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: border-color 0.2s ease;
}

.card:hover {
  border-color: var(--muted);
}

.card.small {
  padding: 1rem;
}

.card.text-center {
  text-align: center;
}

.card-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.accent-border {
  border-color: rgba(59, 130, 246, 0.3);
}

.accent-list li::before {
  color: var(--accent);
}

/* Syntax Demo */
.syntax-demo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
}

.syntax-demo .syntax {
  color: var(--accent);
}

.syntax-demo .content {
  color: var(--fg);
}

.syntax-demo .muted {
  color: var(--muted);
}

.syntax-demo .arrow {
  color: var(--muted);
  margin: 1rem 0;
}

.syntax-demo .rendered {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 1rem;
}

.syntax-demo .rendered-h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--fg);
}

/* Syntax Grid */
.syntax-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.syntax-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.syntax-card code {
  display: block;
  margin-bottom: 0.5rem;
  background: none;
  padding: 0;
}

.syntax-card span {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Demo Container */
.demo-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .demo-container {
    grid-template-columns: 1fr 1fr;
  }
}

.demo-pane {
  position: relative;
}

.demo-label {
  position: absolute;
  top: -1.5rem;
  left: 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#markdown-input {
  width: 100%;
  height: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  color: var(--muted);
  resize: none;
  outline: none;
}

#markdown-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

#markdown-output {
  height: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  overflow: auto;
}

/* Markdown Preview */
.markdown-preview h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.markdown-preview h2 {
  font-size: 1.4rem;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--fg);
}

.markdown-preview p {
  margin-bottom: 0.75rem;
  color: var(--muted);
}

.markdown-preview strong {
  color: var(--fg);
}

.markdown-preview code {
  background: var(--bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.85em;
}

.markdown-preview pre {
  background: var(--bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
}

.markdown-preview pre code {
  background: none;
  padding: 0;
  color: var(--muted);
}

.markdown-preview ul {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-preview blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  color: var(--muted);
  margin: 1rem 0;
}

.markdown-preview a {
  color: var(--accent);
  text-decoration: underline;
}

/* Code Block */
.code-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.code-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
}

.window-controls {
  display: flex;
  gap: 6px;
}

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

.dot.red { background: rgba(255, 95, 86, 0.8); }
.dot.yellow { background: rgba(255, 189, 46, 0.8); }
.dot.green { background: rgba(39, 201, 63, 0.8); }

.filename {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

.code-block pre {
  padding: 1rem;
  margin: 0;
  overflow-x: auto;
}

.code-block code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--muted);
  background: none;
  padding: 0;
  line-height: 1.5;
}

.code-block .hl {
  color: var(--accent);
}

/* Token Math */
.token-math {
  margin-top: 2rem;
}

.token-math h3 {
  margin-bottom: 1rem;
}

.token-math code {
  display: block;
  font-size: 0.85rem;
  word-break: break-all;
}

.token-math .accent {
  color: var(--accent);
}

/* Feature List */
.feature-list {
  margin: 1rem 0;
}

.feature-list li {
  padding-left: 0;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.feature-list li::before {
  display: none;
}

.feature-list .arrow {
  color: var(--accent);
  flex-shrink: 0;
}

/* Hierarchy List */
.hierarchy-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hierarchy-item {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

@media (min-width: 768px) {
  .hierarchy-item {
    grid-template-columns: 150px 120px 1fr;
    align-items: center;
    gap: 1rem;
  }
}

.hierarchy-item code {
  color: var(--accent);
}

.hierarchy-item .scope {
  font-size: 0.9rem;
  color: var(--muted);
}

.hierarchy-item .purpose {
  font-size: 0.9rem;
  color: var(--fg);
}

/* Wikilink Demo */
.wikilink-demo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.8;
}

.wikilink-demo .dim {
  color: var(--muted);
  opacity: 0.6;
}

/* File Tree */
.file-tree {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
}

.tree-item {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: default;
}

.tree-item:hover {
  background: var(--card-hover);
}

.tree-item span {
  margin-right: 0.5rem;
}

.tree-children {
  padding-left: 1.25rem;
}

.tree-item.highlight {
  color: #4ade80;
}

.tree-item.highlight span {
  color: inherit;
}

/* File Roles */
.file-roles {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.file-roles div {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.file-roles code {
  flex-shrink: 0;
  width: 150px;
}

.file-roles span {
  color: var(--muted);
}

/* Quote Card */
.quote-card {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(168, 85, 247, 0.1));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin-top: 2rem;
}

.quote-card p:first-child {
  font-size: 1.25rem;
  color: var(--fg);
  margin-bottom: 1rem;
}

/* Tips */
.tips-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.tip-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}

.tip-card h3 {
  margin-bottom: 1rem;
}

.tip-comparison {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  .tip-comparison {
    grid-template-columns: 1fr 1fr;
  }
}

.tip-comparison .bad,
.tip-comparison .good {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.tip-comparison .bad {
  color: var(--muted);
}

.tip-comparison .good {
  color: var(--fg);
}

.tip-comparison .x {
  color: #f87171;
}

.tip-comparison .check {
  color: #4ade80;
}

/* Button */
.button {
  display: inline-block;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--fg);
  transition: all 0.2s ease;
  margin-top: 2rem;
}

.button:hover {
  background: var(--card-hover);
  text-decoration: none;
}

/* Final CTA */
.final-cta {
  font-family: 'JetBrains Mono', monospace;
  color: var(--muted);
  margin-bottom: 1rem;
}

.final-cta .accent {
  color: var(--accent);
}

/* Footer */
footer {
  padding: 3rem 0;
  text-align: center;
  border-top: 1px solid var(--border);
}

footer p {
  font-size: 0.9rem;
}

/* Theme Toggle */
.theme-toggle {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.theme-toggle:hover {
  border-color: var(--muted);
}

.theme-toggle .sun-icon {
  color: #facc15;
  display: block;
}

.theme-toggle .moon-icon {
  color: var(--muted);
  display: none;
}

html.light .theme-toggle .sun-icon {
  display: none;
}

html.light .theme-toggle .moon-icon {
  display: block;
}

.shortcut-hint {
  position: absolute;
  bottom: -1.75rem;
  right: 0;
  font-size: 0.7rem;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.2s ease;
  white-space: nowrap;
}

.theme-toggle:hover .shortcut-hint {
  opacity: 1;
}

/* Utilities */
.text-center {
  text-align: center;
}

.muted {
  color: var(--muted);
}

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

.green {
  color: #4ade80;
}

.small {
  font-size: 0.85rem;
}

/* Fade In Animation */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

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

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
