/* ============================================================================
   Savvy — the FiveNova project encyclopedia.
   ----------------------------------------------------------------------------
   Structure follows Wikipedia closely on purpose: fixed left rail, article
   column, right-floated infobox, boxed contents, ruled section headings, edit
   affordances, "last edited" footer. The skin is entirely ours — near-black,
   violet accent, and the studio display face where Wikipedia uses a serif.
   ========================================================================== */

:root {
  --rail: 268px;
  --wiki-max: 1500px;
  }

body.wiki {
  background: var(--bg);
  font-size: 15px;
}

/* ============================================================== CHROME === */

.wiki-top {
  position: sticky; top: 0; z-index: 60;
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 0 22px;
  height: 92px;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 3px solid var(--edge);
}
@media (max-width: 980px) { .wiki-top { grid-template-columns: auto minmax(0,1fr) auto; } }

.wiki-brand { display: inline-flex; align-items: center; }
.wiki-brand img {
  height: clamp(46px, 5.6vw, 68px);
  width: auto;
  filter: drop-shadow(0 0 20px color-mix(in oklab, var(--acc) 45%, transparent));
  transition: transform var(--t-med) var(--e-out), filter var(--t-med) var(--e-out);
}
.wiki-brand:hover img { transform: rotate(-2deg) scale(1.05); }
@media (max-width: 620px) { .wiki-brand img { height: 40px; } }

/* --- search ------------------------------------------------------------- */

.wiki-search { position: relative; max-width: 520px; width: 100%; }
.wiki-search input {
  width: 100%;
  padding: 9px 14px 9px 34px;
  background: var(--bg-1);
  border: 1px solid var(--line-hi);
  color: var(--ink);
  font-family: var(--f-body); font-size: 14px;
  transition: border-color var(--t-fast) var(--e-io), background var(--t-fast) var(--e-io);
}
.wiki-search input::placeholder { color: var(--ink-faint); }
.wiki-search input:focus { outline: none; border-color: var(--acc); background: var(--bg-2); }
.wiki-search .ico {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-family: var(--f-mono); font-size: 12px;
  pointer-events: none;
}
.wiki-search:focus-within .ico { color: var(--acc); }

.wiki-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 70;
  background: var(--bg-1);
  border: 1px solid var(--line-hi);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  max-height: 62vh; overflow-y: auto;
}
.wiki-results:empty { display: none; }
.wiki-results a {
  display: block; padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  transition: background var(--t-fast) var(--e-io);
}
.wiki-results a:last-child { border-bottom: 0; }
.wiki-results a:hover, .wiki-results a.on { background: color-mix(in oklab, var(--acc) 16%, transparent); }
.wiki-results .t { font-weight: 500; font-size: 14px; }
.wiki-results .d { font-size: 12px; color: var(--ink-mute); margin-top: 2px; }
.wiki-results mark { background: color-mix(in oklab, var(--acc) 40%, transparent); color: var(--ink); }
.wiki-results .none { padding: 14px; font-family: var(--f-mono); font-size: 12px; color: var(--ink-mute); }

/* ============================================================== LAYOUT === */

.wiki-shell {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  gap: 0;
  max-width: var(--wiki-max);
  margin-inline: auto;
}
@media (max-width: 980px) { .wiki-shell { grid-template-columns: 1fr; } }

/* --- left rail ---------------------------------------------------------- */

.rail {
  position: sticky; top: 92px; align-self: start;
  height: calc(100svh - 92px);
  overflow-y: auto;
  padding: 26px 20px 40px;
  border-right: 1px solid var(--line);
}
@media (max-width: 980px) {
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}

.rail h4 {
  font-family: var(--f-display);
  font-size: 12px; font-weight: 400; letter-spacing: .2em; text-transform: uppercase;
  color: var(--ink-faint);
  padding: 0 8px 8px;
  margin-top: 26px;
}
.rail h4:first-child { margin-top: 0; }

.rail ul { list-style: none; }
.rail li a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  font-size: 13.5px;
  color: var(--ink-dim);
  border-left: 2px solid transparent;
  transition: color var(--t-fast) var(--e-io), border-color var(--t-fast) var(--e-io), background var(--t-fast) var(--e-io);
}
.rail li a:hover { color: var(--ink); background: color-mix(in oklab, var(--acc) 9%, transparent); border-left-color: var(--acc-lo); }
.rail li a[aria-current="page"] { color: var(--acc-hi); border-left-color: var(--acc); background: color-mix(in oklab, var(--acc) 12%, transparent); }
.rail li a .st { margin-left: auto; width: 5px; height: 5px; border-radius: 50%; background: var(--ink-faint); flex: none; }
.rail li a .st[data-status="active"]     { background: var(--log-ok); }
.rail li a .st[data-status="paused"]     { background: var(--log-warn); }
.rail li a .st[data-status="unreleased"] { background: var(--ink-mute); }

