/**
 * HyperFixi Examples Gallery - Minimalist Design System
 */

/* =============================================================================
   CSS Reset
   ============================================================================= */

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

/* =============================================================================
   Design Tokens
   ============================================================================= */

:root {
  /* Colors - Minimal palette */
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-text: #18181b;
  --color-text-secondary: #71717a;
  --color-text-muted: #a1a1aa;
  --color-border: #e4e4e7;
  --color-border-hover: #a1a1aa;
  --color-accent: #6366f1;
  --color-accent-muted: #e0e7ff;

  /* Accent panels — colored callout boxes used in examples */
  --panel-green-bg: #e8f5e9;
  --panel-green-fg: #1b5e20;
  --panel-green-border: #4caf50;
  --panel-orange-bg: #fff3e0;
  --panel-orange-fg: #e65100;
  --panel-orange-border: #ff9800;
  --panel-blue-bg: #e3f2fd;
  --panel-blue-fg: #0d47a1;
  --panel-blue-border: #2196f3;
  --panel-red-bg: #ffebee;
  --panel-red-fg: #c62828;
  --panel-red-border: #f44336;
  --panel-yellow-bg: #fff3cd;
  --panel-yellow-fg: #7b5e00;
  --panel-yellow-border: #ffc107;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Source Code Pro', Menlo, monospace;

  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 200ms ease;
}

/* =============================================================================
   Dark Theme
   ============================================================================= */

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #09090b;
    --color-surface: #18181b;
    --color-text: #fafafa;
    --color-text-secondary: #a1a1aa;
    --color-text-muted: #71717a;
    --color-border: #27272a;
    --color-border-hover: #52525b;
    --color-accent: #818cf8;
    --color-accent-muted: #312e81;

    --panel-green-bg: #1a2e1a;
    --panel-green-fg: #a5d6a7;
    --panel-green-border: #388e3c;
    --panel-orange-bg: #2e1c0a;
    --panel-orange-fg: #ffcc80;
    --panel-orange-border: #f57c00;
    --panel-blue-bg: #0d1b2a;
    --panel-blue-fg: #90caf9;
    --panel-blue-border: #1976d2;
    --panel-red-bg: #2a0d0d;
    --panel-red-fg: #ef9a9a;
    --panel-red-border: #e53935;
    --panel-yellow-bg: #2a2200;
    --panel-yellow-fg: #ffe082;
    --panel-yellow-border: #ffa000;
  }
}

html.dark-mode {
  --color-bg: #09090b;
  --color-surface: #18181b;
  --color-text: #fafafa;
  --color-text-secondary: #a1a1aa;
  --color-text-muted: #71717a;
  --color-border: #27272a;
  --color-border-hover: #52525b;
  --color-accent: #818cf8;
  --color-accent-muted: #312e81;

  --panel-green-bg: #1a2e1a;
  --panel-green-fg: #a5d6a7;
  --panel-green-border: #388e3c;
  --panel-orange-bg: #2e1c0a;
  --panel-orange-fg: #ffcc80;
  --panel-orange-border: #f57c00;
  --panel-blue-bg: #0d1b2a;
  --panel-blue-fg: #90caf9;
  --panel-blue-border: #1976d2;
  --panel-red-bg: #2a0d0d;
  --panel-red-fg: #ef9a9a;
  --panel-red-border: #e53935;
  --panel-yellow-bg: #2a2200;
  --panel-yellow-fg: #ffe082;
  --panel-yellow-border: #ffa000;
}

/* =============================================================================
   Base Styles
   ============================================================================= */

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

/* Site navigation bar — links back to docs site */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: var(--space-3) var(--space-6);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
}

.site-nav a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--color-text);
}

.site-nav-home {
  margin-right: auto;
}

/* Gallery index page */
body.gallery-index {
  padding: 0 0 var(--space-12);
}

body.gallery-index > .container {
  padding: var(--space-8) var(--space-6) 0;
}

/* Example pages */
body.example-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-12) var(--space-6);
}

/* =============================================================================
   Layout
   ============================================================================= */

.container {
  max-width: 1120px;
  margin: 0 auto;
}

.container-narrow {
  max-width: 720px;
  margin: 0 auto;
}

/* =============================================================================
   Header
   ============================================================================= */

header {
  text-align: center;
  margin-bottom: var(--space-16);
}

header h1 {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.025em;
  margin-bottom: var(--space-3);
  color: var(--color-text);
}

.tagline {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.header-meta {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.header-meta span {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

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

.section {
  margin-bottom: var(--space-16);
}

.section h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-2);
  letter-spacing: -0.01em;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.section-count {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.section-description {
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
  max-width: 640px;
}

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

.section-description a:hover {
  text-decoration: underline;
}

/* =============================================================================
   Example Grid & Cards
   ============================================================================= */

.example-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.example-card {
  display: block;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
}

.example-card:hover {
  border-color: var(--color-border-hover);
  transform: translateY(-2px);
}

.example-card:active {
  transform: translateY(0);
}

.example-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.example-description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-3);
}

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

.example-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  background: transparent;
  padding: 0;
}

