/* =====================================================
   UE5 Docs — Main Stylesheet
   Mirrors docs.unrealengine.com visual style
   ===================================================== */

:root {
  --sidebar-bg: #1a1a2e;
  --sidebar-width: 280px;
  --navbar-height: 56px;
  --accent: #0f8ce8;
  --accent-hover: #1ea0ff;
  --body-bg: #111827;
  --surface: #1f2937;
  --surface-2: #263040;
  --border: #2d3748;
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --code-bg: #0d1117;
  --code-border: #30363d;
  --note-bg: #1a2744;
  --note-border: #3b5bdb;
  --warning-bg: #2d1f07;
  --warning-border: #d97706;
  --danger-bg: #2d0f0f;
  --danger-border: #dc2626;
  --success-bg: #0d2518;
  --success-border: #16a34a;
  --sidebar-item: #c9d1d9;
  --sidebar-active-bg: #162236;
  --sidebar-hover: rgba(15,140,232,0.1);
  --breadcrumb: #6b7280;
  --font-mono: 'Consolas', 'Fira Code', 'Courier New', monospace;
  --transition: 0.2s ease;
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

html { scroll-behavior: smooth; font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background: var(--body-bg);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--sidebar-bg); }
::-webkit-scrollbar-thumb { background: #374151; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ── Navbar ── */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);
  background: #0d1117;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  gap: 16px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
  text-decoration: none;
  flex-shrink: 0;
}

.navbar-brand:hover { text-decoration: none; color: #fff; }

.ue-logo {
  width: 32px;
  height: 32px;
  background: #000;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
  letter-spacing: -1px;
  border: 1px solid #333;
  flex-shrink: 0;
}

.navbar-version {
  background: var(--accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  letter-spacing: 0.3px;
}

.navbar-spacer { flex: 1; }

.navbar-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navbar-links a {
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: all var(--transition);
  text-decoration: none;
}

.navbar-links a:hover { background: var(--surface); color: var(--text-primary); text-decoration: none; }

.navbar-search {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 10px;
  gap: 8px;
  width: 220px;
}

.navbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  width: 100%;
  padding: 6px 0;
}

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

.search-icon { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }

.burger-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
}

.burger-btn:hover { background: var(--surface); }

.burger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
  margin: 4px 0;
  transition: all var(--transition);
  border-radius: 1px;
}

.burger-btn.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.burger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.burger-btn.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }

/* ── Layout ── */
.layout {
  display: flex;
  margin-top: var(--navbar-height);
  min-height: calc(100vh - var(--navbar-height));
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid #1e2a3a;
  position: fixed;
  top: var(--navbar-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 20px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: #4b5563;
}

.sidebar-section { margin-bottom: 4px; }

.sidebar-section-title {
  padding: 8px 20px 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #4b5563;
  margin-top: 12px;
}

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

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 24px;
  color: var(--sidebar-item);
  font-size: 0.85rem;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  position: relative;
  line-height: 1.3;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: #fff;
  text-decoration: none;
  border-left-color: rgba(15,140,232,0.4);
}

