/* ===================================================
   Ethereans Docs - Design Tokens & Component Styles
   Game Boy palette on dark background
   =================================================== */

:root {
  /* Game Boy palette */
  --gb-darkest: #0f380f;
  --gb-dark: #306230;
  --gb-light: #8bac0f;
  --gb-lightest: #9bbc0f;

  /* Surfaces */
  --bg: #0a0e0a;
  --bg-sidebar: #0d120d;
  --bg-surface: #111811;
  --bg-surface-2: #162016;
  --bg-surface-hover: #1a261a;
  --bg-code: #0d120d;
  --bg-code-inline: #162016;

  /* Borders */
  --border: rgba(139, 172, 15, 0.12);
  --border-active: rgba(139, 172, 15, 0.3);
  --border-strong: rgba(155, 188, 15, 0.2);

  /* Text */
  --text-primary: #d4dcc4;
  --text-muted: #8a9a7a;
  --text-faint: #556645;
  --text-accent: #9bbc0f;
  --text-accent-dim: #8bac0f;
  --text-heading: #c4d4b0;

  /* Functional */
  --success: #40b070;
  --warning: #b08020;
  --error: #c04040;
  --info: #4a8ab0;

  /* Scrollbar */
  --scrollbar-track: #0d120d;
  --scrollbar-thumb: #1a261a;
  --scrollbar-thumb-hover: #306230;

  /* Typography */
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;

  /* Fluid type scale */
  --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
  --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
  --text-base: clamp(0.875rem, 0.825rem + 0.25vw, 1rem);
  --text-lg: clamp(1.1rem, 1rem + 0.5vw, 1.25rem);
  --text-xl: clamp(1.35rem, 1.15rem + 1vw, 1.75rem);
  --text-2xl: clamp(1.75rem, 1.4rem + 1.5vw, 2.25rem);

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-width: 260px;
  --content-max: 820px;
  --header-height: 56px;

  /* Motion */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 180ms;
}

/* ===== Scrollbar ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ===== Layout ===== */
.docs-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.sidebar-header {
  padding: var(--sp-6) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
}

.sidebar-logo svg {
  flex-shrink: 0;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-logo-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-accent);
  letter-spacing: 0.04em;
  line-height: 1;
}

.sidebar-logo-sub {
  font-size: var(--text-xs);
  color: var(--text-faint);
  line-height: 1;
  letter-spacing: 0.02em;
}

.sidebar-nav {
  padding: var(--sp-4) 0;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-5);
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--duration) var(--ease-out);
  border-left: 2px solid transparent;
  line-height: 1.4;
}

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

.sidebar-nav a.active {
  color: var(--text-accent);
  border-left-color: var(--text-accent);
  background: rgba(139, 172, 15, 0.06);
}

.sidebar-nav a .nav-num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  min-width: 18px;
}

.sidebar-nav a.active .nav-num {
  color: var(--text-accent-dim);
}

.sidebar-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-footer a {
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-decoration: none;
  transition: color var(--duration) var(--ease-out);
}

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

.sidebar-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(139, 172, 15, 0.1);
  color: var(--text-accent-dim);
  border: 1px solid rgba(139, 172, 15, 0.15);
  margin-left: auto;
  line-height: 1.3;
}

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--sp-3) var(--sp-5) var(--sp-1) var(--sp-5);
  margin-top: var(--sp-2);
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  padding: 0 var(--sp-4);
  gap: var(--sp-3);
}

.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--duration) var(--ease-out);
  flex-shrink: 0;
}

.hamburger:hover,
.hamburger:active {
  color: var(--text-accent);
  border-color: var(--border-active);
}

.hamburger svg {
  width: 20px;
  height: 20px;
}

.mobile-title {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-accent);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
}

.content-area {
  max-width: var(--content-max);
  padding: var(--sp-12) var(--sp-10);
  margin: 0 auto;
}

/* ===== Sections ===== */
.doc-section {
  display: none;
  animation: fadeIn 250ms var(--ease-out);
}

.doc-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Typography ===== */
h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-accent);
  line-height: 1.2;
  margin-bottom: var(--sp-3);
  letter-spacing: -0.01em;
}

