/* ============================================================================
   AGG-Rust Demo — Clean Professional Theme
   ============================================================================ */

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --surface-alt: #f0f2f5;
  --border: #e2e5ea;
  --border-light: #eef0f3;
  --text: #1a1d23;
  --text-secondary: #5a6170;
  --text-muted: #8b92a0;
  --accent: #c05020;
  --accent-hover: #a04018;
  --accent-light: #fff5f0;
  --sidebar-width: 220px;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --transition: 150ms ease;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   Sidebar
   ============================================================================ */

#sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  overflow: hidden;
}

.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

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

.tagline {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px;
  flex-shrink: 0;
}

.expand-all-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 10px;
  transition: all var(--transition);
  width: 100%;
}

.expand-all-btn:hover {
  color: var(--text-secondary);
  border-color: var(--text-muted);
  background: var(--surface-alt);
}

.search-box {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--text-muted);
  pointer-events: none;
  line-height: 1;
}

.search-input {
  width: 100%;
  padding: 5px 26px 5px 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(192, 80, 32, 0.12);
}

.search-clear {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
  display: none;
  transition: color var(--transition);
}

.search-clear.visible {
  display: block;
}

.search-clear:hover {
  color: var(--text);
}

.nav-list {
  list-style: none;
  padding: 8px 8px;
  flex: 1;
  overflow-y: auto;
}

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

.nav-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 16px 12px 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: color var(--transition);
}

.nav-section:hover {
  color: var(--text-secondary);
}

.nav-section::after {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-right: 1.5px solid var(--text-muted);
  border-bottom: 1.5px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.nav-section[aria-expanded="true"]::after {
  transform: rotate(-135deg);
}

.nav-group-items {
  list-style: none;
  padding: 0;
  overflow: hidden;
  max-height: 0;
  transition: max-height 200ms ease;
}

.nav-group.open > .nav-group-items {
  max-height: 2200px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon { font-size: 14px; width: 18px; text-align: center; flex-shrink: 0; }

.nav-thumb {
  width: 24px;
  height: 18px;
  object-fit: cover;
  object-position: center;
  /* Force smooth downscaling for tiny sidebar previews. */
  image-rendering: auto;
  image-rendering: smooth;
  border-radius: 3px;
  flex-shrink: 0;
  background: var(--surface-alt);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.8;
  flex-shrink: 0;
}

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

.sidebar-footer a:hover { text-decoration: underline; }

.license { opacity: 0.7; }

/* ============================================================================
   Main Content
   ============================================================================ */

#main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

/* ============================================================================
   Home Page
   ============================================================================ */

.home-page {
  max-width: 900px;
  margin: 0 auto;
  padding: 48px 32px;
}

.hero {
  margin-bottom: 40px;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
}

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

.hero p {
  margin-top: 16px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 600px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.feature-card {
  display: block;
  padding: 12px 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  overflow: hidden;
}

.feature-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 24px;
  display: block;
  margin-bottom: 12px;
}

.card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center;
  /* Keep home-page cards from using nearest-neighbor sampling. */
  image-rendering: auto;
  image-rendering: smooth;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
}

.card-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  font-size: 36px;
  color: var(--text-muted);
}

.feature-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  padding: 0 4px;
}

.feature-card p {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  padding: 0 4px;
}

.about-section {
  margin-top: 48px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}

.about-section h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

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

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

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

.stats-row {
  display: flex;
  gap: 32px;
  margin-top: 24px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-links {
  margin-bottom: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.github-badge-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: var(--text);
  color: white;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: opacity var(--transition);
}

.github-badge-link:hover { opacity: 0.85; }

/* ============================================================================
   Legacy Tribute Pages
   ============================================================================ */

.legacy-page {
  max-width: 980px;
}

.legacy-tribute-intro {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 22px;
}

.legacy-tribute-intro h1 {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.8px;
  margin-bottom: 10px;
}

.legacy-tribute-intro p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 10px;
}

.legacy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.legacy-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  text-decoration: none;
  transition: all var(--transition);
}

.legacy-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.legacy-card h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

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

.legacy-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.legacy-banner h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

.legacy-banner p {
  color: var(--text-secondary);
  line-height: 1.7;
}

.legacy-note {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #f4d0bf;
  background: var(--accent-light);
  color: var(--text-secondary);
}

.legacy-port-update {
  margin-top: 8px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #c8d7f3;
  background: #eef4ff;
  color: var(--text-secondary);
}

.legacy-banner-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.legacy-banner-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.legacy-banner-links a:hover {
  text-decoration: underline;
}

.legacy-local-note {
  color: var(--text-muted);
  font-size: 13px;
}

.legacy-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  overflow-x: auto;
}

.legacy-content h1,
.legacy-content h2,
.legacy-content h3,
.legacy-content h4 {
  margin: 18px 0 10px;
  line-height: 1.3;
}

.legacy-content p,
.legacy-content li,
.legacy-content td {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-secondary);
}

.legacy-content ul,
.legacy-content ol {
  margin-left: 22px;
}

.legacy-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
}

.legacy-content table td,
.legacy-content table th {
  border: 1px solid var(--border-light);
  padding: 8px;
  vertical-align: top;
}

