/* Godot 3D Game Tutorial Documentation Styling */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Menlo, Monaco, Consolas, 'Courier New', monospace;

  /* Color Palette - Light Mode */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --bg-card: #ffffff;
  --bg-code: #1e293b;
  --bg-inline-code: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-code: #f8fafc;
  --border-color: #e2e8f0;
  --border-subtle: #cbd5e1;

  /* Godot Brand Colors */
  --godot-blue: #478cbf;
  --godot-blue-hover: #3d79a6;
  --godot-dark: #24292f;
  --accent-blue: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;

  /* Callout Colors */
  --callout-note-bg: #eff6ff;
  --callout-note-border: #3b82f6;
  --callout-note-text: #1e40af;
  --callout-tip-bg: #f0fdf4;
  --callout-tip-border: #22c55e;
  --callout-tip-text: #166534;
  --callout-warning-bg: #fffbeb;
  --callout-warning-border: #f59e0b;
  --callout-warning-text: #92400e;

  /* Layout */
  --sidebar-width: 300px;
  --header-height: 64px;
  --content-max-width: 900px;
}

[data-theme="dark"] {
  /* Dark Mode */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: #0b1120;
  --bg-card: #1e293b;
  --bg-code: #020617;
  --bg-inline-code: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-code: #e2e8f0;
  --border-color: #334155;
  --border-subtle: #475569;

  --godot-blue: #5ba3d9;
  --godot-blue-hover: #7bb5e3;
  --accent-blue: #60a5fa;
  --accent-hover: #93c5fd;
  --accent-light: #1e3a8a33;

  --callout-note-bg: #1e293b;
  --callout-note-border: #3b82f6;
  --callout-note-text: #93c5fd;
  --callout-tip-bg: #142e23;
  --callout-tip-border: #22c55e;
  --callout-tip-text: #86efac;
  --callout-warning-bg: #2d2310;
  --callout-warning-border: #f59e0b;
  --callout-warning-text: #fde68a;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* Header */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.sidebar-toggle-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
}

.sidebar-toggle-btn:hover {
  background-color: var(--bg-secondary);
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.1rem;
}

.godot-icon {
  width: 32px;
  height: 32px;
}

.header-badge {
  background: var(--godot-blue);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 9999px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.theme-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
}

.theme-btn:hover {
  border-color: var(--accent-blue);
}

.external-link-btn {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.external-link-btn:hover {
  background-color: var(--bg-secondary);
  color: var(--godot-blue);
}

/* App Container */
.app-container {
  display: flex;
  margin-top: var(--header-height);
  flex: 1;
}

/* Sidebar */
.site-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 1.5rem 1rem 3rem 1rem;
  z-index: 50;
  transition: transform 0.3s ease;
}

.sidebar-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.75rem;
  padding-left: 0.75rem;
}

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

.nav-item {
  margin-bottom: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.4;
  font-weight: 500;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background-color: var(--bg-secondary);
  color: var(--godot-blue);
  transform: translateX(2px);
}

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

.nav-num {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--border-color);
  color: var(--text-secondary);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  margin-right: 0.5rem;
  font-family: var(--font-mono);
}

.nav-link.active .nav-num {
  background: var(--godot-blue);
  color: #fff;
}

/* Main Content */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 2.5rem 2rem 5rem 2rem;
  width: calc(100% - var(--sidebar-width));
}

.main-content {
  width: 100%;
  max-width: var(--content-max-width);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2.2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.75rem;
  margin-top: 0;
  margin-bottom: 1.5rem;
}

h2 {
  font-size: 1.55rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
  margin-top: 2.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-top: 1.75rem;
}

p {
  margin-bottom: 1.2rem;
  color: var(--text-secondary);
  font-size: 1.02rem;
}

strong {
  color: var(--text-primary);
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.75rem;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.4rem;
}

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 2.5rem 0;
}

/* Images */
.main-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  margin: 1.5rem auto;
  display: block;
  background-color: var(--bg-card);
}


/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background-color: var(--bg-card);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.95rem;
}

