/* ========================================
   Enjin Engine - Documentation Styles
   ======================================== */

:root {
  /* TEGE palette - boldened for stronger contrast */
  --bg: #e6efe3;
  --bg-alt: #d7e5d2;
  --text: #262735;
  --text-muted: #5b5d73;
  --border: #aebca8;
  --link: #445fc4;
  --link-hover: #354fb0;
  --accent: #8fb1ff;
  --accent-light: #dbe6ff;

  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-serif: 'Lora', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  --content-width: 800px;
  --sidebar-width: 240px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.site-container { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: #2f3040;
  color: #d4d8dc;
  padding: var(--space-lg);
  position: fixed;
  height: 100vh;
  overflow-y: auto;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: var(--space-2xl);
  max-width: calc(var(--content-width) + var(--space-2xl) * 2 + var(--sidebar-width));
}

.content-wrapper { max-width: var(--content-width); }

/* Sidebar nav */
.site-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #98a0af;
  text-decoration: none;
  display: block;
  margin-bottom: var(--space-xs);
}
.site-title:hover { color: #e5e7eb; }

.site-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: #b3d8b0;
  margin-bottom: var(--space-lg);
}

.nav-home {
  display: block;
  color: #98a0af;
  text-decoration: none;
  font-size: var(--text-sm);
  padding: var(--space-xs) 0;
  margin-bottom: var(--space-md);
  border-bottom: 1px solid #4c4d5e;
  padding-bottom: var(--space-md);
}
.nav-home:hover { color: #e5e7eb; }

.nav-section { margin-bottom: var(--space-lg); }
.nav-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7a7b8a;
  font-weight: 600;
  margin-bottom: var(--space-xs);
}

.nav-list { list-style: none; padding: 0; }

.nav-link {
  display: block;
  color: #d4d8dc;
  text-decoration: none;
  font-size: var(--text-sm);
  padding: 0.2rem 0;
  padding-left: var(--space-sm);
  border-left: 2px solid transparent;
}
.nav-link:hover { color: #fff; border-left-color: #8fb1ff; }
.nav-link.active { color: #8fb1ff; border-left-color: #8fb1ff; font-weight: 500; }

/* Hero */
.hero {
  padding: var(--space-2xl) 0;
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
}

.hero-screenshot {
  float: right;
  width: 480px;
  margin: 0.25rem 0 1rem 1.5rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.hero-screenshot img {
  width: 100%;
  height: auto;
  display: block;
}

@media (min-width: 1400px) {
  .hero-screenshot {
    width: 560px;
  }
}

@media (min-width: 1800px) {
  .hero-screenshot {
    width: 640px;
  }
}

.hero h1 {
  font-family: var(--font-mono);
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #6aaa6a, #8fb1ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

.hero-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #6aaa6a;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: var(--space-lg);
}

.hero .lead {
  margin-bottom: var(--space-xl);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: var(--space-xl);
}

.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.75rem;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 600;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  cursor: pointer;
}

.cta-button:hover {
  text-decoration: none;
  transform: translateY(-2px);
}

.cta-button:active {
  transform: translateY(0);
}

.cta-primary {
  background: #0078d4;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 120, 212, 0.3);
}

.cta-primary:hover {
  background: #006cbe;
  color: #fff;
  box-shadow: 0 6px 20px rgba(0, 120, 212, 0.4);
}

.cta-version {
  font-size: 0.7rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.cta-secondary {
  background: #2f3040;
  color: #d4d8dc;
  border: 1px solid #4c4d5e;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.cta-secondary:hover {
  background: #3e3f52;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Content */
h1 {
  font-size: var(--text-3xl);
  font-weight: 700;
  margin-bottom: var(--space-md);
  color: var(--text);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: 600;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid #4a4b5c;
}

h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-sm);
}

p { margin-bottom: var(--space-md); }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

.lead {
  font-size: var(--text-lg);
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-xl);
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-alt);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}

pre {
  background: #2f3040;
  color: #d4d8dc;
  padding: var(--space-md);
  border-radius: 6px;
  overflow-x: auto;
  margin: var(--space-md) 0;
}

