/* ---------------- player wiki / documentation reader ---------------- */
.wiki {
  position: relative;
  z-index: 1;
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: clamp(1.1rem, 3.2vh, 2rem) clamp(1rem, 4vw, 2.4rem) clamp(2.4rem, 7vh, 4.5rem);
}

.wiki-top {
  position: relative;
  z-index: 10;
  animation: fade-up .8s .1s cubic-bezier(.2, .8, .2, 1) both;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .74rem;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s ease;
}

.back-link:hover { color: var(--gold); }
.back-link svg { width: 14px; height: 14px; }

.wiki-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: .8rem;
}

.wiki-identity {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-width: 0;
  margin-left: -.55rem;
  padding: .4rem .55rem .4rem .4rem;
  border: 1px solid rgba(255, 255, 255, .07);
  border-radius: 16px;
  background: rgba(255, 255, 255, .02);
  color: inherit;
  text-decoration: none;
  transition:
    background-color .2s ease,
    border-color .2s ease,
    box-shadow .2s ease;
}

.wiki-identity:hover,
.wiki-identity:focus-visible {
  border-color: rgba(255, 255, 255, .13);
  background: rgba(255, 255, 255, .045);
  outline: none;
}

.wiki-identity:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .16);
}

.wiki-identity:hover .wiki-mark {
  border-color: rgba(242, 200, 121, .35);
}

.wiki-ext {
  display: flex;
  align-items: center;
  gap: .3rem;
  margin-left: .3rem;
  padding: .22rem .38rem;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 7px;
  font-size: .55rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color .2s ease, border-color .2s ease;
}

.wiki-ext svg { width: 11px; height: 11px; }

.wiki-identity:hover .wiki-ext {
  color: var(--gold);
  border-color: rgba(242, 200, 121, .35);
}

.wiki-mark {
  width: 48px;
  height: 48px;
  border-radius: 13px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 12px 28px -18px rgba(0, 0, 0, .9);
}

.wiki-identity .kicker {
  margin: 0 0 .25rem;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: var(--muted);
}

.wiki-identity h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -.03em;
  line-height: 1.05;
}

.wiki-lang {
  display: flex;
  align-items: center;
  gap: .6rem;
}

.wiki-lang > span {
  font-size: .61rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.lang-picker { position: relative; }

.lang-trigger {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font: inherit;
  font-size: .8rem;
  color: #e7e2d6;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  padding: .43rem .6rem .43rem .55rem;
  transition:
    border-color .2s ease,
    background-color .2s ease;
  outline: none;
}

.lang-trigger:hover,
.lang-trigger:focus-visible,
.lang-picker.is-open .lang-trigger {
  border-color: rgba(242, 200, 121, .4);
  background: rgba(255, 255, 255, .06);
}

.lang-trigger:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .16);
}

.lang-globe {
  width: 14px;
  height: 14px;
  color: var(--muted);
  flex: 0 0 auto;
}

.lang-chevron {
  width: 13px;
  height: 13px;
  color: var(--muted);
  flex: 0 0 auto;
  transition: transform .2s ease;
}

.lang-picker.is-open .lang-chevron { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .4rem);
  z-index: 40;
  min-width: 190px;
  padding: .3rem;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .055), transparent 42%),
    #0c0b10;
  box-shadow:
    0 24px 55px -24px rgba(0, 0, 0, .92),
    inset 0 1px 0 rgba(255, 255, 255, .07);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition:
    opacity .18s ease,
    transform .18s ease,
    visibility .18s;
}

.lang-picker.is-open .lang-menu {
  opacity: 1;
  visibility: visible;
  transform: none;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  padding: .45rem .5rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #c9c4ba;
  font: inherit;
  font-size: .78rem;
  text-align: left;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}

.lang-option:hover,
.lang-option:focus-visible {
  background: rgba(255, 255, 255, .06);
  color: #fff;
  outline: none;
}

.lang-option[aria-selected="true"] {
  color: var(--gold);
  background: rgba(242, 200, 121, .09);
  border-color: rgba(242, 200, 121, .22);
}

.lang-code {
  width: 1.6rem;
  flex: 0 0 auto;
  font-size: .57rem;
  letter-spacing: .1em;
  color: var(--muted);
}

.lang-name { flex: 1; }

.lang-check {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  opacity: 0;
}

.lang-option[aria-selected="true"] .lang-check { opacity: 1; }

.wiki-grid {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  margin-top: 1.3rem;
}

.wiki-grid > * { min-width: 0; }