/* --- article column ----------------------------------------------------- */

.wiki-main { min-width: 0; padding: 30px clamp(18px, 3.4vw, 52px) 100px; }

.crumbs {
  font-family: var(--f-body); font-size: 12.5px; letter-spacing: .04em;
  color: var(--ink-faint); margin-bottom: 16px;
}
.crumbs a { color: var(--ink-mute); }
.crumbs a:hover { color: var(--acc-hi); }
.crumbs span { color: var(--ink-faint); margin: 0 6px; }

.art-title {
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.06;
  letter-spacing: .01em; text-transform: uppercase;
  color: var(--ink);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-hi);
  position: relative;
}
/* Accent segment on the title rule — the one flourish the wiki gets. */
.art-title::after {
  content: "";
  position: absolute; left: 0; bottom: -1px;
  width: 84px; height: 1px; background: var(--acc);
  box-shadow: 0 0 10px var(--acc);
}

.art-sub {
  font-size: 13.5px;
  color: var(--ink-mute);
  font-style: italic;
  margin-top: 10px;
}

/* --- infobox ------------------------------------------------------------ */

.infobox {
  float: right;
  width: 316px;
  margin: 6px 0 22px 30px;
  background: var(--bg-1);
  border: 1px solid var(--line-hi);
  font-size: 13px;

  /* Floats paint before positioned elements, and both .art-title and the body
     h2/h3 are position:relative — without a stacking position of its own the
     infobox gets drawn through by their underlines. */
  position: relative;
  z-index: 1;
}
@media (max-width: 760px) { .infobox { float: none; width: 100%; margin: 20px 0; } }

.infobox .ib-head {
  padding: 11px 14px;
  background: color-mix(in oklab, var(--acc) 20%, var(--bg-2));
  border-bottom: 1px solid var(--line-hi);
  font-family: var(--f-display);
  font-weight: 600; font-size: 15px; letter-spacing: -.01em;
  color: var(--ink);
  text-align: center;
}
.infobox .ib-img { border-bottom: 1px solid var(--line-hi); background: var(--bg-2); }
.infobox .ib-img img { width: 100%; height: 168px; object-fit: cover; }
.infobox .ib-img.blank {
  height: 168px;
  background:
    repeating-linear-gradient(-52deg, color-mix(in oklab, var(--acc) 15%, transparent) 0 1px, transparent 1px 11px),
    var(--bg-2);
  display: grid; place-items: center;
}
.infobox .ib-img.blank span {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--ink-faint);
}
.infobox .ib-cap {
  padding: 7px 12px;
  font-size: 11.5px; color: var(--ink-mute); text-align: center;
  border-bottom: 1px solid var(--line);
}

.infobox dl { display: grid; grid-template-columns: 106px minmax(0,1fr); margin: 0; }
.infobox dt, .infobox dd { padding: 9px 12px; border-bottom: 1px solid var(--line); margin: 0; }
.infobox dt {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--ink-mute);
  background: color-mix(in oklab, var(--bg-2) 60%, transparent);
}
.infobox dd { color: var(--ink-dim); }
.infobox dl > :nth-last-child(-n+2) { border-bottom: 0; }

.ib-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.ib-links { padding: 12px; display: flex; flex-direction: column; gap: 7px; border-top: 1px solid var(--line-hi); }
.ib-links .btn { justify-content: center; padding: 10px 12px; font-size: 11px; }

/* --- table of contents -------------------------------------------------- */

