/*
Theme Name: RennWiki
Theme URI: https://rennwiki.com
Author: Bear International
Description: Dark, data-terminal encyclopedia theme for rennwiki.com — built from the 917K entry design brief. Three-column wiki layout with sys-bar navigation, breadcrumb trail, left rail (page TOC / model family / related), spec tables, race records, chassis registers, and a right-hand quick-stats/metadata/TOC panel.
Version: 0.1.0
Requires at least: 6.0
Requires PHP: 7.4
Text Domain: rennwiki
*/

:root {
  --ground:    #EEECEA;
  --ground-2:  #E2E0DD;
  --ground-3:  #D5D2CE;
  --ink:       #141210;
  --ink-mid:   #3C3A38;
  --ink-muted: #88857F;
  --ink-ghost: #BBBAB5;
  --accent:    #C8380A;
  --accent-2:  rgba(200,56,10,0.1);
  --panel:     #252320;
  --panel-2:   #1A1917;
  --rule:      rgba(20,18,16,0.1);
  --rule-md:   rgba(20,18,16,0.22);
  --rule-str:  rgba(20,18,16,0.38);

  --ff-disp:  'Barlow Condensed', sans-serif;
  --ff-body:  'Barlow', sans-serif;
  --ff-mono:  'DM Mono', monospace;
  --ff-data:  'Space Mono', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--ff-body);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }
img { max-width: 100%; display: block; }

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--ground-2); }
::-webkit-scrollbar-thumb { background: var(--ink-ghost); }

/* ─── SYSTEM CHROME ─── */
.sys-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  height: 38px;
  background: var(--panel-2);
  display: flex; align-items: center; padding: 0 24px; gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sys-bar-logo {
  font-family: var(--ff-disp); font-weight: 900; font-size: 12px;
  letter-spacing: 0.25em; text-transform: uppercase; color: #fff;
}
.sys-bar-logo em { font-style: normal; color: var(--accent); }
.sys-bar-nav {
  display: flex; align-items: stretch; height: 38px; margin-left: 24px;
}
.sys-bar-nav a {
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.14em;
  text-transform: uppercase; color: #666; text-decoration: none;
  display: flex; align-items: center; padding: 0 14px;
  border-right: 1px solid rgba(255,255,255,0.05);
  transition: color 0.15s, background 0.15s;
}
.sys-bar-nav a:first-child { border-left: 1px solid rgba(255,255,255,0.05); }
.sys-bar-nav a:hover { color: #ccc; background: rgba(255,255,255,0.03); }
.sys-bar-nav a.active { color: var(--accent); }
.sys-bar-right {
  margin-left: auto; display: flex; align-items: center; gap: 20px;
}
.sys-bar-right span {
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.1em;
  color: #555; text-transform: uppercase;
}
.sys-bar-right .ping {
  display: flex; align-items: center; gap: 5px; color: #888;
}
.sys-bar-right .ping::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent); animation: blink 2.4s infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ─── BREADCRUMB ─── */
.breadcrumb-bar {
  position: fixed; top: 38px; left: 0; right: 0; z-index: 190;
  height: 32px; background: var(--ground);
  border-bottom: 1px solid var(--rule-md);
  display: flex; align-items: center; padding: 0 48px; gap: 0;
}
.breadcrumb {
  display: flex; align-items: center; gap: 0;
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.12em;
  text-transform: uppercase;
}
.breadcrumb a { color: var(--ink-muted); text-decoration: none; padding: 0 6px; transition: color 0.12s; }
.breadcrumb a:first-child { padding-left: 0; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: var(--ink-ghost); margin: 0 2px; }
.breadcrumb .current { color: var(--ink); font-weight: 500; }
.breadcrumb-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.breadcrumb-right span {
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.1em;
  color: var(--ink-ghost); text-transform: uppercase;
}

/* ─── PAGE LAYOUT ─── */
.page {
  padding-top: 70px;
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  min-height: 100vh;
}

