/* WIKI TOPIC PAGES (owner: topics) — pages/topics.mjs: the hub, how augments
   work, stats, synergies, Skill Tree + Dojo, Demon Fruits, achievements,
   sectors, fragments, glossary. Loaded after cards.css + wiki.css; uses the
   design tokens of base.css (ink, paper, accent, rarity --rc) only.
   Wing colours of the Skill Tree: --wc on .w-<wing>. Logical properties
   throughout (RTL), motion only with prefers-reduced-motion: no-preference. */

.w-CENTER { --wc: var(--paper); } .w-N { --wc: #ef4444; } .w-NE { --wc: #fb923c; } .w-E { --wc: #facc15; }
.w-SE { --wc: #a78bfa; } .w-S { --wc: #22d3ee; } .w-SW { --wc: #f472b6; } .w-W { --wc: #e0a92b; } .w-NW { --wc: #34d399; }

/* ---- page head + table of contents ----------------------------------- */
.tph .kicker { display: inline-flex; align-items: center; gap: 8px; font: 900 .74rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink); background: var(--accent); border: 2px solid var(--ink); box-shadow: 3px 3px 0 #000; padding: 5px 9px 5px 5px; text-decoration: none; margin-bottom: 14px; }
.tph .kicker .glyph { background: var(--paper); border-radius: 50%; padding: 2px; border: 2px solid var(--ink); }
.tph .upd { font: 600 .8rem/1.3 var(--mono); color: #a39d8a; text-transform: uppercase; letter-spacing: .06em; }
.tph .lead2 { color: #d9d2bd; }
.toc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 8px; }
.toc b { font: 900 .7rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .12em; color: #a39d8a; }
.toc ol { display: contents; list-style: none; }
.toc li a { display: inline-block; font: 700 .88rem/1 var(--ui); color: var(--paper); text-decoration: none; padding: 7px 10px; border: 2px solid #3b3f55; background: #141a33; }
.toc li a:hover, .toc li a:focus-visible { border-color: var(--accent); color: var(--accent); }
.tsec { scroll-margin-top: 84px; }
.tsec h3 { font-size: 1.45rem; margin-top: 1.1em; }
.tsec > p { max-width: 75ch; }
.tsec .note { font-weight: 600; color: #5b5547; border-inline-start: 4px solid var(--accent); padding-inline-start: 10px; }
.big { font: 400 1.6rem/1 var(--display); letter-spacing: .04em; }
.sub { display: block; font-weight: 600; color: #5b5547; font-size: .92rem; }
.more { font-weight: 800; }
.neg { color: #b91c1c; }
.pos { color: #166534; }

/* ---- data tables ------------------------------------------------------ */
.tt { width: 100%; border-collapse: collapse; font-weight: 600; font-variant-numeric: tabular-nums; }
.tt th, .tt td { border: 2px solid var(--ink); padding: 8px 10px; text-align: start; vertical-align: top; }
.tt thead th { background: var(--ink); color: var(--accent); font: 900 .72rem/1.2 var(--heavy); text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0; }
.tt tbody th { background: var(--paper2); font-weight: 800; }
.tt tbody tr:nth-child(even) td { background: rgba(13, 13, 13, .035); }
.tt.kv { max-width: 560px; }
.tt.compact { max-width: 620px; }
.tt.compact td, .tt.compact th, .tt.stat td, .tt.stat th { padding: 6px 10px; }
.tt.nodes td:nth-child(2) { min-width: 18em; }
.tt .h-r { -webkit-text-stroke: 0; text-shadow: 0 0 0 transparent; filter: brightness(1.25); }
.tt.odds tbody th { text-align: center; }
.tt .inl::before { content: ""; display: inline-block; width: .62em; height: .62em; margin-inline-end: .4em; background: var(--rc); border: 2px solid var(--ink); transform: rotate(45deg); vertical-align: .05em; }
.tt .inl { text-decoration-thickness: 1px; }
.tt .capb { color: #6b6555; font-size: .88em; white-space: nowrap; }
.frag { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.frag img { opacity: .85; }
.frag.free { font: 900 .7rem/1 var(--heavy); letter-spacing: .08em; background: #166534; color: var(--paper); padding: 3px 6px; }

/* ---- odds bars + the luck slider --------------------------------------- */
.odd { position: relative; display: inline-block; min-width: 5.2em; padding: 2px 6px; font-weight: 800; isolation: isolate; }
.odd i { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); max-width: 100%; background: var(--mk); z-index: -1; }
.tt.odds .odd { min-width: 4.6em; }
.oddslive { border: 3px solid var(--ink); background: #fff; box-shadow: 4px 4px 0 #000; padding: 14px 16px; margin: 6px 0 18px; max-width: 760px; }
.oddslive label { display: block; font: 900 .8rem/1.2 var(--heavy); text-transform: uppercase; letter-spacing: .08em; }
.oddslive output { font: 400 1.9rem/1 var(--display); color: var(--ink); background: var(--accent); padding: 2px 8px; border: 2px solid var(--ink); margin-inline-start: 6px; display: inline-block; min-width: 3.4em; text-align: center; }
.oddslive input[type=range] { width: 100%; margin: 14px 0 10px; accent-color: #0d0d0d; height: 28px; }
.oddslive input[type=range]:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bars li { display: grid; grid-template-columns: minmax(6em, 9em) 1fr 4.6em; align-items: center; gap: 10px; }
.bars .bn { font: 900 .78rem/1.1 var(--heavy); text-transform: uppercase; color: color-mix(in srgb, var(--rc) 70%, #000); }
.bars .bt { height: 18px; border: 2px solid var(--ink); background: var(--paper2); position: relative; }
.bars .bt i { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--w); background: var(--rc); }
.bars b { text-align: end; font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: no-preference) { .bars .bt i { transition: width .18s ease-out; } }

/* ---- small fact rows, node chips, node lists ---------------------------- */
.stackfacts { list-style: none; padding: 0; margin: 10px 0 16px; display: flex; flex-wrap: wrap; gap: 10px; }
.stackfacts li { border: 2px solid var(--ink); background: var(--paper2); padding: 8px 12px; font-weight: 700; display: flex; align-items: baseline; gap: 8px; }
.stackfacts.links li { padding: 0; }
.stackfacts.links a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; text-decoration: none; color: var(--ink) !important; font: 900 .85rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .05em; }
.stackfacts.links a:hover { background: var(--accent); }
.node { display: inline-flex; align-items: center; gap: 6px; font: 900 .74rem/1.15 var(--heavy); text-transform: uppercase; letter-spacing: .04em; color: var(--ink) !important; text-decoration: none; vertical-align: middle; }
.node .glyph { flex: none; width: 26px; height: 26px; padding: 3px; border-radius: 50%; background: var(--wc); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
a.node:hover span { text-decoration: underline; }
.nodelist { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px; }
.nodelist li { border: 2px solid var(--ink); background: #fff; padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; border-inline-start: 6px solid var(--wc, var(--ink)); }
.nodelist li:has(.w-N) { --wc: #ef4444; } .nodelist li:has(.w-NE) { --wc: #fb923c; } .nodelist li:has(.w-E) { --wc: #facc15; } .nodelist li:has(.w-SE) { --wc: #a78bfa; }
.nodelist li:has(.w-S) { --wc: #22d3ee; } .nodelist li:has(.w-SW) { --wc: #f472b6; } .nodelist li:has(.w-W) { --wc: #e0a92b; } .nodelist li:has(.w-NW) { --wc: #34d399; }
.nodelist .cost { margin-inline-start: auto; font-weight: 800; }
.nodelist p { flex-basis: 100%; margin: 0; font-size: .95rem; }
.dojomini { margin: 4px 0 10px; }

/* ---- augment cards with their text, chains, rivals --------------------- */
.dcards { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 16px; }
.dc { display: flex; flex-direction: column; gap: 8px; }
.dc > p { margin: 0; padding: 10px 12px; background: #fff; border: 2px solid var(--ink); border-top: 0; margin-top: -10px; font: 500 .9rem/1.45 var(--mono); }
.dc > p b.hl { color: #0d0d0d; background: var(--mk); padding: 0 2px; }
.topic-chain { list-style: none; padding: 0; margin: 14px 0; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 4px; }
.topic-chain li { display: flex; flex-direction: column; gap: 6px; flex: 1 1 230px; max-width: 330px; position: relative; }
.topic-chain li small { font-weight: 600; color: #5b5547; font-size: .85rem; }
.topic-chain .arrow { position: absolute; inset-inline-start: -16px; top: 22px; font: 400 2rem/1 var(--display); color: var(--ink); }
.topic-chain li + li { margin-inline-start: 14px; }
.rivals { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin: 10px 0; }
.rivals .vs { font: 400 2.2rem/1 var(--display); }
.rivals p { grid-column: 1 / -1; margin: 0; }
.mult { display: grid; grid-template-columns: 1fr; gap: 14px; margin: 16px 0 26px; padding-bottom: 18px; border-bottom: 3px dashed rgba(13, 13, 13, .25); }
@media (min-width: 900px) { .mult { grid-template-columns: minmax(300px, 1fr) 1.4fr; } }
.chips2 { list-style: none; padding: 0; margin: 6px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.chips2 li { border: 2px solid var(--ink); background: #fff; padding: 4px 8px; font-size: .92rem; }

/* ---- Skill Tree map ----------------------------------------------------- */
.treemap { margin: 18px 0 0; background: radial-gradient(circle at 50% 48%, #1c2448 0, #0b0f1d 70%); border: 3px solid var(--ink); box-shadow: var(--sh); padding: 10px; }
.treemap svg { display: block; width: 100%; height: auto; max-height: 78vh; }
.treemap line { stroke: #5b6488; stroke-width: 3; }
.treemap line.e.any { stroke-dasharray: 6 6; }
.treemap line.e { stroke: #5b6488; }
.treemap circle { fill: var(--wc); stroke: #0d0d0d; stroke-width: 3; }
.treemap a:hover circle, .treemap a:focus circle { stroke: #fff; stroke-width: 4; }
.treemap a:focus { outline: none; }
.treemap figcaption { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.treemap .wing, h3.wing { display: inline-flex; align-items: center; gap: 6px; }
.treemap .wing { font: 900 .7rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .08em; text-decoration: none; color: var(--ink); background: var(--wc); border: 2px solid var(--ink); padding: 5px 8px; }
h3.wing::before { content: ""; width: 16px; height: 16px; border-radius: 50%; background: var(--wc); border: 2px solid var(--ink); flex: none; }
h3.wing small { font-family: var(--ui); font-size: .55em; letter-spacing: 0; opacity: 1; color: #5b5547; display: inline-flex; gap: 6px; align-items: center; }

/* ---- feats + sectors + breakout ---------------------------------------- */
.fic .glyph { width: 34px; height: 34px; padding: 5px; border-radius: 50%; background: var(--accent); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink); }
.tt.feats td:first-child, .tt.feats th:first-child { width: 52px; text-align: center; }
.tt.feats .fn { font: 900 .9rem/1.2 var(--heavy); text-transform: uppercase; letter-spacing: .03em; }
.tt.feats .rw { font: 400 1.3rem/1 var(--display); letter-spacing: .04em; white-space: nowrap; }
.tt.feats .more { display: inline-block; margin-top: 4px; font-size: .9rem; }
.tt.sectors .sn { display: block; font: 600 .74rem/1.2 var(--mono); text-transform: uppercase; letter-spacing: .08em; color: #6b6555; }
.hz { display: inline-block; font: 900 .72rem/1 var(--heavy); letter-spacing: .08em; background: var(--danger); color: #fff; border: 2px solid var(--ink); padding: 4px 7px; }
.bosslink { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink) !important; }
.bosslink img { background: radial-gradient(circle, color-mix(in srgb, var(--ac) 45%, transparent) 0, transparent 70%); }
.bosslink span { display: flex; flex-direction: column; font: 600 .74rem/1.2 var(--mono); text-transform: uppercase; }
.bosslink b { font: 400 1.25rem/1 var(--display); letter-spacing: .04em; }
.bosslink:hover b { text-decoration: underline; }
.lv { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; font-size: .9rem; }
.lv li span { display: inline-block; min-width: 4.4em; font: 600 .72rem/1.3 var(--mono); text-transform: uppercase; color: #6b6555; }
.lv li.have span { color: #166534; }
.lv em { font-style: normal; font-weight: 800; color: #166534; }
.tag2 { display: inline-block; margin-top: 6px; font: 900 .64rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .08em; border: 2px solid var(--ink); padding: 3px 6px; background: var(--paper2); }
.kick2 { font: 900 .78rem/1.2 var(--heavy); text-transform: uppercase; letter-spacing: .1em; color: #6b6555; }

/* ---- Demon Fruits ------------------------------------------------------- */
.fruitrule { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-bottom: 10px; }
.fruitrule .band-fruit { font: 900 .8rem/1 var(--heavy); text-transform: uppercase; letter-spacing: .1em; color: #fff; background: #dc2626; border: 2px solid var(--ink); padding: 7px 10px; box-shadow: 3px 3px 0 var(--ink); }
.fruitrule .big { margin: 0; }

/* ---- glossary ----------------------------------------------------------- */
.gloss { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: 12px; }
.gloss > div { border: 2px solid var(--ink); background: #fff; padding: 12px 14px; scroll-margin-top: 84px; }
.gloss > div:target { outline: 4px solid var(--accent); }
.gloss dt { font: 900 .95rem/1.2 var(--heavy); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; }
.gloss dd { margin: 0; font-size: .97rem; }

/* ---- topic cards (hub + related) ---------------------------------------- */
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.tcard { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: var(--ink); background: var(--paper); border: 3px solid var(--ink); box-shadow: var(--sh); padding: 14px 16px; }
.tcard:hover, .tcard:focus-visible { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 #000; background: #fff; }
.tcard .tc-i { flex: none; width: 48px; height: 48px; padding: 8px; border-radius: 50%; background: var(--accent); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); }
.tc-t { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tc-t b { font: 400 1.45rem/1.05 var(--display); letter-spacing: .03em; }
.tc-t span { font: 600 .9rem/1.35 var(--ui); color: #4b463b; }
.related { margin-top: 40px; }

/* ---- phones: tables become cards ---------------------------------------- */
@media (max-width: 700px) {
  .tt.keep { font-size: .9rem; }
  .tt.keep th, .tt.keep td { padding: 6px 7px; }
  .tt:not(.keep) thead { display: none; }
  .tt:not(.keep), .tt:not(.keep) tbody, .tt:not(.keep) tr, .tt:not(.keep) th, .tt:not(.keep) td { display: block; width: 100%; }
  .tt:not(.keep) tr { margin-bottom: 10px; border: 2px solid var(--ink); background: #fff; }
  .tt:not(.keep) th, .tt:not(.keep) td { border: 0; padding: 6px 10px; }
  .tt:not(.keep) tbody th { background: var(--paper2); }
  .tt:not(.keep) td::before { content: attr(data-label); display: block; font: 900 .64rem/1.3 var(--heavy); text-transform: uppercase; letter-spacing: .08em; color: #6b6555; }
  .tt td[data-label=""]::before { display: none; }
  .tt.feats td:first-child, .tt.feats th:first-child { width: auto; text-align: start; }
  .tt.odds td, .tt.odds th { text-align: start; }
  .tt.odds tbody tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); }
  .tt.odds tbody th { grid-column: 1 / -1; }
  .tt.nodes td:nth-child(2) { min-width: 0; }
  .bars li { grid-template-columns: 6.5em 1fr 4.2em; gap: 6px; }
  .rivals { grid-template-columns: 1fr; }
  .rivals .vs { text-align: center; }
  .topic-chain li + li { margin-inline-start: 0; }
  .topic-chain .arrow { position: static; transform: rotate(90deg); align-self: center; }
  .toc li a { padding: 6px 8px; font-size: .8rem; }
}
:lang(ar) .dc > p, :lang(th) .dc > p { font-family: var(--ui); }
.tt.breakout tbody th { width: 40%; }
.tt.breakout td:nth-child(2) { min-width: 15em; }
.tt.dojo tbody th { min-width: 14em; }
:lang(ar) .tph .upd, :lang(ar) .sn, :lang(ar) .bosslink span, :lang(ar) .lv li span, :lang(th) .tph .upd, :lang(th) .sn, :lang(th) .bosslink span, :lang(th) .lv li span { font-family: var(--ui); }
