/* ==========================================================================
   Lyndryss WikiLore — dark wiki UI
   --------------------------------------------------------------------------
   Shares its theme tokens with the campaign map (Lyndryss-Map/css/style.css)
   so the two tools read as one product.

   State classes JS is expected to toggle:
     .is-hidden          generic hide (search results, GM panel, …)
     .section--hidden    GM omniscient view: a section players can't see yet
                         (Guide 04). Never used to hide content from players —
                         hidden text must never reach their browser at all.
   ========================================================================== */

/* ---------- Theme tokens (same values as the map) ---------- */
:root {
  --bg: #14171c;            /* page backdrop */
  --panel: #1d2128;         /* header, footer */
  --panel-raised: #262b34;  /* cards, inputs, hover rows */
  --border: #333a45;
  --text: #e3e6eb;
  --text-muted: #9aa3b0;
  --accent: #5aa9e6;        /* links, interactive highlights */
  --accent-soft: rgba(90, 169, 230, 0.18);
  --danger: #e06c5c;
  --warn: #d9a441;          /* "needs your attention", not "something broke" */
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --radius: 8px;
  --radius-sm: 5px;
  --header-h: 52px;
  --ease: 200ms ease;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Amarante", var(--font);
  --content-w: 780px;       /* comfortable reading measure */
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  /* Unlike the map, this page scrolls like a normal document. */
}

button {
  font: inherit;
  color: inherit;
}

.is-hidden {
  display: none !important;
}

/* ---------- App frame ---------- */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Wrapper only — the two words are separate links. The newline between them
   in the HTML collapses to the single space that used to be there. */
.site-title {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--text);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.site-title__home,
.site-title__accent {
  text-decoration: none;
}

.site-title__home {
  color: var(--text);
}

.site-title__accent {
  color: var(--accent);
}

.site-title__home:hover,
.site-title__accent:hover {
  text-decoration: underline;
}

.header-actions {
  position: relative; /* the GM dropdown anchors to this */
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Header search (Guide 06) ---------- */
.search-wrap {
  position: relative;
}

#search-box {
  width: 190px;
  padding: 5px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), width var(--ease);
}

#search-box:focus {
  outline: none;
  border-color: var(--accent);
  width: 240px;
}