.rail-left {
  position: sticky; top: 70px; height: calc(100vh - 70px);
  border-right: 1px solid var(--rule-md);
  overflow-y: auto; padding: 32px 0;
  background: var(--ground);
}
.rail-section { padding: 0 20px 24px; border-bottom: 1px solid var(--rule); }
.rail-section:last-child { border-bottom: none; }
.rail-label {
  font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-ghost);
  padding: 16px 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.rail-label::before {
  content: attr(data-n);
  background: var(--panel); color: #555;
  font-size: 7px; padding: 1px 4px;
}
.rail-link {
  display: flex; align-items: center; padding: 5px 0;
  font-family: var(--ff-body); font-size: 11px; color: var(--ink-muted);
  text-decoration: none; gap: 8px; cursor: pointer;
  transition: color 0.12s; border: none; background: none; width: 100%;
  text-align: left;
}
.rail-link:hover { color: var(--ink); }
.rail-link.active { color: var(--ink); font-weight: 500; }
.rail-link.active::before {
  content: ''; width: 2px; height: 12px; background: var(--accent);
  margin-left: -20px; margin-right: -2px; flex-shrink: 0;
}
.rail-link .ref { font-family: var(--ff-mono); font-size: 8px; color: var(--ink-ghost); margin-left: auto; }

.content { padding: 0 56px 120px; min-width: 0; }

/* ─── HERO ─── */
.hero { padding: 48px 0 0; position: relative; overflow: hidden; }
.hero-overline {
  font-family: var(--ff-mono); font-size: 9px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--accent);
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.hero-overline::before { content: ''; width: 24px; height: 2px; background: var(--accent); }
.hero-title {
  font-family: var(--ff-disp); font-weight: 900;
  font-size: clamp(64px, 8vw, 96px); line-height: 0.88;
  letter-spacing: -0.02em; text-transform: uppercase;
  margin-bottom: 4px;
}
.hero-subtitle {
  font-family: var(--ff-disp); font-weight: 400; font-size: 22px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 24px;
}
.hero-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 32px; }
.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.1em;
  text-transform: uppercase; background: var(--panel); color: #999; gap: 5px;
}
.tag .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.tag.accent { background: var(--accent-2); color: var(--accent); }

