/* ============================================================
   Radiance Wiki — Shared Design System  v2.1.0
   Used by: index.html, node_reference.html, radiance_viewer.html,
            tutorials.html, faq.html, changelog.html, architecture.html
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ── */
:root {
  /* Palette — Dark */
  --bg-base:        #111214;
  --bg-surface:     #18191d;
  --bg-card:        #1e2025;
  --bg-card-hover:  #242730;
  --bg-code:        #13141a;

  /* Accent */
  --accent:         #d4a853;       /* warm gold */
  --accent-dim:     rgba(212,168,83,.15);
  --accent-border:  rgba(212,168,83,.3);
  --accent-teal:    #2dd4bf;
  --accent-coral:   #f97066;
  --accent-violet:  #a78bfa;
  --accent-green:   #4ade80;
  --accent-red:     #f87171;

  /* Text */
  --text-primary:   #eaeaea;
  --text-secondary: #8b8fa0;
  --text-muted:     #5a5e6e;
  --text-code:      #d4a853;

  /* Borders / Shadows */
  --border:         rgba(255,255,255,.08);
  --border-hover:   rgba(255,255,255,.16);
  --shadow-sm:      0 2px 8px rgba(0,0,0,.4);
  --shadow-md:      0 6px 24px rgba(0,0,0,.5);
  --shadow-glow:    0 0 32px rgba(212,168,83,.12);

  /* Spacing */
  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  18px;
  --sidebar-w:  260px;
  --content-max:900px;
  --nav-h:      56px;
}

/* Light theme */
body.light {
  --bg-base:       #f4f5f7;
  --bg-surface:    #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f9f9fb;
  --bg-code:       #f0f0f4;
  --text-primary:  #111214;
  --text-secondary:#4a4e5a;
  --text-muted:    #8b8fa0;
  --border:        rgba(0,0,0,.1);
  --border-hover:  rgba(0,0,0,.2);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── TOP NAV ── */
.wiki-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-h);
  background: rgba(17,18,20,.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
}
body.light .wiki-nav { background: rgba(255,255,255,.92); }

.wiki-nav .brand {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: -.02em;
  white-space: nowrap;
}
.wiki-nav .brand span { color: var(--accent); }

.nav-links {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
  margin-left: .5rem;
}
.nav-links a {
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  padding: .35rem .7rem;
  border-radius: var(--radius-sm);
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.nav-links a:hover { background: var(--bg-card); color: var(--text-primary); text-decoration: none; }
.nav-links a.active { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent-border); }

.nav-spacer { flex: 1; }

/* Theme toggle */
#themeToggle {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: .35rem .8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .82rem;
  font-family: inherit;
  transition: all .2s;
}
#themeToggle:hover { border-color: var(--border-hover); color: var(--text-primary); }

/* ── WIKI LAYOUT (sidebar + content) ── */
.wiki-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: calc(100vh - var(--nav-h));
  max-width: 1440px;
  margin: 0 auto;
}

/* ── SIDEBAR ── */
.wiki-sidebar {
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  background: var(--bg-surface);
  scrollbar-width: thin;
}

.sidebar-group { margin-bottom: 1.5rem; }
.sidebar-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  padding: 0 .5rem;
  margin-bottom: .5rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .75rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: .88rem;
  font-weight: 500;
  transition: all .18s;
}
.sidebar-link:hover { background: var(--bg-card); color: var(--text-primary); text-decoration: none; }
.sidebar-link.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-link .badge-new {
  margin-left: auto;
  font-size: .62rem;
  font-weight: 700;
  background: var(--accent);
  color: #111;
  padding: .1rem .4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ── CONTENT AREA ── */
.wiki-content {
  padding: 2.5rem 3rem;
  max-width: var(--content-max);
  margin: 0 auto;
  width: 100%;
}

/* ── TYPOGRAPHY ── */
.wiki-content h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.03em; margin-bottom: .5rem; }
.wiki-content h2 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; margin: 2.5rem 0 1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.wiki-content h3 { font-size: 1.15rem; font-weight: 700; margin: 1.75rem 0 .75rem; }
.wiki-content h4 { font-size: .9rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin: 1.25rem 0 .5rem; }
.wiki-content p { color: var(--text-secondary); margin-bottom: 1rem; }
.wiki-content ul, .wiki-content ol { color: var(--text-secondary); padding-left: 1.5rem; margin-bottom: 1rem; }
.wiki-content li { margin-bottom: .35rem; }
.wiki-content code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .82em;
  background: var(--bg-code);
  color: var(--text-code);
  padding: .15rem .45rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.wiki-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
}
.wiki-content pre code { background: none; border: none; padding: 0; font-size: .85rem; color: var(--text-primary); }

/* Page subtitle */
.page-subtitle { color: var(--text-muted); font-size: .95rem; margin-bottom: 2rem; }