.search-results {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-hit {
  display: block;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.search-hit:hover {
  background: var(--accent-soft);
}

/* -l search: this article never links the term anywhere — the actionable case.
   padding-left compensates for the border so titles stay aligned. */
.search-hit--needs-link {
  border-left: 3px solid var(--warn);
  padding-left: 7px;
}

.search-hit__flag {
  margin-left: 8px;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--warn);
}

.search-hit__title {
  display: block;
  font-size: 14px;
}

.search-hit__snippet {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.search-empty {
  margin: 0;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Banner shown while a search modifier like "-l" is active. */
.search-mode {
  margin: 0 0 4px;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

/* ---------- Index category groups (Guide 06) ---------- */
.index-category-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
  margin: 22px 0 10px;
  color: var(--text-muted);
}

/* ---------- Header buttons + GM login panel (Guide 04) ---------- */
.header-btn {
  padding: 5px 12px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
}

.header-btn:hover {
  border-color: var(--accent);
}

.header-btn--primary {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* JS adds this to the GM button while the GM session is active. */
.header-btn--gm {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.gm-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 240px;
  padding: 14px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.gm-panel__field {
  display: block;
  margin-bottom: 10px;
}

.gm-panel__field span {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
  color: var(--text-muted);
}

.gm-panel__field input {
  width: 100%;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.gm-panel__field input:focus {
  outline: none;
  border-color: var(--accent);
}

.gm-panel__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.gm-panel__error {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--danger);
}

/* Same slot, non-alarming: "check your email to confirm" and friends. */
.gm-panel__error.is-ok {
  color: var(--text-muted);
}

.gm-panel__status {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Player articles (Guide 07) ---------- */
.badge--private {
  color: var(--accent);
  border-color: var(--accent);
}

.article-byline {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Doubled selector so this outranks .index-heading's margin shorthand,
   which appears later in the file. */
.index-heading.index-heading--player {
  margin-top: 72px;
}

.index-link__author {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- "hidden" badges (GM omniscient view) ---------- */
.badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  padding: 1px 8px;
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 999px;
}

/* ---------- Main content column ---------- */
.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.notice {
  padding: 12px 16px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
}

.notice--error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Article typography ---------- */
.article-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.article-section {
  margin-top: 24px;
}

.section-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.article p {
  margin: 0 0 14px;
}

.article a,
.wikilink {
  color: var(--accent);
  text-decoration: none;
}

.article a:hover,
.wikilink:hover {
  text-decoration: underline;
}

/* GM omniscient view only (Guide 04): marks a section that players cannot
   see yet. Players never receive this content, so this style never reaches
   them — it exists purely so the GM can tell revealed from unrevealed. */
.section--hidden {
  opacity: 0.6;
  border-left: 3px dashed var(--danger);
  padding-left: 12px;
}

/* ---------- Article reader (Guide 03) ---------- */
.back-link {
  display: inline-block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

/* Markdown output inside a section body */
.section-body ul,
.section-body ol {
  margin: 0 0 14px;
  padding-left: 24px;
}

.section-body li {
  margin-bottom: 4px;
}

.section-body blockquote {
  margin: 0 0 14px;
  padding: 8px 14px;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--panel);
  color: var(--text-muted);
}

.section-body blockquote p:last-child {
  margin-bottom: 0;
}

.section-body code {
  padding: 1px 5px;
  font-size: 13px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.section-body hr {
  margin: 20px 0;
  border: none;
  border-top: 1px solid var(--border);
}

.section-body img {
  max-width: 100%;
  border-radius: var(--radius);
}

/* If the GM uses #/##/### headings inside a body, style them as smaller
   display headings so they sit under the real section heading. */
.section-body h1,
.section-body h2,
.section-body h3 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 18px 0 8px;
}

.section-body h1 { font-size: 20px; }
.section-body h2 { font-size: 18px; }
.section-body h3 { font-size: 16px; }

/* ---------- Home page article index (Guide 02) ---------- */
.index-heading {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 34px;
  line-height: 1.2;
  margin: 0 0 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.article-index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.index-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  transition: background var(--ease), border-color var(--ease);
}

.index-link:hover {
  background: var(--panel-raised);
  border-color: var(--accent);
}

.index-link__title {
  font-size: 16px;
}

.index-link__category {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

/* ---------- Editor (Guide 05) ---------- */
.btn {
  display: inline-block;
  padding: 5px 12px;
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--ease), color var(--ease);
}

.btn:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.btn--primary {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn--danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.index-new {
  margin-bottom: 16px;
}

.article-edit {
  margin-left: 14px;
}

/* "Show on map 🗺" link on articles that carry a location_id (Guide 09). */
.article-map-link {
  float: right;
  margin-left: 14px;
}

/* ---------- Embed mode (map integration, Guide 09) ---------- */
/* main.js adds body.embed when the page loads with ?embed=1 — the campaign
   map shows this page inside its lore side-panel iframe. Strip the site
   chrome down to the article column and blend into the map's panel color.
   Wiki-links keep working, so the panel is a tiny browsable wiki. */
body.embed {
  background: var(--panel);
}

body.embed .app-header,
body.embed .app-footer {
  display: none;
}

body.embed .content {
  max-width: none;
  padding: 14px 16px 40px;
}

body.embed .article-title {
  font-size: 26px;
}

body.embed .section-heading {
  font-size: 19px;
}

/* Already on the map — pointing back at it from inside the panel is noise. */
body.embed .article-map-link {
  display: none;
}

.editor-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 28px;
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.editor-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
  align-items: end;
  margin-bottom: 20px;
}

.ed-field {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
}

.editor input:not([type="checkbox"]),
.editor textarea {
  width: 100%;
  margin-top: 3px;
  padding: 6px 8px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.editor input:focus,
.editor textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.ed-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

.ed-section {
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ed-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.ed-section-head .ed-heading {
  flex: 1;
  margin-top: 0;
}

.ed-body {
  resize: vertical;
  line-height: 1.5;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.editor-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Footer ---------- */
.app-footer {
  padding: 14px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--panel);
  border-top: 1px solid var(--border);
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}