.tag::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 4px;
  background: var(--color-border-hover);
  border-radius: 50%;
  margin-right: var(--space-2);
  vertical-align: middle;
}

/* Featured tag variant */
.tag.feature {
  color: var(--color-accent);
}

.tag.feature::before {
  background: var(--color-accent);
}

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

footer {
  text-align: center;
  padding-top: var(--space-12);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
}

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

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

footer .footer-links {
  margin-top: var(--space-4);
  display: flex;
  justify-content: center;
  gap: var(--space-6);
}

/* =============================================================================
   Example Page Styles
   ============================================================================= */

.page-container {
  background: var(--color-surface);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.breadcrumb {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-6);
}

.breadcrumb a {
  color: var(--color-text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--color-accent);
}

.page-container h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.description {
  background: var(--color-bg);
  border-left: 2px solid var(--color-accent);
  padding: var(--space-4);
  margin: var(--space-6) 0;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.demo {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-8);
  margin: var(--space-6) 0;
  text-align: center;
}

#output,
.output {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--color-accent-muted);
  border-radius: var(--radius-md);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--color-accent);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent);
  color: white;
  border: none;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-sm);
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity var(--transition-fast);
  font-family: inherit;
}

button:hover,
.btn:hover {
  opacity: 0.9;
}

button:active,
.btn:active {
  opacity: 0.8;
}

button.secondary,
.btn.secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

button.secondary:hover,
.btn.secondary:hover {
  background: var(--color-border);
  opacity: 1;
}

/* =============================================================================
   Code Blocks
   ============================================================================= */

.code {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin: var(--space-4) 0;
  line-height: 1.6;
}

/* Syntax highlighting */
.keyword { color: #c586c0; }
.string { color: #ce9178; }
.comment { color: #6a9955; }
.number { color: #b5cea8; }
.function { color: #dcdcaa; }

/* Prism.js tokens */
.token.hs-command { color: #9cdcfe; font-weight: 500; }
.token.hs-modifier { color: #808080; }
.token.hs-event { color: #dcdcaa; }
.token.hs-logical { color: #c586c0; }
.token.hs-temporal { color: #4ec9b0; }
.token.hs-value { color: #b5cea8; }
.token.hs-attribute { color: #9cdcfe; }
.token.hs-expression { color: #c586c0; }
.token.hs-selector { color: #ce9178; }

.token.comment { color: #6a9955; font-style: italic; }
.token.string, .token.attr-value { color: #ce9178; }
.token.keyword { color: #c586c0; }
.token.number { color: #b5cea8; }
.token.tag { color: #569cd6; }
.token.attr-name { color: #9cdcfe; }
.token.punctuation { color: #d4d4d4; }
.token.operator { color: #d4d4d4; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-bg);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}

/* =============================================================================
   Explanations
   ============================================================================= */

.explanation {
  margin: var(--space-6) 0;
  line-height: 1.7;
}

.explanation h3 {
  font-size: var(--text-base);
  font-weight: 600;
  margin: var(--space-6) 0 var(--space-3);
}

.explanation ul {
  margin-left: var(--space-5);
  color: var(--color-text-secondary);
}

.explanation li {
  margin-bottom: var(--space-2);
}

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

.nav-buttons {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-8);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.nav-buttons a {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.nav-buttons a:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

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

@media (max-width: 640px) {
  body.gallery-index {
    padding: var(--space-6) var(--space-4);
  }

  header h1 {
    font-size: var(--text-2xl);
  }

  .tagline {
    font-size: var(--text-base);
  }

  .header-meta {
    flex-direction: column;
    gap: var(--space-2);
  }

  .section {
    margin-bottom: var(--space-12);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }

  .example-grid {
    grid-template-columns: 1fr;
  }

  .page-container {
    padding: var(--space-5);
  }
}

/* =============================================================================
   Utilities
   ============================================================================= */

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }

.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

/* Legacy class mappings for compatibility */
.muted { color: var(--color-text-muted); }
.mt-sm { margin-top: var(--space-2); }
.mt-md { margin-top: var(--space-4); }
.mt-lg { margin-top: var(--space-6); }
.mb-sm { margin-bottom: var(--space-2); }
.mb-md { margin-bottom: var(--space-4); }
.mb-lg { margin-bottom: var(--space-6); }

/* Legacy header/body structure - hidden */
.example-header {
  display: none;
}

.example-body {
  /* Reset any padding if parent had structure */
}
