/* nwn-wiki — base stylesheet for generated module wikis. */

:root {
  --fg: #1f1f1f;
  --bg: #fafaf6;
  --muted: #6b6b6b;
  --accent: #6b3a1c;
  --accent-soft: #c8a577;
  --border: #d6d2c4;
  --card: #fff;
  --hostile: #a13a2c;
  --friendly: #2d6a3a;
  --link: #5a3210;
  --link-hover: #a05a1c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.5;
}

body { padding: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

header.site, header.site-header {
  background: var(--accent);
  color: #fff;
  padding: 0.75em 1.5em;
  border-bottom: 4px solid var(--accent-soft);
}
header.site a, header.site-header a { color: #fff; }
header.site-header .brand {
  font-size: 1.3em;
  margin-right: 1.5em;
}
header.site h1 {
  margin: 0;
  font-size: 1.4em;
  font-weight: normal;
  letter-spacing: 0.02em;
}
header.site nav, header.site-header nav {
  display: inline;
  font-size: 0.95em;
}
header.site nav a, header.site-header nav a { margin-right: 1.2em; }

dl.meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2em 1.2em;
  margin: 0.5em 0 1em;
}
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; }

table.data {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0 1em;
  background: var(--card);
}
.map-hint { color: var(--muted); font-size: 0.9em; margin-bottom: 0.3em; }
.map-hint .legend.trigger::before,
.map-hint .legend.door::before {
  content: "—"; display: inline-block; margin-right: 0.25em;
}
.map-hint .legend.trigger { color: #6b3a1c; }
.map-hint .legend.door    { color: #2d6a3a; }
.map-hint .legend.convo   { color: #9b4dca; }
.map-hint .legend.pseudo  { color: #9b4dca; font-size: 1.1em; }
footer { text-align: center; color: var(--muted); font-size: 0.85em; padding: 1.5em 0 2em; }
.muted { color: var(--muted); font-size: 0.85em; }

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5em;
}

h1, h2, h3 {
  font-family: "Iowan Old Style", Georgia, serif;
  color: var(--accent);
  font-weight: normal;
}
h1 { font-size: 1.8em; margin-top: 0; }
h2 {
  font-size: 1.3em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.2em;
  margin-top: 1.6em;
}
h3 { font-size: 1.1em; margin-top: 1.2em; }

.muted { color: var(--muted); }
.tag {
  display: inline-block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.85em;
  background: rgba(0,0,0,0.05);
  padding: 0.05em 0.4em;
  border-radius: 3px;
}

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.2em 1em;
  margin: 0.5em 0 1em;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5em 0 1em;
  background: var(--card);
}
th, td {
  text-align: left;
  padding: 0.4em 0.6em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: rgba(107, 58, 28, 0.08);
  font-weight: normal;
  color: var(--accent);
}
tr:hover td { background: rgba(0,0,0,0.02); }

.hostile  { color: var(--hostile);  }
.friendly { color: var(--friendly); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 1em 1.2em;
  margin: 0.8em 0;
  border-radius: 4px;
}

footer.site {
  text-align: center;
  color: var(--muted);
  font-size: 0.85em;
  padding: 1.5em 0 2em;
}

/* The giant area map. Breaks out of the centred main column so it can use
 * almost the full viewport, since labels become unreadable when hundreds of
 * areas are crammed into 1100 px. The SVG inside renders at its native
 * pixel size (set by width/height attributes) so browser zoom enlarges the
 * map proportionally with the rest of the page; the wrap scrolls when the
 * map is wider than the viewport. */
.map-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin: 1em 0;
  width: 1000px;
  max-width: 100%;
  height: 1000px;
  overflow: auto;
}
.map-wrap svg { display: block; }
.map-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0.4em 0 0.2em;
  width: 1000px;
  max-width: 100%;
}
.map-toolbar button {
  font: inherit;
  padding: 0.3em 0.8em;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}
.map-toolbar button:hover { background: var(--accent-soft); }
.map-legend {
  font-size: 0.85em;
  color: var(--muted);
  padding: 0.5em 1em;
  border-top: 1px solid var(--border);
}
.map-legend .swatch {
  display: inline-block;
  width: 0.9em;
  height: 0.4em;
  vertical-align: middle;
  margin-right: 0.3em;
}

