/* =============================================
   The Bloodvault — Public / Reader Styles
   ============================================= */

/* Font size scaling via data-font on <html> */
:root                { --reader-size: 1.15rem; }
[data-font="s"]      { --reader-size: 0.95rem; }
[data-font="l"]      { --reader-size: 1.35rem; }

body.public-body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--reader-size, 1.15rem);
  line-height: 1.8;
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar Nav ─── */
.public-nav {
  width: var(--nav-width);
  min-width: var(--nav-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--bg-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}

.nav-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--bg-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.nav-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 0.2rem;
}
.nav-close:hover { color: var(--text-primary); }

.site-title {
  font-family: var(--font-fraktur);
  font-size: 1.6rem;
  color: var(--accent-glow);
  text-decoration: none;
  letter-spacing: 0.02em;
  display: block;
  text-shadow: 0 0 12px rgba(139,26,26,0.4);
}
.site-title:hover { color: var(--accent-hover); }

.nav-list {
  list-style: none;
  padding: 1rem 0;
  flex: 1;
}

.nav-list li a {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  border-left: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-list li a:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-left-color: var(--accent);
}

.nav-list li.active a {
  color: var(--accent-hover);
  border-left-color: var(--accent-glow);
  background: var(--bg-raised);
  font-weight: 600;
}

.nav-empty {
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* Section headers — collapsible buttons */
.nav-section-item {
  list-style: none;
}

.nav-section-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  background: none;
  border: none;
  border-top: 1px solid var(--bg-border);
  margin-top: 0.4rem;
  padding: 0.55rem 1.1rem 0.3rem;
  color: var(--accent-light);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.nav-section-btn:hover { color: var(--accent-hover); }

.nav-section-item:first-child > .nav-section-btn {
  border-top: none;
  margin-top: 0;
}

/* Nested sections inside a sub-list get no top border, smaller label */
.nav-sub .nav-section-btn {
  border-top: none;
  margin-top: 0;
  font-size: 0.68rem;
  padding-top: 0.4rem;
  padding-bottom: 0.2rem;
  color: var(--text-muted);
}

.nav-section-btn:hover { color: var(--accent-hover); }

/* Collapse arrow */
.nav-arrow {
  display: inline-block;
  font-size: 0.6rem;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.nav-section-btn[aria-expanded="false"] .nav-arrow {
  transform: rotate(-90deg);
}

/* Nested sub-list */
.nav-sub {
  list-style: none;
  padding: 0;
  overflow: hidden;
}

.nav-sub.nav-collapsed {
  display: none;
}

/* Page links inside any depth */
.nav-page-item a {
  display: block;
  padding: 0.45rem 1.1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.nav-page-item a:hover {
  color: var(--text-primary);
  background: var(--bg-raised);
  border-left-color: var(--accent);
}

.nav-page-item.active a {
  color: var(--accent-hover);
  border-left-color: var(--accent-glow);
  background: var(--bg-raised);
  font-weight: 600;
}

.nav-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--bg-border);
}

.admin-link {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.admin-link:hover { color: var(--text-secondary); }

/* ─── Main Content ─── */
.public-content {
  margin-left: var(--nav-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.public-main {
  flex: 1;
  padding: 3rem 4rem;
  max-width: 820px;
}

/* ─── Story Article ─── */
.story-page { }

.story-title {
  font-family: var(--font-fraktur);
  font-size: 2.8rem;
  color: var(--accent-glow);
  margin-bottom: 2rem;
  text-shadow: 0 0 20px rgba(139,26,26,0.3);
  letter-spacing: 0.02em;
}

.story-content h1,
.story-content h2,
.story-content h3,
.story-content h4 {
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
  margin: 2rem 0 0.75rem;
  line-height: 1.3;
}

.story-content h1 { font-size: 2rem; }
.story-content h2 { font-size: 1.6rem; color: var(--accent-light); }
.story-content h3 { font-size: 1.25rem; }

.story-content p { margin: 0 0 1.25rem; }

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

/* WikiLinks get a subtle crimson tint to distinguish them */
.story-content a[href^="/story/"] {
  color: var(--accent-hover);
  text-decoration-color: var(--accent);
}
.story-content a[href^="/story/"]:hover {
  color: #ff9090;
}

.story-content blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.75rem 1.5rem;
  margin: 1.5rem 0;
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.story-content code {
  background: var(--bg-surface);
  padding: 0.1em 0.35em;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--accent-hover);
}

.story-content pre {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
}

.story-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.story-content hr {
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--accent-light), transparent);
  margin: 2.5rem auto;
  max-width: 60%;
  opacity: 0.7;
}

.story-content strong { font-weight: 700; color: var(--text-primary); }
.story-content em     { font-style: italic; color: var(--text-secondary); }
.story-content strong em,
.story-content em strong { font-weight: 700; font-style: italic; color: var(--text-primary); }

.story-content ul, .story-content ol {
  padding-left: 1.5rem;
  margin: 0 0 1.25rem;
}

.story-content li { margin: 0.25rem 0; }

.story-content img {
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-border);
}