h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.3;
  margin-top: var(--sp-12);
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

h2:first-child,
.doc-section > h1 + h2 {
  margin-top: 0;
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text-heading);
  line-height: 1.35;
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-3);
}

h4 {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-heading);
  margin-top: var(--sp-6);
  margin-bottom: var(--sp-2);
}

.section-subtitle {
  font-size: var(--text-base);
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
  line-height: 1.5;
}

p {
  margin-bottom: var(--sp-4);
  max-width: 72ch;
}

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

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color var(--duration) var(--ease-out);
}

a:hover {
  color: var(--gb-lightest);
  text-decoration: underline;
}

/* ===== Lists ===== */
ul, ol {
  margin-bottom: var(--sp-4);
  padding-left: var(--sp-6);
}

li {
  margin-bottom: var(--sp-2);
  max-width: 72ch;
}

li::marker {
  color: var(--text-faint);
}

/* ===== Code ===== */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-code-inline);
  color: var(--text-accent-dim);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
  overflow-x: auto;
  position: relative;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Syntax highlighting overrides for Prism */
pre[class*="language-"],
code[class*="language-"] {
  background: none !important;
  text-shadow: none !important;
  color: var(--text-primary);
}

pre[class*="language-"] {
  background: var(--bg-code) !important;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: var(--text-faint) !important;
}

.token.keyword,
.token.tag,
.token.selector {
  color: var(--gb-lightest) !important;
}

.token.string,
.token.attr-value {
  color: #80e0a0 !important;
}

.token.number,
.token.boolean {
  color: #e8c060 !important;
}

.token.function {
  color: var(--text-accent) !important;
}

.token.class-name,
.token.builtin {
  color: #c9a0f0 !important;
}

.token.property {
  color: #8ac4e0 !important;
}

.token.operator,
.token.punctuation {
  color: var(--text-muted) !important;
}

.token.attr-name {
  color: var(--text-accent-dim) !important;
}

/* Copy button on code blocks */
.code-block {
  position: relative;
}

.code-block .copy-btn {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  cursor: pointer;
  transition: all var(--duration) var(--ease-out);
  opacity: 0;
  z-index: 2;
}

.code-block:hover .copy-btn {
  opacity: 1;
}

.code-block .copy-btn:hover {
  color: var(--text-accent);
  border-color: var(--border-active);
}

.code-block .copy-btn.copied {
  color: var(--success);
  border-color: var(--success);
}

/* ===== Tables ===== */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--sp-5);
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead {
  background: var(--bg-surface-2);
}

th {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  font-weight: 600;
  color: var(--text-heading);
  white-space: nowrap;
  border-bottom: 1px solid var(--border-strong);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(139, 172, 15, 0.03);
}

/* ===== Address / Copyable ===== */
.addr {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-accent-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all var(--duration) var(--ease-out);
  word-break: break-all;
  position: relative;
}

.addr:hover {
  background: rgba(139, 172, 15, 0.08);
  color: var(--text-accent);
}

.addr.copied::after {
  content: 'Copied!';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--success);
  background: var(--bg-surface-2);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(64, 176, 112, 0.2);
  white-space: nowrap;
  animation: tooltipFade 1.2s var(--ease-out) forwards;
  pointer-events: none;
}

@keyframes tooltipFade {
  0% { opacity: 0; transform: translateX(-50%) translateY(4px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

/* ===== Key Properties List ===== */
.key-props {
  list-style: none;
  padding: 0;
  margin-bottom: var(--sp-6);
}

.key-props li {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
}

.key-props li:last-child {
  border-bottom: none;
}

.key-props .prop-marker {
  color: var(--text-accent-dim);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  flex-shrink: 0;
  padding-top: 3px;
}

/* ===== Status Badges ===== */
.status {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-planned {
  background: rgba(74, 138, 176, 0.12);
  color: var(--info);
  border: 1px solid rgba(74, 138, 176, 0.2);
}

.status-progress {
  background: rgba(176, 128, 32, 0.12);
  color: var(--warning);
  border: 1px solid rgba(176, 128, 32, 0.2);
}

.status-pending {
  background: rgba(139, 172, 15, 0.08);
  color: var(--text-accent-dim);
  border: 1px solid rgba(139, 172, 15, 0.15);
}

/* ===== Palette Swatches ===== */
.palettes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.palette-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-4);
  transition: border-color var(--duration) var(--ease-out);
}

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

.palette-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.palette-card-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-heading);
}