/* ─── IMAGE BAND ─── */
.image-band {
  position: relative; margin: 0 -56px; height: 360px;
  background: var(--panel-2); overflow: hidden;
  border-top: 1px solid var(--rule-str); border-bottom: 1px solid var(--rule-str);
}
.image-band-inner {
  position: absolute; inset: 0;
  background:
    linear-gradient(to right, var(--panel-2) 0%, transparent 30%, transparent 70%, var(--panel-2) 100%),
    linear-gradient(165deg, #1e1c1a 0%, #2e2a26 40%, #1a1816 100%);
  display: flex; align-items: center; justify-content: center;
}
.image-band-hud-left { position: absolute; left: 56px; bottom: 24px; display: flex; flex-direction: column; gap: 4px; }
.image-band-hud-right {
  position: absolute; right: 0; top: 0; bottom: 0; width: 200px;
  background: var(--panel); border-left: 1px solid rgba(255,255,255,0.06);
  display: flex; flex-direction: column; padding: 20px;
  gap: 16px; justify-content: center;
}
.hud-item { display: flex; flex-direction: column; gap: 3px; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.hud-item:last-child { border-bottom: none; padding-bottom: 0; }
.hud-label { font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.18em; text-transform: uppercase; color: #555; }
.hud-value { font-family: var(--ff-data); font-size: 20px; font-weight: 700; color: #fff; line-height: 1; }
.hud-value.sm { font-size: 14px; }
.hud-unit { font-family: var(--ff-mono); font-size: 8px; color: var(--accent); letter-spacing: 0.1em; }
.hud-scan { font-family: var(--ff-mono); font-size: 8px; color: #444; letter-spacing: 0.1em; text-transform: uppercase; }
.hud-scan span { color: var(--accent); }
.image-band-ref {
  position: absolute; left: 56px; top: 20px;
  font-family: var(--ff-data); font-size: 80px; font-weight: 700;
  color: rgba(255,255,255,0.04); line-height: 1; user-select: none;
  letter-spacing: -0.02em;
}

/* ─── CONTENT GRID ─── */
.content-grid { display: grid; grid-template-columns: 1fr; gap: 0; padding-top: 48px; }
.content-section { padding-bottom: 48px; margin-bottom: 48px; border-bottom: 1px solid var(--rule); }
.content-section:last-child { border-bottom: none; }
.section-head { display: flex; align-items: baseline; gap: 16px; margin-bottom: 24px; }
.section-head-title { font-family: var(--ff-disp); font-weight: 700; font-size: 13px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink); }
.section-head-ref { font-family: var(--ff-mono); font-size: 8px; color: var(--ink-ghost); letter-spacing: 0.1em; }
.section-head::after { content: ''; flex: 1; height: 1px; background: var(--rule-md); }
.prose { font-family: var(--ff-body); font-size: 13.5px; color: var(--ink-mid); line-height: 1.75; max-width: 640px; }
.prose p + p { margin-top: 16px; }
.prose strong { font-weight: 600; color: var(--ink); }
.prose h2, .prose h3, .prose h4 { font-family: var(--ff-disp); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink); margin: 24px 0 12px; }
.prose ul, .prose ol { margin: 12px 0 12px 20px; }
.prose a { color: var(--accent); text-decoration: underline; }

/* ─── SPEC TABLE ─── */
.spec-table { width: 100%; border-collapse: collapse; }
.spec-table tbody tr { border-bottom: 1px solid var(--rule); transition: background 0.1s; }
.spec-table tbody tr:hover { background: var(--ground-2); }
.spec-table tbody tr:last-child { border-bottom: none; }
.spec-table td { padding: 10px 0; vertical-align: top; }
.spec-table td:first-child {
  font-family: var(--ff-mono); font-size: 9px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-muted); width: 44%; padding-right: 24px;
}
.spec-table td:last-child { font-family: var(--ff-data); font-size: 12px; font-weight: 700; color: var(--ink); letter-spacing: 0.03em; }
.spec-table td:last-child.accent { color: var(--accent); }
.spec-group-header td {
  padding-top: 20px !important; padding-bottom: 4px !important;
  font-family: var(--ff-mono) !important; font-size: 7px !important;
  letter-spacing: 0.2em !important; color: var(--accent) !important;
  text-transform: uppercase !important; font-weight: 400 !important;
  border-bottom: none !important;
}

/* ─── RACE RECORD ─── */
.race-record { display: flex; flex-direction: column; gap: 1px; }
.race-row { display: grid; grid-template-columns: 56px 1fr 80px 80px 100px; gap: 0; background: var(--rule); }
.race-row.header { background: var(--panel); }
.race-cell {
  background: var(--ground); padding: 9px 12px;
  font-family: var(--ff-mono); font-size: 9px; letter-spacing: 0.06em;
  color: var(--ink-mid); display: flex; align-items: center;
}
.race-row.header .race-cell { background: var(--panel); color: #666; font-size: 7px; letter-spacing: 0.18em; text-transform: uppercase; }
.race-cell.pos { font-family: var(--ff-data); font-size: 16px; font-weight: 700; color: var(--ink-ghost); }
.race-cell.pos.win { color: var(--accent); }
.race-cell.pos.podium { color: var(--ink); }
.race-cell.event { font-family: var(--ff-body); font-size: 12px; color: var(--ink); }
.race-cell.driver { font-size: 8px; color: var(--ink-muted); }
.race-row:hover .race-cell { background: var(--ground-2); }
.race-row.header:hover .race-cell { background: var(--panel); }

/* ─── CHASSIS GRID ─── */
.chassis-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--rule-md); border: 1px solid var(--rule-md); }
.chassis-card { background: var(--ground); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; transition: background 0.12s; }
.chassis-card:hover { background: var(--ground-2); }
.chassis-number { font-family: var(--ff-data); font-size: 22px; font-weight: 700; color: var(--ink-ghost); line-height: 1; }
.chassis-number.active { color: var(--ink); }
.chassis-id { font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.12em; color: var(--accent); text-transform: uppercase; }
.chassis-note { font-family: var(--ff-body); font-size: 11px; color: var(--ink-muted); margin-top: 4px; line-height: 1.4; }
.chassis-status {
  margin-top: 8px; display: flex; align-items: center; gap: 4px;
  font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-ghost);
}
.chassis-status.extant { color: #7aaa7a; }
.chassis-status::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

/* ─── TIMELINE ─── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 1px; background: var(--rule-md); }
.tl-item { position: relative; margin-bottom: 28px; padding-bottom: 28px; border-bottom: 1px solid var(--rule); }
.tl-item:last-child { border-bottom: none; margin-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -28px; top: 6px;
  width: 8px; height: 8px; border: 1px solid var(--rule-str); background: var(--ground);
}
.tl-item.key::before { background: var(--accent); border-color: var(--accent); }
.tl-date { font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.tl-event { font-family: var(--ff-disp); font-weight: 700; font-size: 15px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); margin-bottom: 6px; }
.tl-desc { font-family: var(--ff-body); font-size: 12px; color: var(--ink-muted); line-height: 1.6; max-width: 520px; }

/* ─── RELATED ENTRIES ─── */
.related-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--rule-md); border: 1px solid var(--rule-md); }
.related-card { background: var(--ground); padding: 20px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; transition: background 0.12s; text-decoration: none; }
.related-card:hover { background: var(--ground-2); }
.related-card-type { font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-ghost); }
.related-card-title { font-family: var(--ff-disp); font-weight: 800; font-size: 20px; text-transform: uppercase; color: var(--ink); line-height: 1; }
.related-card-sub { font-family: var(--ff-disp); font-size: 12px; font-weight: 500; text-transform: uppercase; color: var(--ink-muted); letter-spacing: 0.05em; }
.related-card-ref { font-family: var(--ff-data); font-size: 32px; font-weight: 700; color: var(--ground-3); line-height: 1; margin-top: auto; align-self: flex-end; }

