/* chapter.css — Reading template for prose chapters
   Light warm parchment theme to match the majority of archive pages.
   Optimized for long reading sessions. */


/* ===== Base ===== */

body.chapter {
  background-color: #d4cfc6;
  color: #2a2a2a;
  font-family: 'Noto Serif', Georgia, 'Times New Roman', serif;
  line-height: 1.85;
  margin: 0;
  padding: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(180, 170, 150, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(190, 180, 160, 0.1) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 90%, rgba(175, 165, 145, 0.12) 0%, transparent 50%);
  background-attachment: fixed;
}


/* ===== Selection highlight ===== */

body.chapter ::selection {
  background: rgba(196, 163, 90, 0.3);
  color: #1a1a1a;
}


/* ===== Container ===== */

.chapter-container {
  max-width: 680px;
  margin: 0 auto;
  padding: 80px 24px 120px;
}


/* ===== Chapter header ===== */

.chapter-header {
  text-align: center;
  margin-bottom: 60px;
  padding-bottom: 30px;
  border-bottom: 1px solid rgba(120, 110, 95, 0.2);
}

.chapter-number {
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 0.8rem;
  color: rgba(120, 110, 95, 0.55);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.chapter-title {
  font-family: 'Noto Serif', Georgia, serif;
  font-weight: 700;
  font-size: 2rem;
  color: #1a1a1a;
  letter-spacing: 0.03em;
  margin: 0;
}


/* ===== Prose body ===== */

.chapter-body p {
  font-size: 1.05rem;
  margin-bottom: 1.4em;
  text-indent: 0;
}

/* Inner thoughts / emphasis */
.chapter-body em {
  color: #4a4540;
}


/* ===== Scene breaks ===== */

.scene-break {
  width: 60px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(120, 110, 95, 0.4), transparent);
  margin: 2.5em auto;
  border: none;
}


/* ===== Timestamp / location markers ===== */

.timestamp {
  font-style: italic;
  color: #6a6560;
  text-align: center;
  font-size: 0.95rem;
  margin: 2em 0;
}


/* ===== Author notes ===== */

.author-note {
  font-size: 0.9rem;
  color: #6a6560;
  border-left: 2px solid rgba(120, 110, 95, 0.3);
  padding-left: 16px;
  margin: 2em 0;
  font-style: italic;
}


/* ===== Chorus artifacts (in-world documents) ===== */

.chorus-artifact {
  margin: 2.5em 0;
  padding: 20px 22px 16px;
  border: 1px solid rgba(120, 110, 95, 0.25);
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.04);
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 0.92rem;
  line-height: 1.65;
  color: #3f3a34;
}

.chorus-artifact-label {
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(90, 80, 68, 0.75);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(120, 110, 95, 0.15);
}

.chorus-artifact-body p {
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 0.92rem;
  margin-bottom: 0.9em;
  text-indent: 0;
}

.chorus-artifact-body p:last-child {
  margin-bottom: 0;
}


/* ===== Contextual archive callouts ===== */

.archive-callout {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1.8em 0;
  padding: 12px 14px;
  border-left: 3px solid rgba(196, 163, 90, 0.65);
  border-radius: 2px;
  background: rgba(196, 163, 90, 0.11);
  color: #3f3a34;
  cursor: pointer;
  transition: background 0.16s ease, border-left-color 0.16s ease;
}

.archive-callout:hover,
.archive-callout:focus {
  background: rgba(196, 163, 90, 0.18);
  border-left-color: rgba(196, 163, 90, 0.9);
  outline: none;
}

.archive-callout .callout-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.archive-callout .callout-text {
  font-size: 0.95rem;
}

.archive-callout.archive-callout-error {
  border-left-color: rgba(160, 40, 40, 0.8);
  background: rgba(160, 40, 40, 0.1);
}


/* ===== Chapter-end related docs ===== */

.chapter-related-docs {
  margin-top: 2.4em;
  margin-bottom: 1.2em;
  padding: 18px 20px 8px;
  border: 1px solid rgba(120, 110, 95, 0.25);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.03);
}

.chapter-related-title {
  font-family: 'Special Elite', 'Courier New', monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: rgba(90, 80, 68, 0.88);
}

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

.chapter-related-item {
  margin-bottom: 12px;
}

.chapter-related-link {
  display: inline-block;
  color: #403930;
  text-decoration: none;
  font-size: 0.96rem;
}