.palette-card-key {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
}

.palette-swatches {
  display: flex;
  gap: var(--sp-2);
}

.swatch {
  flex: 1;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  position: relative;
  cursor: pointer;
  transition: transform var(--duration) var(--ease-out);
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch-hex {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--duration) var(--ease-out);
  pointer-events: none;
}

.swatch:hover .swatch-hex {
  opacity: 1;
}

.palette-colors-row {
  padding-bottom: var(--sp-5);
}

/* ===== Callout / Note ===== */
.callout {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-accent-dim);
  border-radius: 0 8px 8px 0;
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout-title {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-accent-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
  font-weight: 600;
}

/* ===== Checklist ===== */
.checklist {
  list-style: none;
  padding: 0;
}

.checklist li {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: var(--sp-2);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  background: var(--bg-surface);
}

.checklist li .check-num {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  min-width: 20px;
  padding-top: 2px;
}

.checklist li .check-content {
  flex: 1;
}

.checklist li .check-content p {
  margin-bottom: var(--sp-1);
}

.checklist li .check-content p:last-child {
  margin-bottom: 0;
}

/* ===== Architecture Diagram ===== */
.arch-diagram {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-primary);
  white-space: pre;
}

.arch-diagram .diag-label {
  color: var(--text-accent);
  font-weight: 600;
}

.arch-diagram .diag-arrow {
  color: var(--text-faint);
}

.arch-diagram .diag-comment {
  color: var(--text-faint);
}

/* ===== File tree ===== */
.file-tree {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-5);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.7;
  color: var(--text-muted);
  overflow-x: auto;
  white-space: pre;
}

.file-tree .ft-dir {
  color: var(--text-accent-dim);
}

.file-tree .ft-file {
  color: var(--text-primary);
}

.file-tree .ft-comment {
  color: var(--text-faint);
}

/* ===== Security Points ===== */
.security-list {
  list-style: none;
  padding: 0;
}

.security-list li {
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}

.security-list li:last-child {
  border-bottom: none;
}

.security-list strong {
  color: var(--text-accent-dim);
}

/* ===== Prev/Next Page Navigation ===== */
.page-nav {
  display: flex;
  gap: var(--sp-4);
  padding-top: var(--sp-10);
  border-top: 1px solid var(--border);
  margin-top: var(--sp-8);
}

.page-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  transition: all var(--duration) var(--ease-out);
  min-width: 0;
}

.page-nav-link:hover {
  border-color: var(--border-active);
  background: rgba(139, 172, 15, 0.04);
  text-decoration: none;
}

.page-nav-link.hidden {
  visibility: hidden;
  pointer-events: none;
}

.page-nav-next {
  text-align: right;
  margin-left: auto;
}

.page-nav-dir {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.page-nav-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 300ms var(--ease-out);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    padding-top: var(--header-height);
  }

  .content-area {
    padding: var(--sp-6) var(--sp-4);
  }

  h1 { font-size: var(--text-xl); }
  h2 { font-size: var(--text-lg); }

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

  pre {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-xs);
  }

  .table-wrapper {
    font-size: var(--text-xs);
  }

  th, td {
    padding: var(--sp-2) var(--sp-3);
  }

  .arch-diagram {
    font-size: var(--text-xs);
    padding: var(--sp-3) var(--sp-4);
  }

  .file-tree {
    font-size: var(--text-xs);
    padding: var(--sp-3) var(--sp-4);
  }

  .page-nav {
    flex-direction: column;
    gap: var(--sp-3);
  }

  .page-nav-link {
    width: 100%;
  }

  .page-nav-next {
    text-align: left;
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .content-area {
    padding: var(--sp-4) var(--sp-3);
  }

  .palettes-grid {
    gap: var(--sp-3);
  }
}