/* ==========================================================================
   Lyndryss Quests — dark journal UI
   --------------------------------------------------------------------------
   Shares its theme tokens with WikiLore (Lyndryss-WikiLore/css/style.css) and
   the campaign map, so all three read as one product. The *layout* is the odd
   one out on purpose: a fixed two-pane journal (quest list | selected quest)
   in the spirit of Skyrim's quest menu, rather than a scrolling document.

   State classes JS is expected to toggle:
     .is-hidden        generic hide (GM panel, "+ New quest", …)
     .is-active        the quest currently open in the right-hand pane
     .quest--hidden    GM omniscient view: a quest players can't see yet.
                       Never used to hide content from players — hidden text
                       must never reach their browser at all.
   ========================================================================== */

/* ---------- Theme tokens (same values as WikiLore and the map) ---------- */
:root {
  --bg: #14171c;            /* page backdrop */
  --panel: #1d2128;         /* header, footer, list pane */
  --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);

  /* Journal geometry */
  --list-w: 340px;          /* left pane — pinned to the left edge */
  --read-w: 720px;          /* comfortable reading measure in the right pane */
}

/* ---------- 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);
  /* The journal owns the viewport; the two panes scroll, the page doesn't. */
  height: 100vh;
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
}

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

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

/* ---------- Header ---------- */
.app-header {
  flex: none;
  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);
  z-index: 10;
}

/* 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 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);
}

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

/* ==========================================================================
   The journal frame
   ========================================================================== */
/* Full-bleed: the list pane sits flush against the left edge of the window
   and the detail pane takes everything left over. The reading column is
   centred inside that pane by .quest / .editor, not by this grid. */
.journal {
  flex: 1;
  min-height: 0;          /* lets the panes scroll instead of the page */
  width: 100%;
  display: grid;
  grid-template-columns: var(--list-w) 1fr;
}

/* ---------- Left pane: the quest list ---------- */
.quest-list-pane {
  min-height: 0;
  overflow-y: auto;
  padding: 18px 20px 40px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.quest-filter {
  width: 100%;
  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);
}

.quest-filter:focus {
  outline: none;
  border-color: var(--accent);
}

.quest-new {
  margin-top: 10px;
}

/* One category block: MAIN QUESTS / SIDE QUESTS / COMPLETED. */
.quest-group {
  margin-top: 26px;
}

.quest-group__heading {
  margin: 0 0 8px;
  padding-bottom: 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 19px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.quest-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* A quest name in the list. The 18px left gutter holds the "you are here"
   marker, which is absolutely positioned and therefore always reserved —
   names never shift when the selection moves. The indent also sets the
   quests visibly under their category heading. */
.quest-link {
  position: relative;
  display: block;
  padding: 5px 0 5px 18px;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--ease);
}

.quest-link::before {
  content: "\25B8";        /* ▸ — points at the quest that's open */
  position: absolute;
  left: 2px;
  font-size: 12px;
  color: var(--accent);
  opacity: 0;
  transition: opacity var(--ease);
}

.quest-link:hover {
  color: var(--text);
}

.quest-link.is-active {
  color: var(--text);
}

.quest-link.is-active::before {
  opacity: 1;
}

/* Completed quests read as settled — dimmer than active ones, but still
   legible and still clickable. */
.quest-link--completed {
  color: #6f7885;
}

/* GM omniscient view only: a quest players cannot see yet. The dashed rule
   eats 2px of the marker gutter, so the name stays on the same vertical. */
.quest--hidden {
  border-left: 2px dashed var(--danger);
  padding-left: 16px;
}

.quest-list-empty {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Right pane: the open quest ---------- */
.quest-detail-pane {
  min-height: 0;
  overflow-y: auto;
  padding: 28px 32px 64px;
}

.quest {
  max-width: var(--read-w);
  margin: 0 auto;
}

/* Empty state before anything is selected. It fills the pane exactly, so it
   must not carry the default <p> margins — they'd overflow it. */
.journal-placeholder {
  display: flex;
  margin: 0;
  height: 100%;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  text-align: center;
}

/* Quest title, flanked by rules that fade out toward the edges — the
   restrained cousin of Skyrim's dragon flourishes. The title text is an
   anonymous flex item between the two pseudo-element rules, so JS only has
   to set textContent. */
.quest-title {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 30px;
  line-height: 1.25;
  letter-spacing: 0.5px;
  text-align: center;
}

.quest-title::before,
.quest-title::after {
  content: "";
  flex: 1;
  height: 1px;
  min-width: 20px;
  background: linear-gradient(to right, transparent, var(--border) 65%, var(--border));
}

.quest-title::after {
  background: linear-gradient(to left, transparent, var(--border) 65%, var(--border));
}

/* "Main Quest · Active" under the title. */
.quest-meta {
  margin: 0 0 26px;
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: center;
}

/* Row of GM controls above the title (Edit ✎, back link on mobile). */
.quest-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 22px;
}

.quest-action {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
}

.quest-action:hover {
  color: var(--accent);
}

/* A section divider inside the quest: REWARD, and anything later. Same
   flourish grammar as the title, one size down and letterspaced. */
.divider-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 30px 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 17px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.divider-heading::before,
.divider-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  min-width: 20px;
  background: var(--border);
}

/* ---------- Markdown output (Guide 03) ---------- */
/* Applied to both the description body and the reward body. */
.quest-body p {
  margin: 0 0 14px;
}

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

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

.quest-body ul,
.quest-body ol {
  margin: 0 0 14px;
  padding-left: 24px;
}

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

.quest-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);
}

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

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

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

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

/* If you use #/##/### headings inside a body, they render as smaller display
   headings that sit under the real dividers. */
.quest-body h1,
.quest-body h2,
.quest-body h3 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 18px 0 8px;
}

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

.quest-body > :last-child {
  margin-bottom: 0;
}

/* ---------- Badges ("hidden", 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;
}

/* ---------- Notices ---------- */
.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);
}

/* ---------- Buttons (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);
}

/* ---------- Editor (Guide 05) ---------- */
.editor {
  max-width: var(--read-w);
  margin: 0 auto;
}

.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(200px, 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 select,
.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 select: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-block {
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.ed-block > .ed-field {
  margin-bottom: 4px;
}

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

.ed-reward {
  min-height: 90px;
}

.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 {
  flex: none;
  padding: 10px 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;
}

/* ==========================================================================
   Narrow screens: the fixed two-pane frame stops making sense. Stack the
   panes and let the page scroll like a normal document.
   ========================================================================== */
@media (max-width: 820px) {
  body {
    height: auto;
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .app-header {
    position: sticky;
    top: 0;
  }

  .journal {
    display: block;
  }

  .quest-list-pane {
    overflow: visible;
    padding: 16px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .quest-detail-pane {
    overflow: visible;
    padding: 22px 16px 48px;
  }

  .journal-placeholder {
    height: auto;
    padding: 40px 20px;
  }

  .quest-title {
    font-size: 25px;
  }
}
