/* ============================================================
   Keely Reader — Global Stylesheet
   public/styles/reader.css
   ============================================================ */

/* ------------------------------------------------------------
   Design tokens — override these to theme a Keely instance
   ------------------------------------------------------------ */
:root {
  /* Colors */
  --color-bg: #f8f6f2;
  --color-text: #1a1a1a;
  --color-text-muted: #6b6b6b;
  --color-link: #4a3f8f;
  --color-link-hover: #2d2660;
  --color-border: #cccccc;
  --color-header-bg: #1a1a2e;
  --color-header-text: #ffffff;
  --color-wiki-bg: #f5f5f5;
  --color-wiki-strip: #4a3f8f;

  /* Typography */
  --font-prose: Georgia, 'Times New Roman', serif;
  --font-ui: system-ui, -apple-system, sans-serif;
  --font-size-base: 1.1rem;
  --line-height-prose: 1.75;

  /* Layout */
  --header-height: 48px;
  --wiki-pane-width: 380px;
  --wiki-pane-collapsed-width: 12px;
  --prose-pane-padding: 2rem;
  --prose-max-width: 75ch;

  /* story blocks */
  --color-warning-bg: #fff8e1;
  --color-warning-border: #f0c040;
  --color-block-bg: #f5f5f5;
  --color-block-border: #cccccc;
  --color-credits-bg: #e8f0fe;
  --color-credits-border: #4a7fc1;
  --color-acknowledgments-bg: #e8f4fd;
  --color-acknowledgments-border: #5ba3c9;
}

/* ------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-prose);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-bg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.site-layout {
  overflow: auto;
  height: auto;
}

/* Every block below the header takes the page's full width. In the body's
   column, a block centred with `margin: 0 auto` would otherwise shrink to
   its contents: a Projects page without taglines fell to one card per row,
   and index pages sat wherever their width put them. Their own
   max-width still sets how wide they read. */
body.site-layout > * {
  width: 100%;
}

/* ------------------------------------------------------------
   Site header
   ------------------------------------------------------------ */
#site-header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: var(--color-header-bg);
  color: var(--color-header-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  font-family: var(--font-ui);
  z-index: 10;
}

/* The breadcrumbs (D-177) and the logo side share the room either side of
   the Navigation and Wiki buttons, which stay centred; a long trail
   shortens its titles rather than pushing them aside. */
#header-left {
  flex: 1 1 0;
  min-width: 0;
  padding-right: 1rem;
}

#header-center {
  flex: none;
}

.crumbs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  min-width: 0;
}

/* When the trail runs out of room, the far crumbs give way first, down to
   a few letters, so the nearest (where a reader most often goes back to)
   stay readable. */
.crumbs li {
  display: flex;
  align-items: center;
  flex: 0 6 auto;
  min-width: 3.5em;
}

.crumbs li:nth-last-child(2) {
  flex-shrink: 1;
}

.crumbs li:last-child {
  flex-shrink: 0;
  min-width: 0;
}

.crumbs li + li::before {
  content: '›';
  margin: 0 0.5em;
  opacity: 0.7;
}

.crumbs a {
  display: block;
  max-width: 14em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The logo (or name) and the ⚙ button sit side by side. */
#header-right {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* The publisher's logo: header height, its width following the logo's shape. */
img#header-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}

#site-header a {
  color: var(--color-header-text);
  text-decoration: none;
}

#site-header a:hover {
  text-decoration: underline;
}

#nav-toggle {
  background: transparent;
  border: 1px solid var(--color-header-text);
  color: var(--color-header-text);
  font-family: var(--font-ui);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  border-radius: 3px;
}

#nav-toggle:hover {
  background: rgba(255,255,255,0.1);
}

#wiki-header-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--color-header-text);
  color: var(--color-header-text);
  font-family: var(--font-ui);
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  border-radius: 3px;
}

#wiki-header-btn:hover {
  background: rgba(255,255,255,0.1);
}