.legacy-content img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.legacy-content pre {
  overflow-x: auto;
  background: var(--surface-alt);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
}

.legacy-content a {
  color: var(--accent);
}

.history-demo-status {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.history-demo-status a {
  color: var(--accent);
  text-decoration: none;
}

.history-demo-status a:hover {
  text-decoration: underline;
}

.history-demo-soon {
  color: var(--text-muted);
}

.history-demo-rust-link {
  margin-top: 8px;
  font-size: 13px;
}

.history-demo-rust-link a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.history-demo-rust-link a:hover {
  text-decoration: underline;
}

.legacy-living-update {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.legacy-living-update h2 {
  margin-bottom: 8px;
  font-size: 20px;
}

.legacy-current-date {
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.legacy-living-update h3 {
  margin: 8px 0 6px;
  font-size: 15px;
}

.legacy-living-update p,
.legacy-living-update li {
  color: var(--text-secondary);
  line-height: 1.7;
}

.legacy-living-update ul {
  margin: 8px 0 8px 20px;
}

.legacy-contact-note h2 {
  margin-bottom: 10px;
}

.legacy-contact-image-wrap {
  margin-bottom: 12px;
}

.legacy-contact-image {
  width: 160px;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.legacy-contact-note a {
  color: var(--accent);
  text-decoration: none;
}

.legacy-contact-note a:hover {
  text-decoration: underline;
}

.legacy-rust-links {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.legacy-rust-links h4 {
  margin-bottom: 10px;
}

.legacy-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legacy-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.legacy-chip:hover {
  background: #ffe8dd;
}

.legacy-loading,
.legacy-fallback p {
  color: var(--text-secondary);
}

/* ============================================================================
   Demo Page
   ============================================================================ */

.demo-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.demo-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border-light);
  background: var(--surface);
}

.demo-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.demo-header p {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.demo-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.demo-canvas-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--surface-alt);
}

.demo-canvas-area canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  touch-action: none;  /* prevent browser from intercepting touch for scroll/zoom */
}

.demo-sidebar {
  width: 260px;
  padding: 16px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
}

.control-group {
  margin-bottom: 16px;
}

.control-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.control-slider {
  width: 100%;
  accent-color: var(--accent);
}

.control-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.control-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.control-checkbox-label input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.control-radio-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 2px 0;
}

.control-radio-label input {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
}

.control-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.5;
  font-style: italic;
}

.render-time {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  position: absolute;
  bottom: 8px;
  right: 12px;
}

/* ============================================================================
   Hamburger Menu Toggle (hidden by default, shown on mobile)
   ============================================================================ */

.menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  padding: 8px 7px;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  box-shadow: var(--shadow);
}

.menu-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 200ms ease;
}

.menu-toggle.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Sidebar overlay (mobile only) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 90;
  opacity: 0;
  transition: opacity 200ms ease;
}

.sidebar-overlay.visible {
  opacity: 1;
}

/* ============================================================================
   Responsive — Tablet (≤ 900px)
   ============================================================================ */

@media (max-width: 900px) {
  .demo-body {
    flex-direction: column;
  }

  .demo-sidebar {
    width: 100%;
    min-width: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 240px;
    overflow-y: auto;
  }

  .demo-canvas-area {
    min-height: 300px;
  }
}

/* ============================================================================
   Responsive — Mobile (≤ 768px)
   ============================================================================ */

@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    pointer-events: none;
  }

  .sidebar-overlay.visible {
    pointer-events: auto;
  }

  #sidebar {
    transform: translateX(-100%);
    transition: transform 250ms ease;
    box-shadow: none;
  }

  #sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }

  #main-content {
    margin-left: 0;
  }

  /* Home page adjustments */
  .home-page {
    padding: 60px 20px 32px;
  }

  .hero h1 {
    font-size: 28px;
  }

  .hero p {
    font-size: 14px;
  }

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

  .stats-row {
    flex-wrap: wrap;
    gap: 16px;
  }

  .stat-value {
    font-size: 22px;
  }

  /* Demo page header gets padding for hamburger */
  .demo-header {
    padding-left: 60px;
  }

  /* Keep demo-page viewport-locked so header never scrolls away */
  .demo-page {
    height: 100vh;
    overflow: hidden;
  }

  .demo-body {
    overflow-y: auto;
  }

  .demo-canvas-area {
    min-height: 250px;
    flex: none;
    height: 50vh;
  }

  .demo-sidebar {
    flex-shrink: 0;
  }

  /* Touch-friendly controls */
  .control-group select {
    padding: 10px 12px;
    font-size: 14px;
  }

  .control-group input[type="range"] {
    height: 8px;
  }

  .control-group input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  .control-checkbox-label {
    font-size: 14px;
    padding: 4px 0;
  }

  .control-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
  }

  .control-radio-label {
    font-size: 13px;
    padding: 4px 0;
  }

  .control-radio-label input {
    width: 18px;
    height: 18px;
  }

  /* Canvas overlays */
  .render-time {
    font-size: 10px;
    bottom: 4px;
    right: 8px;
  }
}
