/* Material caps the whole page grid (nav + content + TOC) at max-width:
   61rem. Widened for .timeline-layout, which keeps its own two-column
   split, and for .entity-layout (person/faction/location pages) — the
   61rem cap left .entity-text (the column .infobox floats inside) around
   750-850px wide even in a maximized/full-screen window, since floats
   can't grow past their container: the image looked permanently small no
   matter how large the browser got. Entity pages get a smaller bump than
   the timeline (76rem vs 88rem) since they're a single floated element,
   not a two-column layout competing for room — full-width prose below the
   image runs a bit wider than the site default as a result, which reads
   fine at this size. */
body:has(.timeline-layout) .md-grid {
  max-width: 88rem;
}

body:has(.entity-layout) .md-grid {
  max-width: 76rem;
}

/* Entity pages (person/faction/location): .infobox floats at the top of
   .entity-text so prose wraps around the image/table like a standard wiki
   infobox, then reverts to full width once the text runs past the image's
   bottom edge. Source order matters here — infobox.py emits the <div
   class="infobox"> as the FIRST child of .entity-text (see entity_layout in
   scripts/build_wiki.py) so the float establishes itself before any text
   needs to wrap around it; a float placed after content it's meant to wrap
   doesn't affect that earlier content. The ::after clearfix keeps
   .entity-text properly enclosing the float even if the prose is shorter
   than the image, so anything after this section doesn't overlap it. */
.entity-text::after {
  content: "";
  display: table;
  clear: both;
}

.infobox {
  float: right;
  width: 40%;
  min-width: 220px;
  max-width: 480px;
  margin: 0 0 1em 1.5em;
  padding: 0.75em;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  background: var(--md-code-bg-color);
  font-size: 0.8rem;
}

.infobox img {
  display: block;
  width: 100%;
  border-radius: 4px;
  margin-bottom: 0.6em;
  cursor: zoom-in;
}

/* Lightbox triggers are keyboard-focusable (lightbox.js adds tabindex). */
.infobox img:focus-visible,
.handout-card img:focus-visible {
  outline: 3px solid var(--md-accent-fg-color);
  outline-offset: 2px;
}

/* The card's own table (class="infobox-table" — a classed table is exempt
   from Material's `table:not([class])` styling and scroll-wrapper, so no
   border/padding overrides are needed here). */
.infobox-table {
  width: 100%;
  border-collapse: collapse;
}

.infobox-table th,
.infobox-table td {
  padding: 0.2em 0;
  vertical-align: top;
}

.infobox-table th {
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  padding-right: 0.6em;
  color: var(--md-default-fg-color--light);
}

@media screen and (max-width: 44.9375em) {
  /* Narrow screens: a floated infobox next to wrapped text gets cramped
     fast, so stack instead — image full-width above, text full-width
     below, same as the old column fallback. */
  .infobox {
    float: none;
    width: 100%;
    min-width: 0;
    max-width: none;
    margin: 0 0 1em 0;
  }
}

/* GM-only Handouts page (scripts/build_wiki.py's build_handouts_page): one
   card per handouts/ image in a responsive grid. Images are click-to-zoom
   via the same lightbox as the infobox portraits. */
.handout-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.handout-card {
  margin: 0;
  padding: 0.6em;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 6px;
  background: var(--md-code-bg-color);
}

.handout-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
  cursor: zoom-in;
}

/* Material gives bare figcaptions centered/italic/max-width styling meant
   for inline figures — reset it for the card layout. */
.md-typeset .handout-card figcaption {
  max-width: none;
  margin: 0;
  text-align: left;
  font-style: normal;
}

.md-typeset .handout-card .handout-title {
  margin-top: 0.5em;
  font-weight: 700;
}

.md-typeset .handout-card .handout-meta {
  font-size: 0.7rem;
  color: var(--md-default-fg-color--light);
}

/* Infobox portrait lightbox (javascripts/lightbox.js): clicking a
   .infobox img opens it full-size in an overlay. The overlay is a single
   shared element injected once and reused for every click, sized to 90% of
   the viewport in both dimensions (not just width) so a tall portrait can't
   overflow off-screen on a short/landscape viewport — width and height stay
   auto so the image keeps its aspect ratio inside that box. Closing on a
   click anywhere in the overlay except the image itself is what gives the
   "click outside to close" behavior; the visible × button covers the same
   case for touch users who'd otherwise have to tap precisely on the
   backdrop sliver around the image. */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  align-items: center;
  justify-content: center;
}

.lightbox-overlay.lightbox-overlay--open {
  display: flex;
}

.lightbox-overlay img {
  max-width: 90vw;
  max-height: 90vh;
  width: auto;
  height: auto;
  cursor: default;
  border-radius: 4px;
  box-shadow: 0 0 2rem rgba(0, 0, 0, 0.6);
}

.lightbox-close {
  position: fixed;
  top: 1rem;
  right: 1.5rem;
  border: none;
  background: none;
  color: #fff;
  font-size: 2.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25em;
}

.lightbox-close:hover,
.lightbox-close:focus {
  color: var(--md-accent-fg-color);
}