/* ------------------------------------------------------------
   Reader preferences modal
   ------------------------------------------------------------ */

#reader-prefs-btn {
  background: transparent;
  border: none;
  color: var(--color-header-text);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  margin-left: 0.75rem;
  border-radius: 3px;
  line-height: 1;
}

#reader-prefs-btn:hover {
  background: rgba(255,255,255,0.1);
}

#reader-prefs-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: transparent;
}

#reader-prefs-panel {
  position: absolute;
  top: calc(var(--header-height) + 0.5rem);
  right: 1.5rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 1.25rem 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  min-width: 240px;
  z-index: 201;
}

#reader-prefs-panel h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

#reader-prefs-panel label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  cursor: pointer;
  color: var(--color-text);
}

#reader-prefs-panel label:last-of-type {
  margin-bottom: 1rem;
}

#reader-prefs-close {
  display: block;
  width: 100%;
  padding: 0.4rem;
  background: var(--color-header-bg);
  color: white;
  border: none;
  border-radius: 3px;
  font-family: var(--font-ui);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

#reader-prefs-close:hover {
  opacity: 0.85;
}

/* ------------------------------------------------------------
   Pane row
   ------------------------------------------------------------ */
#pane-row {
  display: flex;
  flex-direction: row;
  flex: 1;
  overflow: hidden;
}

/* ------------------------------------------------------------
   Prose pane
   ------------------------------------------------------------ */
#prose-pane {
  flex: 1;
  overflow-y: auto;
  padding: var(--prose-pane-padding);
}

#prose-pane > * {
  max-width: var(--prose-max-width);
  margin-left: auto;
  margin-right: auto;
}

#prose-pane a {
  color: var(--color-link);
}

#prose-pane a:hover {
  color: var(--color-link-hover);
}

/* A "not yet" link: names something the author hasn't created a page for
   (D-156). Reads as a link to come, not a broken one; clicking does
   nothing. */
#prose-pane a.unresolved,
#prose-pane a.unresolved:hover {
  color: var(--color-link);
  opacity: 0.7;
  text-decoration: underline dashed;
  cursor: help;
}

/* A link to another website (D-164): opens in a new tab, and the ↗ says
   so before the reader clicks. */
a[rel~="external"]::after {
  content: "\00a0↗";
  font-size: 0.8em;
  text-decoration: none;
  display: inline-block;
}

/* Above a page from another project in the wiki pane (D-164). */
.wiki-from {
  font-size: 0.8em;
  opacity: 0.75;
  margin: 0 0 0.75rem;
}

/* ------------------------------------------------------------
   Projects Index page
   ------------------------------------------------------------ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.project-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.project-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.project-card-cover {
  width: 100%;
  height: auto;
  display: block;
}

.project-card-cover-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--color-wiki-bg);
}

.project-card-meta {
  padding: 0.75rem;
}

.project-card-meta h2 {
  font-size: 1rem;
  margin: 0 0 0.25rem 0;
}

.project-card-tagline {
  font-size: 0.85rem;
  color: var(--color-text-muted, #666);
  margin: 0;
}

.project-card-tags {
  margin-top: 0.5rem;
}

.project-card-tags .meta-genre,
.project-card-tags .meta-rating {
  font-size: 0.5rem;
  padding: 0.2rem 0.5rem;
}

/* ------------------------------------------------------------
   Scene page
   ------------------------------------------------------------ */
.scene-meta {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  background: var(--color-wiki-bg);
  border-left: 4px solid var(--color-wiki-strip);
  padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}

.scene-meta p {
  margin: 0.3rem 0;
  line-height: 1.4;
}

.scene-prose hr,
hr {
  margin-bottom: 1.5rem;
}

#prose-pane .scene-prose p {
  margin-bottom: 1.1em;
  line-height: 1.5;
}

#prose-pane .scene-prose ul,
#prose-pane .scene-prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1.1em;
}

#prose-pane .scene-prose li {
  margin-bottom: 0.4em;
  line-height: 1.5;
}