/* ─── RIGHT PANEL ─── */
.panel-right { position: sticky; top: 70px; height: calc(100vh - 70px); border-left: 1px solid var(--rule-md); overflow-y: auto; background: var(--ground); padding: 0; }
.panel-block { padding: 20px; border-bottom: 1px solid var(--rule-md); }
.panel-block-label {
  font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-ghost); margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.panel-block-label::after { content: ''; flex: 1; height: 1px; background: var(--rule); }

.quick-stats { display: flex; flex-direction: column; gap: 0; }
.qs-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.qs-row:last-child { border-bottom: none; }
.qs-label { font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-muted); }
.qs-value { font-family: var(--ff-data); font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1; }
.qs-value.accent { color: var(--accent); }
.qs-sub { font-family: var(--ff-mono); font-size: 8px; color: var(--ink-ghost); letter-spacing: 0.06em; }

.meta-list { display: flex; flex-direction: column; gap: 8px; }
.meta-item { display: flex; align-items: flex-start; gap: 8px; }
.meta-key { font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); width: 72px; flex-shrink: 0; padding-top: 1px; }
.meta-val { font-family: var(--ff-body); font-size: 11px; color: var(--ink); line-height: 1.4; }

.toc-list { display: flex; flex-direction: column; gap: 0; }
.toc-item {
  padding: 6px 0; font-family: var(--ff-body); font-size: 11px;
  color: var(--ink-muted); cursor: pointer; text-decoration: none;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--rule); transition: color 0.12s;
}
.toc-item:last-child { border-bottom: none; }
.toc-item:hover { color: var(--ink); }
.toc-item.active { color: var(--accent); }
.toc-item .toc-n { font-family: var(--ff-mono); font-size: 7px; color: var(--ink-ghost); width: 16px; flex-shrink: 0; }