pre code { background: none; padding: 0; font-size: var(--text-sm); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-xl) 0;
}

ul, ol { margin: var(--space-md) 0; padding-left: var(--space-xl); }
li { margin-bottom: var(--space-xs); }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: var(--space-md) 0; font-size: var(--text-sm); }
th, td { padding: 0.5rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; background: var(--bg-alt); }

/* Feature cards */
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-md);
  margin: var(--space-lg) 0;
}

.feature-card {
  background: #eef4ec;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--space-lg);
}

.feature-card h3 {
  font-size: var(--text-base);
  margin-top: 0;
  margin-bottom: var(--space-sm);
  color: #4a4b5c;
}

.feature-card p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0;
}

/* Roadmap */
.phase { margin: var(--space-lg) 0; }
.phase-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.phase-header h3 { margin: 0; font-size: var(--text-base); }
.phase-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.phase-status--done { background: #cfe1cb; color: #2a5a2a; }
.phase-status--wip { background: #dbe6ff; color: #3f4f83; }

.phase ul { margin: 0; }
.phase li { font-size: var(--text-sm); }
.phase li.done { color: var(--text-muted); }
.phase li.done::marker { content: '\2713  '; color: #6aaa6a; }
.phase li.todo::marker { content: '\25CB  '; color: #c5ccc2; }

/* Tech stack badges */
.tech-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}
.tech-badge {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: #3e3f52;
  color: #b3d8b0;
}

/* Mobile nav */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1001;
  background: #2f3040;
  border: 1px solid #4c4d5e;
  border-radius: 6px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: #d4d8dc;
  border-radius: 1px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 900px) {
  html, body { overflow-x: hidden; }

  .mobile-nav-toggle { display: flex; }

  .sidebar {
    position: fixed;
    left: -100%;
    width: 280px;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  .sidebar.mobile-open { left: 0; }

  .main-content {
    margin-left: 0;
    padding: var(--space-lg) var(--space-md);
    padding-top: 4rem;
    max-width: 100%;
  }

  .content-wrapper {
    max-width: 100%;
    overflow-x: hidden;
  }

  .hero { padding: var(--space-lg) 0; }
  .hero h1 { font-size: 2.25rem; }

  .hero-screenshot {
    float: none;
    width: 100%;
    margin: 0 0 1rem 0;
  }

  .hero-cta {
    flex-direction: column;
  }

  .cta-button {
    justify-content: center;
    width: 100%;
  }

  .features-grid { grid-template-columns: 1fr; }

  /* Tables scroll horizontally instead of breaking layout */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Phase headers wrap on small screens */
  .phase-header {
    flex-wrap: wrap;
  }

  /* Prevent code blocks from pushing layout */
  pre {
    max-width: calc(100vw - 2 * var(--space-md));
  }

  details.code-block {
    max-width: 100%;
    overflow: hidden;
  }

  /* Scale down heading sizes */
  h1 { font-size: var(--text-2xl); }
  h2 { font-size: var(--text-xl); }

  /* Tech badges wrap nicely */
  .tech-badges {
    gap: var(--space-xs);
  }
  .tech-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
  }
}

/* ========================================
   Section Screenshots (right-side gallery)
   ======================================== */

.section-gallery {
  float: right;
  width: 260px;
  margin: 0 0 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-gallery figure {
  margin: 0;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

.section-gallery img {
  width: 100%;
  height: auto;
  display: block;
  cursor: pointer;
  transition: opacity 0.15s;
}

.section-gallery img:hover {
  opacity: 0.88;
}

.section-gallery figcaption {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.3;
}

.section-gallery figcaption .gallery-credit {
  font-style: italic;
}

/* Enjin lightbox */
.enjin-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.88);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  cursor: pointer;
}

.enjin-lightbox.active {
  display: flex;
}

.enjin-lightbox img {
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 6px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  object-fit: contain;
}

.enjin-lightbox__caption {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #d4d8dc;
  font-size: 0.8rem;
  text-align: center;
  max-width: 80vw;
  background: rgba(57, 58, 75, 0.8);
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

.enjin-lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1.5rem;
  color: #fff;
  font-size: 2rem;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  line-height: 1;
}

.enjin-lightbox__close:hover {
  opacity: 1;
}

/* Clear float after sections */
h2::after {
  content: '';
  display: table;
  clear: both;
}

@media (max-width: 900px) {
  .section-gallery {
    float: none;
    width: 100%;
    margin: 1rem 0;
    flex-direction: column;
    gap: 0.75rem;
  }

  .section-gallery figure {
    min-width: 0;
    width: 100%;
  }

  .enjin-lightbox {
    padding: 1rem;
  }
}

/* Collapsible code blocks */
details.code-block {
  margin: var(--space-md) 0;
  border-radius: 6px;
  overflow: hidden;
}
details.code-block summary {
  background: #4a4b5c;
  color: #d4d8dc;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  border-radius: 6px;
}
details.code-block[open] summary { border-radius: 6px 6px 0 0; }
details.code-block summary:hover { background: #57586c; }
details.code-block summary::before {
  content: '\25B6';
  font-size: 0.7em;
  transition: transform 0.2s ease;
}
details.code-block[open] summary::before { transform: rotate(90deg); }
details.code-block summary::-webkit-details-marker { display: none; }
details.code-block pre { margin: 0; border-radius: 0 0 6px 6px; }

/* Under Construction Badge */
.wip-badge {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.4rem 0.8rem;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--link);
  background: var(--bg);
  border: 1px solid var(--link);
  border-radius: 4px;
  z-index: 1000;
  opacity: 0.85;
  pointer-events: none;
}

/* ========================================
   Technical Analysis Viewer
   ======================================== */

.analysis-viewer {
  margin-top: var(--space-md);
}

.analysis-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #445fc4;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.analysis-toggle:hover {
  background: #354fb0;
}

.analysis-toggle:active {
  transform: scale(0.98);
}

.analysis-container {
  display: none;
  margin-top: var(--space-md);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #0d1117;
}

.analysis-container.active {
  display: block;
}

.analysis-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 0.625rem 1rem;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
}