/* Letters, signs, remembered speech. */
.scene-prose blockquote,
.entity-prose blockquote {
  margin: 0 0 1.1em;
  padding-left: 1em;
  border-left: 3px solid var(--color-border);
  color: #555555;
}

.scene-prose blockquote p:last-child,
.entity-prose blockquote p:last-child {
  margin-bottom: 0;
}

.scene-filter {
  margin-top: 0.75rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.scene-filter select {
  margin-left: 0.5rem;
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.scene-inline-image {
  max-width: 50%;
  height: auto;
  display: block;
  margin: 1.5rem auto;
}

.scene-authors-note {
  background: var(--color-credits-bg);
  border-left: 4px solid var(--color-credits-border);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}


/* ------------------------------------------------------------
   Wiki pane
   ------------------------------------------------------------ */
#wiki-pane {
  width: var(--wiki-pane-width);
  min-width: var(--wiki-pane-width);
  background: var(--color-wiki-bg);
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width 0.25s ease, min-width 0.25s ease, padding 0.25s ease;
}

/* Collapsed state */
#wiki-pane.collapsed {
  width: var(--wiki-pane-collapsed-width);
  min-width: var(--wiki-pane-collapsed-width);
  padding: 0;
  overflow: hidden;
  background: var(--color-wiki-strip);
  cursor: pointer;
}

#wiki-pane.collapsed .wiki-pane-inner {
  display: none;
}

/* Toggle tab */
#wiki-toggle {
  position: relative;
  align-self: center;
  width: 16px;
  height: 48px;
  background: var(--color-wiki-strip);
  border: none;
  border-radius: 4px 0 0 4px;
  cursor: pointer;
  color: white;
  font-size: 0.6rem;
  z-index: 5;
  flex-shrink: 0;
}

/* ------------------------------------------------------------
   Wiki pane contents
   ------------------------------------------------------------ */
#wiki-pane a {
  color: var(--color-link);
}

#wiki-pane a:hover {
  color: var(--color-link-hover);
}

#wiki-nav-controls {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  font-family: var(--font-ui);
}

.wiki-pane-index-link {
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-family: var(--font-ui);
  font-size: 0.85rem;
}

.wiki-pane-index-link a {
  color: var(--color-link);
  text-decoration: none;
}

.wiki-pane-index-link a:hover {
  text-decoration: underline;
}

.entity-tags ul {
  padding-left: 1.25rem;
}

#scene-info p {
  margin-bottom: 0.6rem;
}


/* ------------------------------------------------------------
   Story landing page
   ------------------------------------------------------------ */

.story-banner img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
}

.story-landing {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-prose);
}

.story-back {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.story-back a {
  color: var(--color-link);
  text-decoration: none;
}

.story-back a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

.story-block {
  border-left: 4px solid var(--color-block-border);
  background: var(--color-block-bg);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.story-block h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.story-block--warnings {
  background: var(--color-warning-bg);
  border-left-color: var(--color-warning-border);
}

.story-landing h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.story-tagline {
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.story-summary {
  line-height: var(--line-height-prose);
  margin-bottom: 1.5rem;
}

.story-author-note {
  color: #555;
  font-style: italic;
  line-height: var(--line-height-prose);
  margin-bottom: 1.5rem;
}

.story-start {
  display: inline-block;
  margin: 1.5rem 0;
  padding: 0.75rem 2rem;
  background: var(--color-header-bg);
  color: white;
  text-decoration: none;
  font-family: var(--font-ui);
  font-size: 1.1rem;
  border-radius: 3px;
}

.story-start:hover {
  opacity: 0.85;
}

/* Since D-170 the story page sits in the reading pane, whose link colour
   would otherwise win over the button's white: purple on near-black. */
#prose-pane a.story-start,
#prose-pane a.story-start:visited,
#prose-pane a.story-start:hover {
  color: white;
}

.story-block {
  margin-bottom: 1.5rem;
}

.story-block--credits {
  background: var(--color-credits-bg);
  border-left-color: var(--color-credits-border);
}

.story-block--acknowledgments {
  background: var(--color-acknowledgments-bg);
  border-left-color: var(--color-acknowledgments-border);
}


#entity-content .entity-portrait img {
  width: 40%;
  max-width: 150px;
  height: auto;
  float: right;
  margin: 0 0 1rem 1rem;
}

.entity-portrait img {
  max-width: 300px;
  width: 100%;
  height: auto;
}

.story-meta-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-family: var(--font-ui);
}

