/* ============================================================================
 * Norwyn Idle Wiki — layout on top of the GAME's stylesheet.
 * ----------------------------------------------------------------------------
 * index.html loads /play/css/styles.css FIRST, so every colour variable, theme,
 * rarity colour and the whole .db-* / .popup family come from the game. This
 * file only adds the wiki's own chrome (top bar, navigation rail, article
 * typography) under its own class names so nothing collides with the game.
 *
 * USABILITY FIRST (owner's call): wide comfortable measure, large tap targets,
 * a permanently visible page list, and a search that reaches every section as
 * well as every item and creature.
 * ==========================================================================*/

:root {
  --wt-h: 58px;        /* top bar height */
  --wn-w: 286px;       /* navigation rail width */
}

/* The game's stylesheet sets html,body to height:100% for its app grid. The
   wiki is a normal scrolling document instead. */
html, body.wiki-body { height: auto; min-height: 100%; }
body.wiki-body { background: var(--bg); }

/* ⚠️ Deliberately NO `html { scroll-behavior: smooth }`. Jumping to a topic is
   the wiki's core navigation, and a browser that accepts the smooth keyword but
   never runs the animation would leave every topic link dead. wiki.js asks for
   a smooth scroll and falls back to an instant one if nothing moved, which
   needs the CSS to stay out of the way. */