th {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
}

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

/* Code Blocks & Tabs (Godot Docs Style) */
.code-tab-group, .code-single-group {
  margin: 1.5rem 0;
  background-color: #181a1f;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #282c34;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  position: relative;
}

.code-tab-header {
  display: flex;
  align-items: center;
  background-color: #21252b;
  border-bottom: 1px solid #181a1f;
  padding: 0 0.5rem;
}

.code-tab-btn {
  background: transparent;
  border: none;
  color: #abb2bf;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  border-top: 2px solid transparent;
  transition: all 0.2s ease;
  user-select: none;
}

.code-tab-btn:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.04);
}

.code-tab-btn.active {
  color: #5ba3d9;
  background-color: #181a1f;
  border-top: 2px solid #5ba3d9;
}

.code-lang-label {
  color: #5ba3d9;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 0.8rem;
}

.code-tab-content {
  display: none;
  position: relative;
}

.code-tab-content.active {
  display: block;
}

.code-tab-content pre, .code-single-group pre {
  margin: 0;
  padding: 1.25rem 1.25rem 1.25rem 1.5rem;
  background-color: #181a1f !important;
  border: none !important;
  border-radius: 0;
  overflow-x: auto;
  font-size: 0.95rem;
  line-height: 1.65;
}

.code-tab-content code, .code-single-group code {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace !important;
  font-size: 0.92rem;
  text-shadow: none !important;
  background: transparent !important;
}

/* Copy Code Button */
.copy-code-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #abb2bf;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 10;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: #5ba3d9;
}

.copy-code-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.copy-code-btn.copied {
  background: #22c55e !important;
  color: #ffffff !important;
  border-color: #22c55e !important;
}

/* Syntax Highlighting Colors matching Godot Docs */
.token.comment, .token.prolog, .token.doctype, .token.cdata {
  color: #6e7681 !important;
  font-style: italic;
}

.token.keyword {
  color: #ff7b72 !important;
  font-weight: 600;
}

.token.function {
  color: #57c7ff !important;
}

.token.class-name, .token.type {
  color: #ffc957 !important;
}

.token.string {
  color: #98d379 !important;
}

.token.number, .token.boolean, .token.constant {
  color: #79c0ff !important;
}

.token.operator, .token.punctuation {
  color: #c9d1d9 !important;
}

.token.property, .token.tag, .token.symbol {
  color: #ffa657 !important;
}

.token.variable {
  color: #d2a8ff !important;
}


/* Callouts / Alerts */
.callout {
  padding: 1rem 1.25rem;
  border-left: 4px solid;
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
}

.callout-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.callout-note {
  background-color: var(--callout-note-bg);
  border-color: var(--callout-note-border);
  color: var(--callout-note-text);
}

.callout-tip {
  background-color: var(--callout-tip-bg);
  border-color: var(--callout-tip-border);
  color: var(--callout-tip-text);
}

.callout-warning {
  background-color: var(--callout-warning-bg);
  border-color: var(--callout-warning-border);
  color: var(--callout-warning-text);
}

.callout p {
  color: inherit;
  margin-bottom: 0;
  font-size: 0.95rem;
}

/* Page Navigation Footer */
.page-nav-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.nav-card {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-decoration: none;
  background-color: var(--bg-card);
  transition: all 0.2s ease;
  min-width: 220px;
}

.nav-card:hover {
  border-color: var(--godot-blue);
  box-shadow: 0 4px 12px rgba(71, 140, 191, 0.12);
  text-decoration: none;
  transform: translateY(-2px);
}

.nav-card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  font-weight: 600;
}

.nav-card-title {
  color: var(--godot-blue);
  font-weight: 600;
  font-size: 1rem;
}

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

/* Overlay for Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar-toggle-btn {
    display: block;
  }

  .site-sidebar {
    transform: translateX(-100%);
  }

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

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

  .main-wrapper {
    margin-left: 0;
    width: 100%;
    padding: 1.5rem 1rem 3rem 1rem;
  }

  .page-nav-footer {
    flex-direction: column;
  }

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