.sidebar-nav li a.active {
  background: var(--sidebar-active-bg);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.sidebar-nav li a .nav-icon {
  font-size: 0.9rem;
  opacity: 0.7;
  width: 16px;
  flex-shrink: 0;
}

.sidebar-nav li a.active .nav-icon { opacity: 1; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.content-wrapper {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 48px 80px;
  width: 100%;
}

/* ── Breadcrumbs ── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--breadcrumb);
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.breadcrumbs a { color: var(--breadcrumb); text-decoration: none; }
.breadcrumbs a:hover { color: var(--accent); text-decoration: none; }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs .current { color: var(--text-secondary); }

/* ── Page Header ── */
.page-header { margin-bottom: 36px; border-bottom: 1px solid var(--border); padding-bottom: 24px; }

.page-title {
  font-size: 2rem;
  font-weight: 700;
  color: #f9fafb;
  line-height: 1.2;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 640px;
  line-height: 1.6;
}

.page-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.page-meta span { display: flex; align-items: center; gap: 4px; }

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  color: #f9fafb;
  font-weight: 600;
  line-height: 1.3;
  margin-top: 2.2em;
  margin-bottom: 0.6em;
  scroll-margin-top: calc(var(--navbar-height) + 20px);
}

h1 { font-size: 1.8rem; }
h2 { font-size: 1.35rem; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; color: var(--text-primary); }
h5, h6 { font-size: 0.875rem; }

.anchor-link {
  opacity: 0;
  margin-left: 8px;
  font-size: 0.8em;
  color: var(--text-muted);
  text-decoration: none;
  transition: opacity var(--transition);
}

h2:hover .anchor-link,
h3:hover .anchor-link,
h4:hover .anchor-link { opacity: 1; }

p { margin-bottom: 1em; color: var(--text-primary); }
p:last-child { margin-bottom: 0; }

ul, ol { padding-left: 1.5em; margin-bottom: 1em; }
li { margin-bottom: 0.3em; }

strong { color: #f3f4f6; font-weight: 600; }
em { color: var(--text-secondary); }

/* ── Callout Blocks ── */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  margin: 1.5em 0;
  border-left: 4px solid;
}

.callout-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.callout-body { flex: 1; min-width: 0; }
.callout-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.callout p { margin: 0; font-size: 0.9rem; }

.callout.note    { background: var(--note-bg);    border-color: var(--note-border); }
.callout.note    .callout-title { color: #93c5fd; }
.callout.note    .callout-icon  { color: #93c5fd; }

.callout.warning { background: var(--warning-bg); border-color: var(--warning-border); }
.callout.warning .callout-title { color: #fbbf24; }
.callout.warning .callout-icon  { color: #fbbf24; }

.callout.danger  { background: var(--danger-bg);  border-color: var(--danger-border); }
.callout.danger  .callout-title { color: #f87171; }
.callout.danger  .callout-icon  { color: #f87171; }

.callout.success { background: var(--success-bg); border-color: var(--success-border); }
.callout.success .callout-title { color: #4ade80; }
.callout.success .callout-icon  { color: #4ade80; }

/* ── Code Blocks ── */
pre, code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 2px 6px;
  border-radius: 4px;
  color: #f8c8d4;
  font-size: 0.85em;
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 1.5em 0;
  position: relative;
  line-height: 1.6;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: 0.875rem;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #161b22;
  border: 1px solid var(--code-border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 16px;
  margin-top: 1.5em;
}

.code-header + pre {
  border-radius: 0 0 var(--radius) var(--radius);
  margin-top: 0;
}

.code-lang {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.72rem;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.copy-btn:hover { background: var(--surface); color: var(--text-primary); border-color: var(--accent); }
.copy-btn.copied { color: #4ade80; border-color: #4ade80; }

/* ── Syntax Highlighting (CSS-only) ── */
.tok-keyword   { color: #ff7b72; }
.tok-string    { color: #a5d6ff; }
.tok-comment   { color: #8b949e; font-style: italic; }
.tok-number    { color: #f2cc60; }
.tok-type      { color: #ffa657; }
.tok-func      { color: #d2a8ff; }
.tok-macro     { color: #7ee787; }
.tok-punct     { color: #c9d1d9; }
.tok-builtin   { color: #79c0ff; }
.tok-operator  { color: #ff7b72; }
.tok-variable  { color: #c9d1d9; }
.tok-bp-event  { color: #e05c5c; font-weight: 600; }
.tok-bp-func   { color: #5cacf9; }
.tok-bp-var    { color: #8fbdff; }
.tok-bp-pin    { color: #aaa; font-size: 0.8em; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; margin: 1.5em 0; border-radius: var(--radius); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr { background: #161b22; }

th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: top;
}

tr:hover td { background: rgba(255,255,255,0.02); }
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-green  { background: #14532d; color: #4ade80; }
.badge-red    { background: #450a0a; color: #f87171; }
.badge-blue   { background: #1e3a5f; color: #60a5fa; }
.badge-orange { background: #431407; color: #fb923c; }
.badge-gray   { background: #1f2937; color: #9ca3af; }

/* ── Figures / Images ── */
figure {
  margin: 2em 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}

figure img {
  width: 100%;
  height: auto;
  display: block;
  background: #0d1117;
  min-height: 120px;
}

figcaption {
  padding: 10px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

/* img placeholder on error */
img.img-error {
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  min-height: 200px;
  position: relative;
}

.img-placeholder {
  background: var(--surface-2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.img-placeholder-icon { font-size: 2rem; opacity: 0.4; }

/* ── Feature Cards (index) ── */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 1.5em 0;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.feature-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform var(--transition);
  transform-origin: left;
}

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

.feature-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
  display: block;
}

.feature-card h3 {
  font-size: 1rem;
  margin: 0 0 8px;
  color: #f3f4f6;
}

.feature-card p {
  font-size: 0.83rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* ── Steps ── */
.steps { list-style: none; padding: 0; counter-reset: step; margin: 1.5em 0; }

.steps > li {
  counter-increment: step;
  padding: 16px 16px 16px 56px;
  position: relative;
  border-left: 2px solid var(--border);
  margin-left: 16px;
  margin-bottom: 4px;
}

.steps > li::before {
  content: counter(step);
  position: absolute;
  left: -16px;
  top: 14px;
  width: 28px;
  height: 28px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  left: -15px;
}

.steps > li:last-child { border-left: none; }

/* ── Req Table (install) ── */
.req-table table { table-layout: fixed; }
.req-table .col-component { width: 160px; }
.req-table .col-minimum { width: 200px; }
.req-table .col-recommended { width: 200px; }

/* ── Nav Buttons (prev/next) ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition);
  max-width: 48%;
  min-width: 140px;
}

.nav-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
  color: #fff;
  text-decoration: none;
}

.nav-btn.prev { flex-direction: row; }
.nav-btn.next { flex-direction: row-reverse; margin-left: auto; }

.nav-btn-arrow { font-size: 1.1rem; color: var(--accent); flex-shrink: 0; }

.nav-btn-content { min-width: 0; }
.nav-btn-label   { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 2px; }
.nav-btn-title   { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── TOC (right sidebar) ── */
.toc {
  position: fixed;
  top: calc(var(--navbar-height) + 40px);
  right: 24px;
  width: 200px;
  font-size: 0.78rem;
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.toc-list { list-style: none; }
.toc-list li { margin-bottom: 4px; }

.toc-list a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  padding: 3px 0 3px 12px;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: all var(--transition);
}

.toc-list a:hover     { color: var(--text-primary); border-color: var(--border); text-decoration: none; }
.toc-list a.active    { color: var(--accent); border-color: var(--accent); }
.toc-list .toc-h3     { padding-left: 20px; font-size: 0.74rem; }

/* ── Overlay ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 850;
  backdrop-filter: blur(2px);
}

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

/* ── Footer ── */
.doc-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 24px 48px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

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

/* ── Inline tags ── */
.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
}

.tag-api      { color: #60a5fa; border-color: #1e3a5f; background: rgba(30,58,95,0.4); }
.tag-blueprint{ color: #a78bfa; border-color: #3b1f6e; background: rgba(59,31,110,0.4); }
.tag-cpp      { color: #34d399; border-color: #0f3d2e; background: rgba(15,61,46,0.4); }
.tag-new      { color: #fb923c; border-color: #431407; background: rgba(67,20,7,0.4); }

/* ── Responsive ── */
@media (max-width: 1280px) {
  .toc { display: none; }
}

@media (max-width: 900px) {
  .content-wrapper { padding: 28px 24px 60px; }
  .doc-footer { padding: 20px 24px; }
}

@media (max-width: 768px) {
  .burger-btn { display: flex; flex-direction: column; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 950;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }

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

  .navbar-search { display: none; }
  .navbar-links  { display: none; }

  .content-wrapper { padding: 20px 16px 50px; }

  .page-title { font-size: 1.5rem; }

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

  .page-nav { flex-direction: column; }
  .nav-btn { max-width: 100%; }
  .nav-btn.next { margin-left: 0; }

  .doc-footer { flex-direction: column; gap: 8px; text-align: center; }
}

@media (max-width: 480px) {
  .feature-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.4rem; }
}

/* ── Utilities ── */
.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.85rem; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.highlight-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 1.5em 0;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 1.5em 0;
}

@media (max-width: 640px) { .two-col { grid-template-columns: 1fr; } }