.story-status {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
}

.story-status span {
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.meta-genre {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #2d6a4f;
  color: white;
  font-size: 0.85rem;
  border-radius: 3px;
  font-weight: 600;
}

.meta-subgenre {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: #d8f3dc;
  border: 1px solid #95d5b2;
  color: #1b4332;
  font-size: 0.85rem;
  border-radius: 3px;
}

/* An arc's or chapter's page reads as a cover page (D-170, amended
   2026-11-06): set lower, its heading centred like a book's part page.
   A summary stays left-aligned in a narrower column, to read easily. */
.part-page {
  padding-top: 12vh;
  max-width: 34em;
  margin: 0 auto;
}

.part-kicker,
.part-page h1,
.part-page .story-meta-tags,
.part-begin {
  text-align: center;
  justify-content: center;
}

.part-kicker {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: #6b6b6b;
  margin-bottom: 0.75rem;
}

.part-kicker a {
  color: inherit;
}

.part-sep {
  margin: 0 0.5em;
}

/* Each piece of the line stays whole when it wraps on a phone. */
.part-bit {
  white-space: nowrap;
}

.part-page h1 {
  font-size: 2.4rem;
  margin: 0 0 1.5rem;
}

.part-begin {
  font-family: var(--font-ui);
  font-size: 1.1rem;
  margin: 2.5rem 0 3rem;
}

.meta-rating {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--color-wiki-strip);
  color: white;
  font-size: 0.85rem;
  border-radius: 3px;
  font-weight: 600;
}

/* ------------------------------------------------------------
   Project landing page
   ------------------------------------------------------------ */

.project-banner img {
  width: 100%;
  height: auto;
  max-height: 400px;
  object-fit: cover;
}

.project-cover img {
  max-width: 300px;
  width: 100%;
  height: auto;
}

.project-landing {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-prose);
}

.project-tagline {
  font-size: 1.2rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.project-summary {
  line-height: var(--line-height-prose);
  margin-bottom: 1.5rem;
}

.project-author {
  font-size: 0.9rem;
  color: #777;
  margin-bottom: 1.5rem;
}

.project-author a {
  color: var(--color-link);
}

.project-author a:hover {
  color: var(--color-link-hover);
}

.project-author-note {
  color: #555;
  font-style: italic;
  line-height: var(--line-height-prose);
  margin-bottom: 1.5rem;
}

.project-stories {
  margin-top: 2rem;
}

.project-stories h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  font-family: var(--font-ui);
}

.project-stories a {
  color: var(--color-link);
}

.project-stories a:hover {
  color: var(--color-link-hover);
}

/* The wiki card ends the project page: quiet, but plainly the last thing
   on it, and a way into the wiki. */
.project-wiki-card {
  display: block;
  margin: 3rem 0 4rem;
  padding: 1.1rem 1.4rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.025);
  text-decoration: none;
  font-family: var(--font-ui);
  transition: border-color 0.15s, background 0.15s;
}

.project-wiki-card:hover {
  border-color: var(--color-link);
  background: rgba(74, 63, 143, 0.05);
}

.project-wiki-card-title {
  display: block;
  color: var(--color-link);
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.project-wiki-card-holds {
  display: block;
  color: #6b6b6b;
  font-size: 0.85rem;
}

/* ------------------------------------------------------------
   Publisher landing page
   ------------------------------------------------------------ */

.publisher-landing {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-prose);
}