.chapter-related-link:hover {
  text-decoration: underline;
}

.chapter-related-preview {
  margin: 4px 0 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #625c54;
}


/* ===== Archive overlay (iframe-based full document preview) ===== */

#archive-overlay-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10004;
  background: rgba(0, 0, 0, 0.5);
}

#archive-overlay-backdrop.open {
  display: block;
}

#archive-overlay {
  display: none;
  position: fixed;
  z-index: 10005;
  top: 5vh;
  left: 5vw;
  width: 90vw;
  height: 85vh;
  border-radius: 6px;
  border: 1px solid rgba(100, 92, 80, 0.34);
  background: #d4cfc6;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  flex-direction: column;
  overflow: hidden;
}

#archive-overlay.measuring {
  display: flex;
  clip-path: circle(0% at var(--clip-x, 50%) var(--clip-y, 50%));
  opacity: 0;
}

#archive-overlay.open {
  display: flex;
  animation: overlay-reveal 0.8s ease-in-out forwards;
}

@keyframes overlay-reveal {
  from {
    clip-path: circle(0% at var(--clip-x, 50%) var(--clip-y, 50%));
    opacity: 0.5;
  }
  to {
    clip-path: circle(150% at var(--clip-x, 50%) var(--clip-y, 50%));
    opacity: 1;
  }
}

#archive-overlay-backdrop.open {
  animation: backdrop-fade-in 0.4s ease-out;
}

@keyframes backdrop-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

#archive-overlay .archive-overlay-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: transparent;
  border-bottom: 1px solid transparent;
  flex-shrink: 0;
}

#archive-overlay .archive-overlay-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #2f2a24;
  font-family: 'Noto Serif', Georgia, serif;
  transform: translate(-60px, 80px) rotate(-8deg) scale(0.85);
  opacity: 0.3;
  transition: none;
}

#archive-overlay .archive-overlay-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

#archive-overlay .archive-overlay-open {
  color: #2f2a24;
  text-decoration: none;
  font-size: 0.85rem;
  font-family: 'Special Elite', 'Courier New', monospace;
  transform: translate(80px, 60px) rotate(5deg) scale(0.8);
  opacity: 0.2;
  transition: none;
}

#archive-overlay .archive-overlay-open:hover {
  text-decoration: underline;
}

#archive-overlay .archive-overlay-close {
  border: 1px solid rgba(100, 92, 80, 0.35);
  background: rgba(0, 0, 0, 0.03);
  color: #2f2a24;
  border-radius: 3px;
  font-size: 0.85rem;
  padding: 4px 10px;
  cursor: pointer;
  transform: translate(-40px, 50px) rotate(-6deg) scale(0.8);
  opacity: 0.2;
  transition: none;
}

#archive-overlay .archive-overlay-close:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* When settling: elements consolidate into place */
#archive-overlay.fitting .archive-overlay-bar {
  background: rgba(100, 92, 80, 0.12);
  border-bottom-color: rgba(100, 92, 80, 0.2);
  transition: background 0.8s ease, border-bottom-color 0.8s ease;
}

#archive-overlay.fitting .archive-overlay-title {
  transform: none;
  opacity: 1;
  transition: transform 0.8s cubic-bezier(0.16, 0.7, 0.3, 1),
              opacity 0.6s ease;
}

#archive-overlay.fitting .archive-overlay-open {
  transform: none;
  opacity: 1;
  transition: transform 0.8s cubic-bezier(0.16, 0.7, 0.3, 1) 0.1s,
              opacity 0.6s ease 0.1s;
}

#archive-overlay.fitting .archive-overlay-close {
  transform: none;
  opacity: 1;
  transition: transform 0.8s cubic-bezier(0.16, 0.7, 0.3, 1) 0.15s,
              opacity 0.6s ease 0.15s;
}

#archive-overlay.fitting {
  border-radius: 6px;
}

#archive-overlay iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #d4cfc6;
  overflow-y: auto;
}



/* ===== Mobile responsive ===== */

@media (max-width: 480px) {
  .chapter-container {
    padding: 60px 18px 100px;
  }

  .chapter-title {
    font-size: 1.6rem;
  }

  .chapter-body p {
    font-size: 1rem;
  }
}

@media (max-width: 767px) {
  #archive-overlay {
    top: 2vh;
    left: 2vw;
    width: 96vw;
    height: 92vh;
  }
}