/* Timeline page: body content and the collapsible Year/Season/Week tree
   (scripts/build_wiki.py's build_timeline) side by side — body first in
   source order (reads fine with CSS off), tree second, which a plain flex
   row already puts on the right with no extra `order` needed. The tree
   itself uses `position: sticky` (same mechanism as Material's own
   .md-sidebar, which sticks at `top: 2.4rem`) so it stays in view while the
   much-longer body scrolls past it, instead of scrolling out of reach. */
.timeline-layout {
  display: flex;
  align-items: flex-start;
  gap: 2em;
}

.timeline-body {
  flex: 1 1 auto;
  min-width: 0;
}

.timeline-toc-wrap {
  flex: 0 0 16rem;
  position: sticky;
  top: 2.4rem;
  max-height: calc(100vh - 4.8rem);
  overflow-y: auto;
}

@media screen and (max-width: 76.1875em) {
  .timeline-layout {
    flex-direction: column;
  }

  .timeline-toc-wrap {
    flex: 1 1 auto;
    width: 100%;
    position: static;
    max-height: none;
    order: -1;
  }
}

/* Material styles every plain <details> as a blue "note" admonition box
   (background band, left accent border, note icon, shadow) — right for a
   content aside, wrong for the Timeline page's collapsible Year/Season/Week
   nav tree (scripts/build_wiki.py's _render_toc). Strip the admonition
   chrome and restyle to match Material's own left-hand nav (.md-nav /
   .md-nav__link: .7rem/1.3 line-height, plain default-fg-color text with no
   underline, accent-colored only on hover) instead of typeset prose/link
   styling — same click-to-navigate-and-toggle behavior as the primary nav's
   own collapsible sections, just via native <details> rather than Material's
   checkbox-driven one. */
.md-typeset .timeline-toc,
.md-typeset .timeline-toc details {
  background: none;
  border: none;
  box-shadow: none;
  border-radius: 0;
  margin: 0;
}

.md-typeset .timeline-toc {
  font-size: 0.7rem;
  line-height: 1.3;
}

.md-typeset .timeline-toc details {
  margin-left: 0.9rem;
}

.md-typeset .timeline-toc > details {
  margin-left: 0;
}

.md-typeset .timeline-toc summary {
  background: none;
  padding: 0.3125em 1.4rem 0.3125em 0;
  margin: 0;
  font-weight: 400;
}

.md-typeset .timeline-toc summary:before {
  display: none;
}

.md-typeset .timeline-toc summary > a,
.md-typeset .timeline-toc li > a {
  color: var(--md-default-fg-color);
  text-decoration: none;
}

.md-typeset .timeline-toc summary > a:focus,
.md-typeset .timeline-toc summary > a:hover,
.md-typeset .timeline-toc li > a:focus,
.md-typeset .timeline-toc li > a:hover {
  color: var(--md-accent-fg-color);
  text-decoration: none;
}

/* Current-scroll-position marker, set by javascripts/timeline.js — teal
   (--md-typeset-a-color, tied to the site's `primary: teal` palette) rather
   than --md-accent-fg-color above, which is indigo (mkdocs.yml never sets
   an explicit `accent:`, so Material defaults it) and is reserved for
   hover/focus, same as everywhere else in the site. */
.md-typeset .timeline-toc a.timeline-toc__active {
  color: var(--md-typeset-a-color);
  font-weight: 700;
}

.md-typeset .timeline-toc ul {
  margin: 0.3125em 0 0.3125em 0.9rem;
  padding: 0;
  list-style: none;
}

.md-typeset .timeline-toc li {
  margin: 0.3125em 0;
}

/* GM-only content reveal (javascripts/gm-reveal.js + scripts/build_wiki.py's
   gm_only()/write_gm_only_manifest()) — every element wrapped `.gm-only`
   (GM Notes sections, unseen-entity pages in full, gm-notes/* pages, real
   portraits behind a `partial` reveal) is stripped from the response
   entirely server-side (src/worker.js, HTMLRewriter) for anyone without the
   GM session — this rule only matters for an *authenticated* visitor,
   where the full markup arrives intact and needs revealing. Left-nav
   entries for GM-only pages carry the same class (tagged at build time by
   wiki/hooks/nav_hook.py) and are stripped the same way.
   Scoping the hide rule to `:not([data-gm="true"])` rather than
   `display: none` + an override back means a revealed element just falls
   through to whatever display value it would otherwise have (its own
   `.infobox`/list-item/etc. rule) instead of us having to restate it here. */
html:not([data-gm="true"]) .gm-only {
  display: none !important;
}

/* Player-visible placeholder standing in for a `partial`-reveal entity's
   real portrait (see infobox() in scripts/build_wiki.py) — hidden once GM
   view reveals the real (`.gm-only`) image in the same slot. */
html[data-gm="true"] .player-only {
  display: none !important;
}

/* Sits in the footer's flex row (.md-footer-meta__inner) alongside
   Material's own "Made with Material for MkDocs" .md-copyright — matching
   its color/size tokens rather than looking like a separate floating
   control. See gm-reveal.js for why it's appended there. */