.publisher-landing h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.publisher-tagline {
  font-size: 1.5rem;
  color: #555;
  margin-bottom: 1.5rem;
}

.publisher-blurb {
  line-height: var(--line-height-prose);
  margin-bottom: 2rem;
}

.publisher-blurb p {
  margin-bottom: 1em;
}

.publisher-nav {
  display: flex;
  gap: 1.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.publisher-nav-card {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-width: 160px;
  padding: 1.5rem 2rem;
  background: var(--color-wiki-bg);
  border: 2px solid var(--color-border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
  font-family: var(--font-ui);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.publisher-nav-card:hover {
  border-color: var(--color-link);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  color: var(--color-link);
}

/* ------------------------------------------------------------
   About page
   ------------------------------------------------------------ */

.about-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-prose);
}

.about-page h1 {
  font-size: 2.5rem;
  margin-bottom: 2rem;
}

.about-author {
  margin-bottom: 3rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--color-border);
}

.about-author:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.about-author h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
}

.about-portrait {
  float: right;
  margin: 0 0 1.5rem 2rem;
}

.about-portrait img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.about-bio {
  line-height: var(--line-height-prose);
  margin-bottom: 1.5rem;
}

.about-bio p {
  margin-bottom: 1em;
}

.about-links {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  clear: both;
}

.about-links li {
  display: inline-block;
  margin-right: 0.75rem;
  margin-top: 0.5rem;
}

.about-links a {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--color-link);
  border-radius: 3px;
  color: var(--color-link);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.about-links a:hover {
  background: var(--color-link);
  color: white;
}

/* ------------------------------------------------------------
   Wiki index page
   ------------------------------------------------------------ */

.wiki-index {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-ui);
}

.wiki-index h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-family: var(--font-prose);
}

.wiki-index-section {
  margin-bottom: 2rem;
}

.wiki-index-section h2 {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--color-border);
}

.wiki-index-section h2 a {
  color: var(--color-text);
  text-decoration: none;
}

.wiki-index-section h2 a:hover {
  color: var(--color-link);
}

.wiki-index-list {
  list-style: none;
  padding: 0;
}

.wiki-index-list li {
  padding: 0.25rem 0;
}

.wiki-index-list a {
  color: var(--color-link);
  text-decoration: none;
}

.wiki-index-list a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* ------------------------------------------------------------
   Wiki pages
   ------------------------------------------------------------ */

.entity-prose {
  line-height: var(--line-height-prose);
}

.entity-prose p {
  margin-bottom: 1em;
}

.entity-prose ul,
.entity-prose ol {
  padding-left: 1.5rem;
  margin-bottom: 1em;
}

.entity-prose li {
  margin-bottom: 0.25em;
}

.entity-prose h2,
.entity-prose h3,
.entity-prose h4 {
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

.spoiler-section {
  border-left: 4px solid var(--color-warning-border);
  background: var(--color-warning-bg);
  padding: 1rem 1.5rem;
  margin-top: 1.5em;
  font-family: var(--font-ui);
  font-size: 0.95rem;
}

.spoiler-section summary {
  cursor: pointer;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: bold;
}

.spoiler-section[open] summary {
  margin-bottom: 0.75rem;
}

/* ------------------------------------------------------------
   Tags index page
   ------------------------------------------------------------ */
.tags-index {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-ui);
}

.tags-index h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-family: var(--font-prose);
}

.tags-list {
  list-style: none;
  padding: 0;
}

.tags-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
}

.tags-list li:last-child {
  border-bottom: none;
}

.tags-list a {
  color: var(--color-link);
  text-decoration: none;
  font-size: 1.05rem;
}

.tags-list a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* ------------------------------------------------------------
   Individual tag page
   ------------------------------------------------------------ */
.tag-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-ui);
}

.tag-page h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-family: var(--font-prose);
}

.tag-section {
  margin-bottom: 2rem;
}

.tag-section h2 {
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid var(--color-border);
}

.tag-section ul {
  list-style: none;
  padding: 0;
}

.tag-section li {
  padding: 0.3rem 0;
}

