/* ===============================
   OPEN STORIES — READING NAVIGATION
   (bar, chapter menu, resume prompt, page buttons)
   =============================== */

.open-story-page {
  --rn-bg: rgba(28, 25, 22, 0.94);
  --rn-ink: #e6e1d9;
  --rn-ink-soft: #cbbca8;
  --rn-line: rgba(203, 188, 168, 0.25);
  --rn-accent: #cbbca8;
}

.open-story-page.reading-mode {
  --rn-bg: rgba(253, 253, 249, 0.96);
  --rn-ink: #1a1a1a;
  --rn-ink-soft: #555;
  --rn-line: rgba(0, 0, 0, 0.15);
  --rn-accent: #8a7456;
}

/* Keep jumped-to chapters clear of the bar */
.story-body > * {
  scroll-margin-top: 4rem;
}

/* ---------- 1. Where-am-I bar ---------- */

.rn-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1500;
  background: var(--rn-bg);
  color: var(--rn-ink);
  border-bottom: 1px solid var(--rn-line);
  font-family: Georgia, "Times New Roman", serif;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
}

.rn-bar.visible {
  transform: translateY(0);
}

.rn-bar[hidden] {
  display: none;
}

.rn-bar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.55rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rn-where {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  font-size: 0.92rem;
  color: var(--rn-ink-soft);
  white-space: nowrap;
}

.rn-where .rn-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.rn-where .rn-count {
  flex: none;
  opacity: 0.75;
  margin-left: 0.6em;
}

.rn-chapters-btn {
  flex: none;
  background: none;
  border: 1px solid var(--rn-line);
  color: var(--rn-ink);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.rn-chapters-btn:hover,
.rn-chapters-btn[aria-expanded="true"] {
  border-color: var(--rn-accent);
}

.rn-progress {
  height: 2px;
  background: transparent;
}

.rn-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--rn-accent);
  opacity: 0.8;
}

/* ---------- 2. Chapter menu ---------- */

.rn-menu {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.25rem 1.5rem 1rem;
  max-height: 70vh;
  overflow-y: auto;
}

.rn-menu[hidden] {
  display: none;
}

.rn-menu ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rn-menu a {
  display: block;
  padding: 0.5rem 0;
  border-top: 1px solid var(--rn-line);
  color: var(--rn-ink);
  text-decoration: none;
  font-size: 1rem;
}

.rn-menu a:hover,
.rn-menu a:focus {
  color: var(--rn-accent);
}

.rn-menu a[aria-current="true"] {
  color: var(--rn-accent);
  font-style: italic;
}

/* ---------- 3. Resume prompt ---------- */

.rn-resume {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  z-index: 1600;
  width: min(30rem, calc(100% - 2rem));
  padding: 1rem 1.25rem;
  background: var(--rn-bg);
  color: var(--rn-ink);
  border: 1px solid var(--rn-line);
  border-radius: 4px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  font-family: Georgia, "Times New Roman", serif;
  text-align: center;
}

.rn-resume[hidden] {
  display: none;
}

.rn-resume-text {
  margin: 0 0 0.85rem;
  font-size: 1rem;
  line-height: 1.5;
}

.rn-resume-text span {
  font-style: italic;
}

.rn-resume-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.rn-resume-actions button {
  background: none;
  border: 1px solid var(--rn-line);
  color: var(--rn-ink);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
}

#rnResumeGo {
  border-color: var(--rn-accent);
}

.rn-resume-actions button:hover {
  border-color: var(--rn-accent);
}

/* ---------- 4. Page buttons ---------- */

/* Stacked above the existing back-to-top button (bottom 1.5rem, 42px) */
.rn-pager {
  position: fixed;
  right: 1.5rem;
  bottom: calc(1.5rem + 42px + 0.6rem);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.rn-pager.visible {
  opacity: 1;
  pointer-events: auto;
}

.rn-pager[hidden] {
  display: none;
}

.rn-pager button {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
}

.rn-pager button:hover {
  border-color: rgba(255, 255, 255, 0.5);
}

/* "You were here" marker after a page turn */
.rn-marker {
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}

.rn-marker.show {
  width: 4px;
  border-radius: 2px;
  background: var(--rn-accent);
  animation: rn-fade 2.2s ease forwards;
}

@keyframes rn-fade {
  0%, 45% { opacity: 0.9; }
  100% { opacity: 0; }
}

@media (max-width: 600px) {
  .rn-bar-inner {
    padding: 0.5rem 1rem;
  }

  .rn-where {
    font-size: 0.85rem;
  }

  .rn-pager {
    right: 0.75rem;
  }

  .rn-pager button {
    width: 38px;
    height: 38px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rn-bar {
    transition: none;
  }

  .rn-marker.show {
    animation-duration: 3s;
  }
}

@media print {
  .rn-bar,
  .rn-pager,
  .rn-resume,
  .rn-marker {
    display: none !important;
  }
}