.wiki.is-chapters-collapsed .wiki-grid {
  grid-template-columns: minmax(0, 1fr);
}

.wiki.is-chapters-collapsed .wiki-sidebar {
  display: none;
}

/* sidebar */
.wiki-sidebar {
  position: sticky;
  top: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  animation: fade-up .8s .2s cubic-bezier(.2, .8, .2, 1) both;
}

.wiki-search { position: relative; }

.wiki-search > svg {
  position: absolute;
  left: .8rem;
  top: 50%;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

#pageSearch {
  width: 100%;
  font: inherit;
  font-size: .82rem;
  color: var(--fg);
  background: rgba(255, 255, 255, .03);
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 12px;
  padding: .62rem .8rem .62rem 2.15rem;
  outline: none;
  transition: border-color .2s ease, background-color .2s ease;
  -webkit-appearance: none;
  appearance: none;
}

#pageSearch::placeholder { color: #6d6961; }

#pageSearch:focus {
  border-color: rgba(242, 200, 121, .4);
  background: rgba(255, 255, 255, .05);
}

#pageSearch::-webkit-search-cancel-button { filter: invert(.55); }

.wiki-pages {
  display: flex;
  flex-direction: column;
  gap: .22rem;
  max-height: calc(100vh - 16rem);
  overflow-y: auto;
  padding-right: .15rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .14) transparent;
}

.wiki-page {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .52rem .6rem;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #c9c4ba;
  text-decoration: none;
  font-size: .82rem;
  line-height: 1.3;
  transition:
    color .2s ease,
    background-color .2s ease,
    border-color .2s ease;
}

.wiki-page:hover {
  color: #fff;
  background: rgba(255, 255, 255, .045);
  border-color: rgba(255, 255, 255, .08);
}

.wiki-page:focus-visible {
  outline: none;
  border-color: rgba(242, 200, 121, .4);
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .16);
}

.wiki-page.is-active {
  color: #fff;
  border-color: rgba(242, 200, 121, .34);
  background: linear-gradient(90deg, rgba(242, 200, 121, .12), transparent 92%);
}

.wp-icon {
  flex: 0 0 auto;
  width: 1.15rem;
  text-align: center;
  font-size: .92rem;
}

.wp-text {
  display: flex;
  flex-direction: column;
  gap: .13rem;
  min-width: 0;
}

.wp-label {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wp-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .66rem;
  line-height: 1.45;
  color: var(--muted);
  white-space: normal;
  overflow-wrap: anywhere;
}

.wp-snippet mark {
  background: none;
  color: var(--gold);
  font-weight: 600;
}

.wiki-empty {
  margin: 0;
  padding: .35rem .5rem;
  font-size: .76rem;
  color: var(--muted);
}

/* article panel */
.wiki-panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .012)),
    rgba(8, 8, 11, .55);
  box-shadow: 0 30px 80px -55px rgba(0, 0, 0, .95);
  animation: fade-up .8s .26s cubic-bezier(.2, .8, .2, 1) both;
  transition: border-color .25s ease, box-shadow .25s ease;
}

.wiki-panel.is-copied {
  border-color: rgba(46, 230, 160, .5);
  box-shadow:
    0 0 0 1px rgba(46, 230, 160, .14),
    0 0 45px -12px rgba(46, 230, 160, .5),
    0 30px 80px -55px rgba(0, 0, 0, .95);
}

.wiki-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem .75rem .6rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: rgba(255, 255, 255, .015);
}

.chapters-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .025);
  color: #cbc6bb;
  transition:
    color .25s ease,
    border-color .25s ease,
    background-color .25s ease,
    box-shadow .25s ease;
}

.chapters-toggle svg {
  width: 17px;
  height: 17px;
  display: block;
}

.chapters-toggle:hover,
.chapters-toggle:focus-visible {
  color: var(--gold);
  border-color: rgba(242, 200, 121, .45);
  background: rgba(242, 200, 121, .07);
  box-shadow: 0 0 22px -6px rgba(242, 200, 121, .55);
  outline: none;
}

.chapters-toggle:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .18);
}

.chapters-toggle[aria-expanded="false"] {
  color: var(--gold);
  border-color: rgba(242, 200, 121, .35);
  background: rgba(242, 200, 121, .07);
}

.wiki-crumbs {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
  font-size: .82rem;
  color: #d5d0c5;
}