.toc {
  display: inline-block; min-width: 260px; max-width: 100%;
  margin: 24px 0 8px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  padding: 14px 18px 16px;
}
.toc h2 {
  font-family: var(--f-mono);
  font-size: 10.5px; font-weight: 400; letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.toc h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.toc ol { list-style: none; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc li a {
  display: block; padding: 4px 0;
  font-size: 13.5px; color: var(--ink-dim);
  transition: color var(--t-fast) var(--e-io), transform var(--t-fast) var(--e-out);
}
.toc li a::before {
  content: counter(toc) "  ";
  font-family: var(--f-mono); font-size: 11px; color: var(--acc);
  font-variant-numeric: tabular-nums;
}
.toc li a:hover { color: var(--ink); transform: translateX(3px); }
.toc li a.on { color: var(--acc-hi); }
.toc li.lvl3 { margin-left: 18px; }
.toc li.lvl3 a::before { content: "· "; color: var(--ink-faint); }

/* --- article body ------------------------------------------------------- */

.art-body { font-size: 15.5px; line-height: 1.72; color: var(--ink-dim); max-width: 78ch; }
.art-body > *:first-child { margin-top: 20px; }
.art-body p { margin-bottom: 16px; }
.art-body strong { color: var(--ink); font-weight: 600; }
.art-body em { color: var(--acc-hi); font-style: italic; }

.art-body h2, .art-body h3 {
  font-family: var(--f-display);
  font-weight: 400;
  color: var(--ink);
  letter-spacing: .01em; text-transform: uppercase;
  margin: 34px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 112px;
}
.art-body h2 { font-size: 27px; }
.art-body h3 { font-size: 21px; border-bottom: 0; margin-bottom: 6px; }

.art-body .anchor {
  margin-left: .5em;
  font-family: var(--f-mono); font-size: .5em;
  color: var(--acc);
  opacity: 0; transition: opacity var(--t-fast) var(--e-io);
}
.art-body h2:hover .anchor, .art-body h3:hover .anchor { opacity: 1; }

.art-body ul, .art-body ol { margin: 0 0 16px 22px; }
.art-body li { margin-bottom: 6px; }
.art-body ul { list-style: none; }
.art-body ul li::before {
  content: "▸"; color: var(--acc);
  display: inline-block; width: 1em; margin-left: -1em;
  font-size: .85em;
}
.art-body ol { list-style: decimal; }
.art-body ol li::marker { color: var(--acc); font-family: var(--f-mono); font-size: .85em; }

.art-body a { color: var(--acc-hi); border-bottom: 1px solid color-mix(in oklab, var(--acc) 40%, transparent); }
.art-body a:hover { color: var(--ink); border-bottom-color: var(--acc); background: color-mix(in oklab, var(--acc) 12%, transparent); }

.art-body code {
  font-family: var(--f-mono); font-size: .86em;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 1px 5px; color: var(--acc-hi);
}
.art-body pre {
  background: var(--bg-1); border: 1px solid var(--line);
  border-left: 2px solid var(--acc);
  padding: 14px 16px; overflow-x: auto; margin-bottom: 16px;
}
.art-body pre code { background: none; border: 0; padding: 0; color: var(--ink-dim); font-size: 12.5px; }
.art-body blockquote {
  border-left: 2px solid var(--acc);
  background: color-mix(in oklab, var(--acc) 7%, transparent);
  padding: 12px 16px; margin-bottom: 16px; color: var(--ink);
}

.art-foot {
  clear: both;
  margin-top: 56px; padding-top: 16px;
  border-top: 1px solid var(--line);
  font-family: var(--f-mono); font-size: 11px; letter-spacing: .06em;
  color: var(--ink-faint);
  display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between;
}
.art-foot a { color: var(--ink-mute); }
.art-foot a:hover { color: var(--acc-hi); }

/* ============================================================ INDEX ====== */

.wiki-hero { padding: 36px 0 8px; }
.wiki-hero h1 {
  font-family: var(--f-display); font-weight: 400;
  font-size: clamp(36px, 5.4vw, 60px); line-height: 1.04;
  letter-spacing: .01em; text-transform: uppercase;
}
.wiki-hero p { margin-top: 12px; color: var(--ink-dim); max-width: 62ch; font-size: 15.5px; }
.wiki-hero .rule { margin: 22px 0 0; }

.idx { list-style: none; margin-top: 26px; border-top: 1px solid var(--line); }
.idx li { border-bottom: 1px solid var(--line); }
.idx a {
  display: grid;
  grid-template-columns: 54px minmax(0,1fr) auto;
  gap: 18px; align-items: baseline;
  padding: 16px 10px;
  transition: background var(--t-fast) var(--e-io), padding-left var(--t-med) var(--e-out);
}
.idx a:hover { background: color-mix(in oklab, var(--acc) 8%, transparent); padding-left: 18px; }
.idx .n { font-family: var(--f-mono); font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.idx .nm { font-family: var(--f-display); font-size: 21px; color: var(--ink); letter-spacing: .01em; text-transform: uppercase; }
.idx .tg { display: block; font-size: 13px; color: var(--ink-mute); margin-top: 3px; font-family: var(--f-display); }
.idx a:hover .nm { color: var(--acc-hi); }

/* Print: strip the furniture, keep the article. */
@media print {
  .wiki-top, .rail, .toc, .atmos, .ib-links { display: none !important; }
  body.wiki { background: #fff; color: #000; }
  .art-body, .art-title, .art-sub { color: #000; }
  .wiki-shell { grid-template-columns: 1fr; }
}

/* Infobox media: banner with the square mark badged over its lower-left. */
.ib-media { position: relative; }
.ib-logo {
  position: absolute; left: 12px; bottom: -20px;
  width: 62px; height: 62px;
  border: 2px solid var(--edge);
  background: var(--bg-2);
  box-shadow: 4px 4px 0 var(--edge);
  overflow: hidden;
}
.ib-logo img { width: 100%; height: 100%; object-fit: cover; }
.ib-media:has(.ib-logo) + .ib-cap { padding-top: 26px; }