/* SVG node defaults (overridable inline) */
svg .area-node rect {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2.4;
}
svg .area-node:hover rect {
  fill: var(--accent-soft);
}
svg .area-node text {
  fill: var(--fg);
  pointer-events: none;
  font-family: "Iowan Old Style", Georgia, serif;
}
svg .edge-trigger { stroke: #6b3a1c; stroke-width: 2.5; opacity: 0.55; fill: none; }
svg .edge-door    { stroke: #2d6a3a; stroke-width: 2.5; opacity: 0.55; fill: none; }
svg .edge-convo   {
  stroke: #9b4dca; stroke-width: 2.5; opacity: 0.7; fill: none;
  stroke-dasharray: 6, 4;
}
/* Invisible thicker hit-area paired with each visible edge so the SVG
 * <title> tooltip fires on a generous hover target instead of needing the
 * user to land on a near-pixel-thin line. */
svg .edge-hit {
  stroke: transparent;
  stroke-width: 30;
  fill: none;
  pointer-events: stroke;
  cursor: help;
}
svg .external-node rect { fill: #ddd; stroke: #999; stroke-dasharray: 3,3; }

svg .convo-node polygon {
  fill: #f3e8ff;
  stroke: #9b4dca;
  stroke-width: 2.4;
}
svg .convo-node:hover polygon { fill: #e3c9ff; }
svg .convo-node text {
  fill: #5a2b78;
  pointer-events: none;
  font-family: "Iowan Old Style", Georgia, serif;
}

/* Conversations index + per-dialog page styling. Goal: scannable
 * outline, with NPC entries and PC replies visually distinct so a
 * branching tree is readable as a flat list. */
.badge {
  display: inline-block;
  padding: 0.05em 0.45em;
  border-radius: 3px;
  font-size: 0.75em;
  font-family: "SFMono-Regular", Consolas, monospace;
  vertical-align: middle;
}
.badge.global   { background: #f3e8ff; color: #5a2b78; }
.badge.teleport { background: #fff0c2; color: #6b4a00; }

.dlg-callers { margin: 0.5em 0 1em; padding-left: 1.2em; }
.dlg-callers li { margin-bottom: 0.25em; }

.dlg-node {
  margin: 0.4em 0;
  padding: 0.5em 0.75em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
}
.dlg-node.entry {
  border-left: 4px solid var(--accent);
}
.dlg-node.reply {
  border-left: 4px solid #2d6a3a;
  margin-left: 1.5em;
  background: #f7faf6;
}
.dlg-head {
  font-size: 0.85em;
  color: var(--muted);
  margin-bottom: 0.3em;
}
.dlg-id { font-family: "SFMono-Regular", Consolas, monospace; }
.dlg-speaker { color: var(--accent); }
.dlg-action  { color: #5a2b78; }
.dlg-text { white-space: pre-wrap; }
.dlg-links {
  font-size: 0.85em;
  margin: 0.4em 0 0;
  padding-left: 1.2em;
  color: var(--muted);
  list-style: "↳ ";
}
.dlg-links li { margin: 0.1em 0; }
.dlg-links a { color: var(--link); }
.dlg-link-preview {
  color: var(--text);
  font-style: italic;
}

/* Conversation-flow tree (nested <details> view) */
.dlg-tree { margin: 0.5em 0 1.5em; }
.dlg-tree-node {
  margin: 0.4em 0;
  padding: 0.4em 0.6em 0.4em 0.7em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
}
.dlg-tree-node.entry { border-left: 4px solid var(--accent); }
.dlg-tree-node.reply {
  border-left: 4px solid #2d6a3a;
  background: #f7faf6;
}
.dlg-tree-node > summary {
  font-size: 0.9em;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  margin-bottom: 0.25em;
}
.dlg-tree-node > summary::-webkit-details-marker { display: none; }
.dlg-tree-node > summary::before {
  content: "▾ ";
  display: inline-block;
  width: 1em;
  color: var(--muted);
}
.dlg-tree-node:not([open]) > summary::before { content: "▸ "; }
.dlg-tree-node > .dlg-text { white-space: pre-wrap; }
.dlg-tree-children {
  margin-top: 0.4em;
  margin-left: 1.2em;
  border-left: 1px dotted var(--border);
  padding-left: 0.8em;
}
.dlg-tree-ref {
  font-size: 0.9em;
  color: var(--muted);
  margin: 0.3em 0;
  padding: 0.15em 0.5em;
  border-left: 2px dashed var(--border);
}
.dlg-tree-ref a { color: var(--link); }
.dlg-tree-broken {
  font-size: 0.85em;
  color: #b54708;
  margin: 0.3em 0;
}
.dlg-anchor {
  text-decoration: none;
  color: var(--muted);
  opacity: 0.5;
  margin-left: 0.4em;
}
.dlg-anchor:hover { opacity: 1; }
.featlist {
  column-count: 2;
  column-gap: 1.5em;
  padding-left: 1.5em;
}
.featlist li { break-inside: avoid; }

.dlg-node:target {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

/* NWN canonical damage / effect text colours.
 * Source: https://nwn.wiki/spaces/NWN1/pages/38177018/Colour+Tokens
 * The hex colours come through inline so the page works without this
 * stylesheet; the rules here just make the lighter NWN palette legible
 * on the wiki's light page background. */
.nwn-dmg {
  font-weight: 600;
  text-shadow:
     0 0 1px rgba(0, 0, 0, 0.55),
     0 0 2px rgba(0, 0, 0, 0.35);
}
/* Positive damage is white in-game; on a light page it needs a real outline. */
.nwn-dmg-positive {
  text-shadow:
    -1px 0 0 #444,  1px 0 0 #444,
     0 -1px 0 #444, 0  1px 0 #444;
}