#pageTitle {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wiki-badge {
  flex: 0 0 auto;
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  font-size: .82rem;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  flex: 0 0 auto;
  font: inherit;
  font-size: .71rem;
  color: #d2cdc2;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 9px;
  padding: .4rem .65rem;
  transition:
    color .2s ease,
    border-color .2s ease,
    background-color .2s ease;
}

.copy-btn svg { width: 14px; height: 14px; }

.copy-btn:hover {
  color: var(--gold);
  border-color: rgba(242, 200, 121, .4);
  background: rgba(242, 200, 121, .06);
}

.copy-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .16);
}

.copy-btn.is-copied {
  color: var(--green);
  border-color: rgba(38, 217, 127, .4);
  background: rgba(38, 217, 127, .06);
}

.copy-btn[disabled] {
  opacity: .45;
  pointer-events: none;
}

/* rendered markdown */
.wiki-body {
  padding: clamp(1.1rem, 3vw, 2rem) clamp(1.1rem, 3.4vw, 2.3rem) clamp(1.6rem, 4vw, 2.6rem);
  overflow-wrap: anywhere;
}

.wiki-body > :first-child { margin-top: 0; }
.wiki-body > :last-child { margin-bottom: 0; }

.wiki-body h1,
.wiki-body h2,
.wiki-body h3,
.wiki-body h4 {
  color: #f3efe6;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.2;
}

.wiki-body h1 {
  font-size: clamp(1.45rem, 2.8vw, 1.9rem);
  margin: 0 0 1rem;
}

.wiki-body h2 {
  font-size: clamp(1.15rem, 2vw, 1.4rem);
  margin: 2rem 0 .75rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.wiki-body h3 {
  font-size: 1.02rem;
  margin: 1.6rem 0 .55rem;
}

.wiki-body h4 {
  font-size: .92rem;
  margin: 1.4rem 0 .45rem;
}

.wiki-body p {
  margin: 0 0 1rem;
  color: #c5c0b6;
  font-size: .93rem;
  line-height: 1.8;
}

.wiki-body a {
  color: var(--gold);
  text-decoration: none;
  border-bottom: 1px solid rgba(242, 200, 121, .28);
  transition: color .2s ease, border-color .2s ease;
}

.wiki-body a:hover {
  color: #ffe7b0;
  border-color: var(--gold);
}

.wiki-body strong { color: #f4f0e7; font-weight: 600; }
.wiki-body em { color: #ddd8cd; }
.wiki-body del { color: #7e7970; }

.wiki-body ul,
.wiki-body ol {
  margin: 0 0 1.1rem;
  padding-left: 1.3rem;
  color: #c5c0b6;
  font-size: .93rem;
}

.wiki-body li { margin: .28rem 0; line-height: 1.7; }
.wiki-body li::marker { color: rgba(242, 200, 121, .7); }

.wiki-body hr {
  margin: 1.9rem 0;
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, .08);
}

.wiki-body blockquote {
  margin: 1.2rem 0;
  padding: .1rem 0 .1rem 1rem;
  border-left: 2px solid rgba(242, 200, 121, .45);
  color: #a9a49a;
}

.wiki-body blockquote p { margin: .35rem 0; color: inherit; }

.wiki-body img {
  max-width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, .08);
}

.wiki-body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .86em;
  color: #f6dfae;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .06);
  border-radius: 5px;
  padding: .12em .38em;
}

/* tables */
.table-wrap {
  margin: 0 0 1.3rem;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 12px;
  scrollbar-width: thin;
}

.wiki-body table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: .84rem;
}

.wiki-body th {
  padding: .58rem .75rem;
  text-align: left;
  font-weight: 500;
  color: #ded9ce;
  background: rgba(255, 255, 255, .035);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  white-space: nowrap;
}

.wiki-body td {
  padding: .52rem .75rem;
  color: #b9b4aa;
  vertical-align: top;
  border-top: 1px solid rgba(255, 255, 255, .05);
}

.wiki-body tbody tr:hover { background: rgba(255, 255, 255, .018); }
.wiki-body td code { white-space: nowrap; }

.wiki-body mark.search-hit {
  background: rgba(242, 200, 121, .28);
  color: #fff;
  border-radius: 3px;
  padding: 0 .06em;
}

/* code blocks + syntax colors */
.code-block {
  position: relative;
  margin: 0 0 1.25rem;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 13px;
  background: #0a090e;
  overflow: hidden;
  transition: border-color .25s ease, box-shadow .25s ease;
}