.story-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.story-content th, .story-content td {
  border: 1px solid var(--bg-border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.story-content th {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── Reader controls (font size + bookmark) ─── */
.nav-reader-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--bg-border);
}

.font-controls {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.font-btn {
  background: none;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.15rem 0.4rem;
  font-family: var(--font-body);
  line-height: 1;
  transition: color 0.15s, border-color 0.15s;
}
.font-btn:nth-child(1) { font-size: 0.78rem; }
.font-btn-mid          { font-size: 0.95rem; }
.font-btn-lg           { font-size: 1.15rem; }
.font-btn:hover        { color: var(--text-primary); border-color: var(--accent); }
.font-btn-active       { color: var(--accent-hover) !important; border-color: var(--accent) !important; }

.bookmark-btn {
  background: none;
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
.bookmark-btn:hover { color: var(--accent-hover); border-color: var(--accent); }

.bm-continue-link {
  display: block;
  padding: 0.4rem 0.9rem 0.5rem;
  font-size: 0.82rem;
  color: var(--accent-hover);
  text-decoration: none;
  background: rgba(139,26,26,0.08);
  border-top: 1px solid var(--bg-border);
  border-bottom: 1px solid var(--bg-border);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bm-continue-link:hover { background: rgba(139,26,26,0.15); }

/* ─── Prev / Next navigation ─── */
.prevnext-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--bg-border);
}

.prevnext-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  max-width: 45%;
  line-height: 1.4;
  transition: color 0.15s;
}
.prevnext-link:hover { color: var(--accent-hover); }
.prevnext-prev { text-align: left; }
.prevnext-next { text-align: right; margin-left: auto; }

/* ─── Search ─── */
.nav-search {
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--bg-border);
}

.nav-search-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-raised);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  font-family: inherit;
}
.nav-search-input::placeholder { color: var(--text-muted); }
.nav-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,26,26,0.2);
}

.search-page-title { font-size: 2rem !important; }

.search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 2rem;
}

.search-input {
  flex: 1;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.6rem 0.9rem;
  font-size: 1rem;
  font-family: inherit;
}
.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,26,26,0.2);
}

.search-result {
  margin-bottom: 1.75rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--bg-border);
}
.search-result:last-child { border-bottom: none; }
.search-result h3 { margin: 0 0 0.4rem; font-size: 1.1rem; font-family: var(--font-body); }
.search-result h3 a { color: var(--accent-hover); text-decoration: none; }
.search-result h3 a:hover { color: var(--text-primary); }

.search-snippet {
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

mark {
  background: rgba(139,26,26,0.3);
  color: var(--accent-hover);
  border-radius: 2px;
  padding: 0 2px;
}

.search-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ─── 404 ─── */
.story-404 {
  text-align: center;
  padding-top: 4rem;
}
.story-404 a {
  color: var(--text-link);
}

/* ─── Comments ─── */
.comments-section {
  margin-top: 3rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--bg-border);
}

.comments-heading {
  font-size: 1.2rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--accent-light);
  margin: 0 0 1.25rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
}

.comment {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
}

.comment-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.comment-author {
  color: var(--accent-hover);
  font-weight: 600;
  font-size: 0.9rem;
}

.comment-date {
  color: var(--text-muted);
  font-size: 0.78rem;
}

.comment-body {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--bg-border);
}

.comment-form-heading {
  margin: 0;
  font-size: 1rem;
  font-family: var(--font-body);
  font-weight: 600;
  color: var(--text-primary);
}

.comment-input,
.comment-textarea {
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  width: 100%;
  box-sizing: border-box;
}

.comment-input:focus,
.comment-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(139,26,26,0.2);
}

.comment-textarea {
  min-height: 110px;
  resize: vertical;
}

.comment-flash {
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.comment-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  color: #86efac;
}

.comment-error {
  background: rgba(139,26,26,0.15);
  border: 1px solid var(--accent);
  color: var(--accent-hover);
}

/* ─── Mobile hamburger ─── */
.nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 200;
  background: var(--bg-surface);
  border: 1px solid var(--bg-border);
  color: var(--text-primary);
  font-size: 1.3rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  min-width: 44px;
  min-height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 90;
}

@media (max-width: 720px) {
  .public-nav {
    transform: translateX(-100%);
  }
  .public-nav.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
  .nav-toggle {
    display: flex;
  }
  .nav-close { display: block; }
  .nav-overlay.open { display: block; }
  .public-content {
    margin-left: 0;
  }
  .public-main {
    padding: 4.5rem 1.25rem 2rem;
    max-width: 100%;
  }
  .story-title { font-size: 1.9rem; }
  .story-content img { max-width: 100%; height: auto; }
  .story-content table { font-size: 0.85rem; }
  .story-content pre { font-size: 0.8rem; padding: 0.75rem; }

  /* Bigger tap targets for nav links on mobile */
  .nav-list li a,
  .nav-page-item a {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    font-size: 1rem;
  }
  .nav-section-btn {
    padding-top: 0.75rem;
    padding-bottom: 0.5rem;
  }
}

/* ─── Announcement Banner ─── */
.announcement-banner {
  background: var(--accent);
  color: #1a0000;
  text-align: center;
  padding: 0.65rem 3rem 0.65rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.4;
  position: relative;
  font-family: var(--font-admin, system-ui, sans-serif);
  font-weight: 500;
}
.ann-close {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  opacity: 0.75;
}
.ann-close:hover { opacity: 1; }