/* ---- Top bar -------------------------------------------------------------- */
.wt {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  height: var(--wt-h); padding: 0 18px;
  background: var(--bg2); border-bottom: 1px solid var(--border);
}
.wt-burger {
  display: none;
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  font-size: 17px; cursor: pointer; flex-shrink: 0;
}
.wt-burger:hover { background: var(--panel2); }
.wt-brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.wt-logo { height: 30px; width: auto; display: block; flex-shrink: 0; }
.wt-name { font-size: 19px; font-weight: 800; letter-spacing: .2px; white-space: nowrap; }
.wt-name .accent { color: var(--gold); }
.wt-tag {
  margin-left: 4px; padding: 2px 8px; border-radius: 999px;
  background: var(--panel3); border: 1px solid var(--border2);
  font-size: 11px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--ink-dim); vertical-align: 3px;
}
.wt-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.wt-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid var(--border2); color: var(--ink); background: var(--panel2);
  transition: filter .12s, background .12s;
}
.wt-btn:hover { background: var(--panel3); }
.wt-play { background: var(--gold); border-color: var(--gold); color: #201a09; }
.wt-play:hover { filter: brightness(1.08); background: var(--gold); }
.wt-discord { width: 44px; padding: 0; background: #5865F2; border-color: #5865F2; color: #fff; }
.wt-discord:hover { background: #5865F2; filter: brightness(1.1); }
.wt-discord svg { display: block; }

/* ---- Frame ---------------------------------------------------------------- */
.wiki-frame { display: flex; align-items: flex-start; }

/* ---- Navigation rail ------------------------------------------------------ */
.wn {
  position: sticky; top: var(--wt-h);
  flex: 0 0 var(--wn-w); width: var(--wn-w);
  height: calc(100vh - var(--wt-h));
  display: flex; flex-direction: column;
  background: var(--bg2); border-right: 1px solid var(--border);
}
.wn-scrim { display: none; }
.wn-search { position: relative; padding: 14px 14px 10px; }
.wn-input {
  width: 100%; height: 40px; padding: 0 34px 0 12px;
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--ink); font-family: var(--ui-font); font-size: 14px;
}
.wn-input:focus { outline: none; border-color: var(--border2); background: rgba(255,255,255,.07); }
.wn-input::placeholder { color: var(--ink-faint); }
.wn-search-x {
  position: absolute; right: 20px; top: 50%; transform: translateY(-25%);
  width: 24px; height: 24px; border-radius: 6px;
  background: transparent; border: 0; color: var(--ink-faint); cursor: pointer; font-size: 13px;
}
.wn-search-x:hover { color: var(--ink); background: var(--panel3); }

.wn-list, .wn-results { flex: 1; overflow-y: auto; padding: 0 10px 22px; }
.wn-list, .wn-results { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
.wn-list::-webkit-scrollbar, .wn-results::-webkit-scrollbar { width: 8px; }
.wn-list::-webkit-scrollbar-thumb, .wn-results::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 999px; }

.wn-head {
  margin: 16px 8px 7px; font-size: 11px; letter-spacing: 1.6px; font-weight: 700;
  text-transform: uppercase; color: var(--ink-faint);
}
.wn-page {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  font-family: var(--ui-font); font-size: 14.5px; font-weight: 600;
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  text-decoration: none; transition: background .12s, color .12s;
}
.wn-page:hover { background: var(--panel2); color: var(--ink); }
.wn-page.on { background: var(--panel3); color: var(--gold-2); box-shadow: inset 3px 0 0 -1px var(--gold); }
.wn-ico { font-size: 17px; width: 22px; text-align: center; flex-shrink: 0; }
/* A page nested under the one above it (the three Skills categories under
   Skills). Indented with a rule down the left so the grouping is visible even
   when none of them is the current page. */
.wn-page.wn-child {
  margin-left: 22px; padding-left: 11px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 1px solid var(--border); font-size: 14px;
}
.wn-page.wn-child.on { border-left-color: var(--gold); }

/* Sub-topics: shown only under the page you are reading, so the rail stays
   short and scannable. Search is what finds a topic on another page. */
.wn-subs { margin: 2px 0 8px 22px; padding-left: 11px; border-left: 1px solid var(--border); }
.wn-sub {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--ink-dim);
  font-family: var(--ui-font); font-size: 13.5px; font-weight: 500;
  padding: 6px 10px; border-radius: 6px; cursor: pointer; text-decoration: none;
  transition: background .12s, color .12s;
}
.wn-sub:hover { background: var(--panel2); color: var(--ink); }
.wn-sub.on { color: var(--gold-2); background: var(--panel2); font-weight: 700; }
.wn-sub-ext::after { content: " ↗"; color: var(--ink-faint); font-size: 11px; }

/* ---- Search results (replace the page list while typing) ------------------ */
.wn-res-head {
  margin: 14px 8px 6px; font-size: 11px; letter-spacing: 1.4px; font-weight: 700;
  text-transform: uppercase; color: var(--ink-faint);
}
.wn-res {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--ink);
  font-family: var(--ui-font); font-size: 14px; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; text-decoration: none;
}
.wn-res:hover { background: var(--panel2); }
.wn-res-art { width: 26px; height: 26px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.wn-res-art img { width: 26px; height: 26px; object-fit: contain; image-rendering: pixelated; }
.wn-res-art .item-ico { font-size: 19px; }
.wn-res-txt { min-width: 0; }
.wn-res-title { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wn-res-sub { display: block; font-size: 12px; color: var(--ink-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wn-res-empty { padding: 18px 12px; color: var(--ink-faint); font-size: 13.5px; }
mark { background: rgba(234,181,67,.25); color: var(--gold-2); border-radius: 3px; padding: 0 1px; }

/* ---- Article -------------------------------------------------------------- */
.wm { flex: 1; min-width: 0; }
.wiki-page { max-width: 860px; margin: 0 auto; padding: 34px 36px 60px; }
.wiki-page h1 {
  margin: 0 0 10px; font-size: 34px; font-weight: 800; letter-spacing: -.3px; color: var(--ink);
}
.wiki-lead {
  margin: 0 0 8px; font-size: 16.5px; line-height: 1.65; color: var(--ink-dim);
  padding-bottom: 22px; border-bottom: 1px solid var(--border);
}
.wiki-page section { scroll-margin-top: calc(var(--wt-h) + 16px); padding-top: 14px; }
.wiki-page h2 {
  margin: 22px 0 12px; font-size: 24px; font-weight: 700; color: var(--gold-2);
}
.wiki-page h3 { margin: 20px 0 8px; font-size: 17.5px; font-weight: 700; color: var(--ink); }
.wiki-page p, .wiki-page li { font-size: 15.5px; line-height: 1.72; color: var(--ink-dim); }
.wiki-page p { margin: 0 0 14px; }
.wiki-page ul, .wiki-page ol { margin: 0 0 16px; padding-left: 22px; }
.wiki-page li { margin-bottom: 6px; }
.wiki-page b, .wiki-page strong { color: var(--ink); }
.wiki-page a { color: var(--gold-2); }
.wiki-page hr { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }
.wiki-page table {
  width: 100%; border-collapse: collapse; margin: 0 0 18px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.wiki-page th, .wiki-page td { padding: 9px 13px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.wiki-page th { color: var(--ink); font-weight: 700; background: var(--panel3); }
.wiki-page td { color: var(--ink-dim); }
.wiki-page tr:last-child td { border-bottom: 0; }
.wiki-table-wrap { overflow-x: auto; }

/* A callout box for rules and warnings inside an article. */
.wiki-note {
  background: var(--panel2); border: 1px solid var(--border); border-left: 3px solid var(--gold);
  border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 18px;
}
.wiki-note p:last-child { margin-bottom: 0; }

/* ---- "Important for" badges (gathering + crafting skills) ------------------
   One chip per attack style: the style's icon, its name, and a three-pip meter.
   Very = 3 pips, Medium = 2, Not needed = 0 and the whole chip fades back, so
   "this style does not need this skill" reads without counting anything.
   Built by renderImportance() in wiki.js from a one-line data attribute. */
.wiki-imp {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 16px; padding: 10px 12px;
  background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.imp-label {
  font-size: 11px; letter-spacing: 1.3px; text-transform: uppercase; font-weight: 700;
  color: var(--ink-faint); margin-right: 2px;
}
.imp-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 10px 5px 8px; border-radius: 999px;
  background: var(--panel2); border: 1px solid var(--border2);
}
.imp-ico { font-size: 14px; line-height: 1; }
.imp-name { font-size: 13px; font-weight: 700; color: var(--ink); }
.imp-meter { display: inline-flex; align-items: center; gap: 3px; }
.imp-meter i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border2); display: block;
}
/* A lit pip takes the attack style's own colour, the same three the game uses. */
.imp-st-melee  .imp-meter i.on { background: var(--st-melee); }
.imp-st-ranged .imp-meter i.on { background: var(--st-ranged); }
.imp-st-magic  .imp-meter i.on { background: var(--st-magic); }
.imp-st-melee.imp-very  { border-color: var(--st-melee); }
.imp-st-ranged.imp-very { border-color: var(--st-ranged); }
.imp-st-magic.imp-very  { border-color: var(--st-magic); }
/* Not needed: dimmed rather than hidden, because "Melee does not need this" is
   itself useful information. */
.imp-chip.imp-none { opacity: .45; }
.imp-chip.imp-none .imp-name { color: var(--ink-dim); font-weight: 600; }

/* The one-line key, printed once at the top of a skills page. */
.wiki-imp-key {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  margin: 0 0 20px; font-size: 12.5px; color: var(--ink-faint);
}
.wiki-imp-key b { color: var(--ink-dim); font-weight: 600; }
.wiki-imp-key .k { display: inline-flex; align-items: center; gap: 6px; }
.wiki-imp-key .imp-meter i.on { background: var(--gold); }

@media (max-width: 620px) {
  .wiki-imp { gap: 6px; padding: 9px 10px; }
  .imp-label { width: 100%; margin-bottom: 2px; }
  .imp-chip { padding: 4px 9px 4px 7px; gap: 6px; }
  .imp-name { font-size: 12px; }
}

/* Placeholder for a section whose text has not been written yet. Deliberately
   obvious, so an unfinished page can never be mistaken for a finished one. */
.wiki-todo {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.03); border: 1px dashed var(--border2); border-radius: var(--radius-sm);
  padding: 14px 16px; margin: 0 0 16px;
  color: var(--ink-faint); font-size: 14px; font-style: italic;
}

.wiki-foot {
  max-width: 860px; margin: 0 auto; padding: 20px 36px 44px;
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  border-top: 1px solid var(--border); color: var(--ink-faint); font-size: 13px;
}
.wiki-foot a { color: var(--ink-dim); text-decoration: none; }
.wiki-foot a:hover { color: var(--gold-2); text-decoration: underline; }

.wiki-loading { padding: 40px 0; color: var(--ink-faint); }

/* ---- The generated databases --------------------------------------------- */
/* The .db-* shell comes from the game's stylesheet. These are the few wiki-only
   tweaks: the rail already eats 286px, so the list gets more room, and the
   lists are taller because a wiki page has no active-task bar under it. */
.wiki-page .db-list-inner, .wiki-page .db-opt-list { max-height: 66vh; }
.wiki-page .db-wrap { margin-top: 6px; }
.db-row-sub { color: var(--ink-faint); font-size: 12.5px; }

/* ---- Phone / tablet ------------------------------------------------------- */
@media (max-width: 900px) {
  .wt { padding: 0 12px; gap: 10px; }
  .wt-burger { display: inline-flex; align-items: center; justify-content: center; }
  .wt-name { font-size: 16px; }
  .wt-tag { display: none; }
  .wt-logo { height: 26px; }
  .wt-btn { height: 36px; padding: 0 12px; font-size: 13px; }
  .wt-discord { width: 40px; }

  /* The rail becomes a drawer. It is OFF-CANVAS by default so the article gets
     the whole width, and slides in over a scrim when the burger is tapped. */
  .wn {
    position: fixed; top: var(--wt-h); left: 0; z-index: 55;
    height: calc(100vh - var(--wt-h)); width: min(320px, 86vw); flex-basis: auto;
    transform: translateX(-102%); transition: transform .2s ease;
    box-shadow: 12px 0 40px rgba(0,0,0,.45);
  }
  .wn.open { transform: none; }
  .wn-scrim {
    display: block; position: fixed; inset: var(--wt-h) 0 0 0; z-index: 50;
    background: rgba(6,7,9,.6); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .wn-scrim.on { opacity: 1; pointer-events: auto; }

  .wiki-page { padding: 24px 18px 48px; }
  .wiki-page h1 { font-size: 27px; }
  .wiki-lead { font-size: 15.5px; }
  .wiki-page h2 { font-size: 21px; }
  .wiki-foot { padding: 18px 18px 40px; gap: 14px; }
  .wiki-page .db-list-inner { max-height: none; }
}