.analysis-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #e6edf3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.analysis-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.analysis-open-btn,
.analysis-close-btn {
  padding: 0.375rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
}

.analysis-open-btn {
  background: #21262d;
  color: #e6edf3;
  border: 1px solid #30363d;
}

.analysis-open-btn:hover {
  background: #30363d;
}

.analysis-close-btn {
  background: #da3633;
  color: #fff;
  border: 1px solid #da3633;
}

.analysis-close-btn:hover {
  background: #b62324;
}

.analysis-iframe {
  display: block;
  width: 100%;
  height: 70vh;
  min-height: 400px;
  border: none;
}

@media (max-width: 600px) {
  .analysis-toolbar {
    padding: 0.5rem 0.75rem;
  }

  .analysis-title {
    font-size: 0.75rem;
  }

  .analysis-iframe {
    height: 60vh;
    min-height: 300px;
  }
}

/* ========================================
   Accessibility
   ======================================== */

/* Screen reader only - visually hidden but accessible */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  z-index: 9999;
  padding: var(--space-md) var(--space-xl);
  background: var(--accent);
  color: #262735;
  font-weight: 600;
  font-size: var(--text-sm);
  text-decoration: none;
  border-radius: 0 0 8px 0;
}

.skip-link:focus {
  top: 0;
}

/* Focus indicators for keyboard navigation */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Sidebar focus styles */
.sidebar :focus-visible {
  outline-color: #8fb1ff;
}

/* Lightbox focus */
.enjin-lightbox__close:focus-visible {
  outline-color: #fff;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  html {
    scroll-behavior: auto;
  }

  .sidebar {
    transition: none;
  }

  .cta-button:hover {
    transform: none;
  }

  .cta-button:active {
    transform: none;
  }

  .analysis-toggle:active {
    transform: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: more) {
  :root {
    --text-muted: #3a3c52;
    --border: #8a9a84;
  }

  .feature-card {
    border-width: 2px;
  }

  .cta-button {
    border: 2px solid currentColor;
  }

  a {
    text-decoration: underline;
  }

  .nav-link,
  .site-title,
  .nav-home,
  .cta-button {
    text-decoration: none;
  }
}