.tag-section a {
  color: var(--color-link);
  text-decoration: none;
}

.tag-section a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

/* ------------------------------------------------------------
   Projects index page
   ------------------------------------------------------------ */

.projects-index {
  max-width: 720px;
  margin: 0 auto;
  padding: 3rem 2rem;
  font-family: var(--font-ui);
}

.projects-index h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  font-family: var(--font-prose);
}

.projects-list {
  list-style: none;
  padding: 0;
}

.projects-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
}

.projects-list a {
  color: var(--color-link);
  text-decoration: none;
  font-size: 1.1rem;
}

.projects-list a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
}

.projects-tagline {
  color: #555;
  font-size: 0.95rem;
}

/* Entity index pages */
.entity-index {
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.entity-index h1 {
  margin-bottom: 1.5rem;
}

.entity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.entity-card {
  display: block;
  padding: 1rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 4px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.entity-card:hover {
  border-color: var(--color-link);
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.entity-card-name {
  font-weight: 600;
  color: var(--color-link);
}

.entity-card-sub {
  font-size: 0.85rem;
  color: var(--color-text-muted, #666);
  margin-top: 0.25rem;
}

/* Entity pages */
.entity-page {
  max-width: 700px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.entity-meta {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-surface, #f9f9f9);
  border-radius: 4px;
  border: 1px solid var(--color-border, #ddd);
}

.entity-meta p {
  margin: 0.4rem 0;
}

.entity-prose {
  margin: 1.5rem 0;
}

.entity-appearances {
  margin: 1.5rem 0;
}

.entity-appearances h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.entity-appearances ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.entity-appearances li {
  margin: 0.3rem 0;
}

/* Grouped by story (D-171): each story's scenes fold under it. */
.scene-groups summary {
  cursor: pointer;
}

.scene-groups details ul {
  margin: 0.3rem 0 0.6rem 1.25rem;
}

.scene-group-count {
  color: var(--color-text-muted);
  font-size: 0.9em;
}

/* ------------------------------------------------------------
   Mobile drawer (max 768px)
   ------------------------------------------------------------ */

/* Hide the header wiki button on desktop */

#wiki-header-btn {
  display: none;
}

@media (max-width: 768px) {
  /* Breadcrumbs: only the nearest, as a back link (D-177). */
  .crumbs li:not(:last-child) {
    display: none;
  }

  .crumbs li:last-child {
    flex-shrink: 1;
  }

  .crumbs li:last-child::before {
    content: '←';
    margin: 0 0.35em 0 0;
    opacity: 1;
  }

  /* Hide the collapse tab - replaced by header button on mobile */
  #wiki-toggle {
    display: none;
  }

  #wiki-header-btn {
    display: inline-block;
  }

  /* Wiki pane becomes a fixed overlay drawer */
  #wiki-pane {
    position: fixed;
    top: var(--header-height);
    right: 0;
    width: 85vw;
    max-width: var(--wiki-pane-width);
    height: calc(100vh - var(--header-height));
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    min-width: unset;
  }

  /* Open state */
  #wiki-pane.drawer-open {
    transform: translateX(0);
  }

  /* Backdrop */
  #wiki-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
  }

  #wiki-backdrop.active {
    display: block;
  }
}
/* ------------------------------------------------------------
   Adult-content notice (D-173): covers a Mature or Explicit
   story's pages until the reader chooses Continue.
   ------------------------------------------------------------ */
#adult-notice {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--color-bg);
  font-family: var(--font-ui);
}

#adult-notice .adult-notice-box {
  max-width: 28rem;
  text-align: center;
}

#adult-notice h2 {
  margin-bottom: 0.5rem;
}

#adult-notice .adult-notice-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 1.5rem;
}

#adult-notice button {
  background: var(--color-header-bg);
  color: var(--color-header-text);
  border: none;
  border-radius: 4px;
  padding: 0.6rem 1.4rem;
  font: inherit;
  cursor: pointer;
}