/* ── VERSION / NEW BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .25rem .65rem;
  border-radius: 50px;
  border: 1px solid transparent;
}
.badge-gold   { background: var(--accent-dim); border-color: var(--accent-border); color: var(--accent); }
.badge-teal   { background: rgba(45,212,191,.12); border-color: rgba(45,212,191,.3); color: var(--accent-teal); }
.badge-coral  { background: rgba(249,112,102,.12); border-color: rgba(249,112,102,.3); color: var(--accent-coral); }
.badge-violet { background: rgba(167,139,250,.12); border-color: rgba(167,139,250,.3); color: var(--accent-violet); }
.badge-green  { background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.3); color: var(--accent-green); }

/* ── INFO BANNERS ── */
.callout {
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  border-left: 3px solid;
  margin-bottom: 1.25rem;
  font-size: .92rem;
}
.callout p { margin: 0; }
.callout-info    { background: rgba(45,212,191,.07); border-color: var(--accent-teal); }
.callout-tip     { background: rgba(212,168,83,.07); border-color: var(--accent); }
.callout-warn    { background: rgba(249,112,102,.07); border-color: var(--accent-coral); }
.callout-new     { background: rgba(167,139,250,.07); border-color: var(--accent-violet); }
.callout-label   { font-weight: 700; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: .3rem; }

/* ── TABLES ── */
.wiki-table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; font-size: .9rem; }
.wiki-table th { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--border); color: var(--text-muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.wiki-table td { padding: .6rem .85rem; border-bottom: 1px solid rgba(255,255,255,.04); color: var(--text-secondary); vertical-align: top; }
body.light .wiki-table td { border-bottom-color: rgba(0,0,0,.05); }
.wiki-table tr:hover td { background: var(--bg-card); }
.wiki-table td:first-child { color: var(--text-primary); font-weight: 500; white-space: nowrap; }

/* ── NODE CARDS ── */
.node-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .2s;
  position: relative;
  scroll-margin-top: calc(var(--nav-h) + 1rem);
}
.node-card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.node-card.new-in-21 { border-left: 3px solid var(--accent); }

.node-title { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; flex-wrap: wrap; }
.node-icon { font-size: 1.25rem; }
.node-name { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); }
.node-class-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
  padding: .15rem .55rem;
  border-radius: var(--radius-sm);
  margin-bottom: .75rem;
  display: inline-block;
}
.node-desc { color: var(--text-secondary); font-size: .9rem; margin-bottom: 1rem; }

/* IO tables inside node cards */
.node-io { margin-top: .75rem; }
.node-io h4 { margin-top: 0; margin-bottom: .4rem; }
.node-io table { font-size: .82rem; }
.node-io th { padding: .4rem .6rem; }
.node-io td { padding: .4rem .6rem; }

/* Collapse toggle */
.node-card .collapse-icon {
  position: absolute;
  top: 1.35rem;
  right: 1.25rem;
  color: var(--text-muted);
  font-size: .75rem;
  transition: transform .25s;
}
.node-card.collapsed .collapse-icon { transform: rotate(-90deg); }
.node-card.collapsed .node-desc,
.node-card.collapsed .node-io { display: none; }

/* ── SHORTCUT GRID ── */
.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.shortcut-item { display: flex; align-items: center; gap: .65rem; font-size: .88rem; color: var(--text-secondary); }
.key {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  padding: .3rem .65rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .8rem;
  font-weight: 600;
  min-width: 38px;
  text-align: center;
  color: var(--accent);
}

/* ── WHAT'S NEW CARDS ── */
.whats-new-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.wn-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: border-color .2s;
}
.wn-card:hover { border-color: var(--accent-border); }
.wn-card-icon { font-size: 1.5rem; margin-bottom: .5rem; }
.wn-card-title { font-weight: 700; font-size: .95rem; margin-bottom: .4rem; }
.wn-card-body { font-size: .85rem; color: var(--text-secondary); }

/* ── CATEGORY SECTIONS ── */
.category-section { margin-bottom: 3.5rem; }
.category-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1.25rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--border);
}
.category-header h2 { margin: 0; border: none; padding: 0; }
.category-count { font-size: .78rem; color: var(--text-muted); }

/* ── ARCHITECTURE DIAGRAMS ── */
.arch-layer {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
  background: var(--bg-card);
}
.arch-layer h4 { margin: 0 0 .5rem; }
.arch-layer-items { display: flex; flex-wrap: wrap; gap: .5rem; }
.arch-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem;
  padding: .2rem .55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-code);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

/* ── FOOTER ── */
.wiki-footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: 2rem;
}
.wiki-footer strong { color: var(--accent); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .wiki-layout { grid-template-columns: 1fr; }
  .wiki-sidebar { display: none; }
  .wiki-content { padding: 1.5rem; }
  .wiki-nav .nav-links { display: none; }
}
@media (max-width: 600px) {
  .wiki-content h1 { font-size: 1.6rem; }
  .wiki-content h2 { font-size: 1.2rem; }
  .shortcuts-grid { grid-template-columns: 1fr 1fr; }
  .whats-new-grid { grid-template-columns: 1fr; }
}

/* ── ANIMATIONS ── */
@keyframes fadeUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
.animate-in { animation: fadeUp .5s ease-out forwards; }

/* ── PRINT ── */
@media print {
  .wiki-nav, .wiki-sidebar { display: none !important; }
  .wiki-content { max-width: 100%; padding: 0; }
  body { background: #fff; color: #000; }
}