.version-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel); padding: 6px 10px;
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.1em;
  text-transform: uppercase; color: #666; margin-bottom: 8px;
}
.version-chip .v { color: var(--accent); }

/* ─── ENTRY FOOTER ─── */
.entry-footer {
  margin-top: 64px; padding-top: 24px; border-top: 2px solid var(--ink);
  display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 24px;
}
.entry-footer-meta { display: flex; flex-direction: column; gap: 4px; }
.entry-footer-ref { font-family: var(--ff-data); font-size: 48px; font-weight: 700; color: var(--ground-3); line-height: 1; }
.entry-footer-label { font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.12em; color: var(--ink-muted); text-transform: uppercase; }

/* ─── ANIMATIONS ─── */
.reveal { opacity: 0; transform: translateY(10px); animation: revealUp 0.5s ease forwards; }
@keyframes revealUp { to { opacity: 1; transform: translateY(0); } }
.reveal:nth-child(1){animation-delay:.04s}
.reveal:nth-child(2){animation-delay:.08s}
.reveal:nth-child(3){animation-delay:.12s}
.reveal:nth-child(4){animation-delay:.16s}
.reveal:nth-child(5){animation-delay:.20s}
.reveal:nth-child(6){animation-delay:.24s}
.reveal:nth-child(7){animation-delay:.28s}

/* ─── TAB SYSTEM ─── */
.tab-bar { display: flex; border-bottom: 1px solid var(--rule-md); margin-bottom: 24px; gap: 0; }
.tab-btn {
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-muted);
  background: none; border: none; cursor: pointer;
  padding: 10px 16px; border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 0.12s, border-color 0.12s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── FIGURE NOTE ─── */
.figure-note {
  background: var(--ground-2); border-left: 2px solid var(--accent);
  padding: 12px 16px; margin: 20px 0;
  font-family: var(--ff-body); font-size: 12px; color: var(--ink-mid); line-height: 1.6;
}
.figure-note strong {
  font-family: var(--ff-mono); font-size: 8px; letter-spacing: 0.14em;
  text-transform: uppercase; display: block; margin-bottom: 4px; color: var(--accent);
}

/* ─── STATUS BAR ─── */
.status-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: 22px; background: var(--panel-2);
  display: flex; align-items: center; padding: 0 24px; gap: 20px;
}
.sb-item { font-family: var(--ff-mono); font-size: 7px; letter-spacing: 0.12em; text-transform: uppercase; color: #444; display: flex; align-items: center; gap: 5px; }
.sb-item.lit { color: #777; }
.sb-item.accent { color: var(--accent); }
.sb-sep { color: #2a2a2a; }

/* ─── RESPONSIVE ─── */
@media (max-width: 1100px) {
  .page { grid-template-columns: 200px 1fr; }
  .panel-right { display: none; }
}
@media (max-width: 780px) {
  .page { grid-template-columns: 1fr; }
  .rail-left { position: static; height: auto; border-right: none; border-bottom: 1px solid var(--rule-md); }
  .content { padding: 0 20px 80px; }
  .image-band { margin: 0 -20px; height: 260px; }
  .image-band-hud-right { width: 140px; padding: 12px; }
  .chassis-grid, .related-grid { grid-template-columns: 1fr; }
  .race-row { grid-template-columns: 40px 1fr 60px; }
  .race-row .race-cell:nth-child(4), .race-row .race-cell:nth-child(5) { display: none; }
  .breadcrumb-bar { padding: 0 20px; }
  .breadcrumb-right { display: none; }
}