.code-block.is-copied {
  border-color: rgba(46, 230, 160, .55);
  box-shadow:
    0 0 0 1px rgba(46, 230, 160, .16),
    0 0 32px -8px rgba(46, 230, 160, .55);
}

.code-lang {
  display: flex;
  align-items: center;
  gap: .35rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .57rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #5f5b54;
  pointer-events: none;
}

.code-lang svg { width: 12px; height: 12px; flex: 0 0 auto; }

.code-lang.is-command { color: var(--gold); }
.code-lang.is-command svg { color: var(--gold); }

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: .3rem .45rem .3rem .9rem;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  background: rgba(255, 255, 255, .018);
}

.code-copy {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 7px;
  background: rgba(255, 255, 255, .035);
  color: #8d887e;
  transition:
    color .2s ease,
    background-color .2s ease,
    border-color .2s ease;
}

.code-copy svg { width: 15px; height: 15px; }

.code-copy:hover {
  color: var(--gold);
  background: rgba(255, 255, 255, .05);
  border-color: rgba(255, 255, 255, .1);
}

.code-copy:focus-visible {
  outline: none;
  color: var(--gold);
  border-color: rgba(242, 200, 121, .4);
  box-shadow: 0 0 0 3px rgba(242, 200, 121, .14);
}

.code-copy.is-copied {
  color: var(--green);
  background: rgba(38, 217, 127, .08);
  border-color: rgba(38, 217, 127, .35);
}

.code-block pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  scrollbar-width: thin;
}

.code-block code {
  display: block;
  background: none;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .82rem;
  line-height: 1.68;
  color: #cdc7ba;
  white-space: pre;
}

.tok-command { color: #f2c879; }
.tok-string { color: #7fe3a1; }
.tok-number { color: #ff9f6b; }
.tok-comment { color: #6c675f; font-style: italic; }
.tok-placeholder { color: #b9a6ff; }
.tok-bool { color: #7ec8ff; }

/* states */
.wiki-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  padding: 3rem 0;
  color: var(--muted);
  font-size: .84rem;
}

.wiki-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .14);
  border-top-color: var(--gold);
  animation: wiki-spin .9s linear infinite;
}

@keyframes wiki-spin { to { transform: rotate(360deg); } }

.wiki-notice {
  margin-bottom: 1.1rem;
  padding: .7rem .85rem;
  border: 1px solid rgba(242, 200, 121, .28);
  border-radius: 11px;
  background: rgba(242, 200, 121, .07);
  color: #d9c9a6;
  font-size: .79rem;
  line-height: 1.6;
}

.wiki-error {
  padding: 2.2rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: .84rem;
}

.wiki-error strong {
  display: block;
  margin-bottom: .35rem;
  color: #e9e4d9;
  font-weight: 500;
  font-size: .95rem;
}

.retry-btn {
  margin-top: .9rem;
  font: inherit;
  font-size: .76rem;
  color: var(--gold);
  background: rgba(242, 200, 121, .07);
  border: 1px solid rgba(242, 200, 121, .32);
  border-radius: 9px;
  padding: .45rem .8rem;
  transition: background-color .2s ease, border-color .2s ease;
}

.retry-btn:hover {
  background: rgba(242, 200, 121, .12);
  border-color: rgba(242, 200, 121, .55);
}

/* responsive */
@media (max-width: 900px) {
  .wiki-grid { grid-template-columns: 1fr; }

  .wiki-sidebar { position: static; min-width: 0; }

  .wiki-pages {
    flex-direction: row;
    max-height: none;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: .35rem;
    scroll-snap-type: x proximity;
  }

  .wiki-page {
    flex: 0 0 auto;
    border-color: rgba(255, 255, 255, .07);
    background: rgba(255, 255, 255, .02);
    scroll-snap-align: start;
  }

  .wiki-page .wp-label { max-width: 220px; }
}

@media (max-width: 560px) {
  .wiki { padding-top: .9rem; }
  .wiki-ext-label { display: none; }
  .wiki-identity { padding-right: .4rem; }
  .wiki-lang { width: 100%; justify-content: space-between; }
  .wiki-mark { width: 42px; height: 42px; }
  .wiki-toolbar { padding: .5rem .55rem .5rem .75rem; }
  .wiki-body { padding: 1rem .9rem 1.4rem; }
  .wiki-body table { min-width: 360px; }
  .copy-btn { padding: .38rem .55rem; font-size: .68rem; }
  .wiki-body p,
  .wiki-body li { font-size: .89rem; }
  .code-block code { font-size: .78rem; }
}