#gm-toggle {
  margin: auto 0.6rem;
  padding: 0.4rem 0;
  border: none;
  background: none;
  font-size: 0.64rem;
  color: var(--md-footer-fg-color--lighter);
  cursor: pointer;
}

#gm-toggle::before {
  content: "· ";
}

#gm-toggle:hover {
  color: var(--md-footer-fg-color);
}

#gm-login-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}

#gm-login-form {
  background: var(--md-default-bg-color);
  border-radius: 6px;
  padding: 1.5em;
  width: 100%;
  max-width: 20rem;
  display: flex;
  flex-direction: column;
  gap: 0.9em;
}

#gm-login-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  font-size: 0.75rem;
}

#gm-login-form input {
  padding: 0.4em 0.5em;
  margin-top: 0.3em;
  border: 1px solid var(--md-default-fg-color--lightest);
  border-radius: 4px;
  background: var(--md-code-bg-color);
  color: var(--md-default-fg-color);
}

#gm-login-error {
  color: #b00020;
  font-size: 0.75rem;
}

[data-md-color-scheme="slate"] #gm-login-error {
  color: #f28b94;
}

.gm-login-actions {
  display: flex;
  gap: 0.6em;
  justify-content: flex-end;
}

.gm-login-actions button {
  padding: 0.4em 0.9em;
  border-radius: 4px;
  border: 1px solid var(--md-default-fg-color--lightest);
  background: var(--md-code-bg-color);
  color: var(--md-default-fg-color);
  cursor: pointer;
}

/* `aka:` front-matter names, rendered as a subtitle line directly under an
   entity's H1 (see aka_subtitle in scripts/build_wiki.py): h2 size, h1 shade,
   hugging the title. (The floated .infobox comes later in the source, so it
   can't wrap beside these — no clear needed.) */
.md-typeset h1:has(+ p.aka) {
  margin-bottom: 0.1em;
}

.md-typeset p.aka {
  margin: 0 0 1.2em;
  font-size: 1.5625em; /* Material's h2 size */
  font-weight: 300;
  line-height: 1.4;
  letter-spacing: -0.01em;
  font-style: italic;
  color: var(--heading-color); /* same as h1 */
}

/* Blockquotes (NPC hook quotes, oaths, dialogue). Material's default tints
   them --md-default-fg-color--light, which is dark grey on the slate
   scheme's dark-blue background. A warm sand/amber keeps them clearly
   distinct from the teal links. */
.md-typeset blockquote {
  color: #6b4c10;
  border-left-color: #b8863b;
  background: hsl(40, 45%, 94%);
  padding: 0.1rem 0.8rem;
  border-radius: 0.4rem;
}

[data-md-color-scheme="slate"] .md-typeset blockquote {
  color: #cbb48a; /* 4.5:1+ on the box's hsl(40,14%,24%) */
  border-left-color: #a67c3d;
  background: hsl(40, 14%, 24%);
}

/* GM-only aside (build_wiki.py's gm_asides(): a `GM only:` paragraph in
   gm_notes/). Tinted rose box with a "GM only" label, text a shade off
   the body tone. */
.md-typeset .gm-aside {
  margin: 1em 0;
  padding: 0.5em 0.9em 0.6em;
  border-left: 4px solid #ae4751;
  border-radius: 0.4rem;
  background: hsl(354, 40%, 96%);
  color: #7d3b41;
}

.md-typeset .gm-aside::before {
  content: "GM only";
  display: block;
  margin-bottom: 0.2em;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7d3b41;
}

.md-typeset .gm-aside > :last-child {
  margin-bottom: 0;
}

[data-md-color-scheme="slate"] .md-typeset .gm-aside {
  border-left-color: #a8575f;
  background: hsl(354, 16%, 26%);
  color: #d08a92; /* 4.5:1+ on the box; the previous #b27077 was 2.8:1 */
}

[data-md-color-scheme="slate"] .md-typeset .gm-aside::before {
  color: #d08a92;
}

/* Headings: a muted violet — distinct from the teal links, sand quotes and
   rose GM asides, and kept low-contrast so it tints rather than shouts. */
:root {
  --heading-color: #603894;
}

[data-md-color-scheme="slate"] {
  --heading-color: #b094e6; /* same violet, lifted to 4.5:1+ on slate for the small h5/h6 */
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4,
.md-typeset h5,
.md-typeset h6 {
  color: var(--heading-color);
}

/* Dark mode: body text one step darker than Material's slate default
   (alpha .82 -> .70), and the table of contents' already-read entries
   (.md-nav__link--passed, default alpha .56) one step darker to match
   (-> .44). Headings, links and the boxes above set their own colors. */
[data-md-color-scheme="slate"] {
  --md-typeset-color: hsla(var(--md-hue), 15%, 90%, 0.7);
}

[data-md-color-scheme="slate"] .md-nav__link--passed,
[data-md-color-scheme="slate"] .md-nav__link--passed code {
  color: hsla(var(--md-hue), 15%, 90%, 0.44);
}
