/* ═══════════════════════════════════════════════════════════════════
   GUARDIANS · ACT III — THE WORLD (lore.css)
   Additive layer only. portal.css is LAW. Twilight chrome; the story's
   chapter plates are paintings, not parchment — the prologue is
   PERFORMED, not filed.
   ═══════════════════════════════════════════════════════════════════ */

/* ── The performed prologue ─────────────────────────────────────── */
.story-chapter {
  display: grid; grid-template-columns: minmax(260px, 420px) 1fr;
  gap: clamp(20px, 4vw, 44px); align-items: start;
  margin: 0 auto 54px; max-width: 1060px;
}
.story-chapter:nth-child(even) { grid-template-columns: 1fr minmax(260px, 420px); }
.story-chapter:nth-child(even) figure { order: 2; }
.story-chapter figure { margin: 0; position: sticky; top: 90px; }
.story-chapter figure img {
  width: 100%; height: auto; border-radius: 10px; display: block;
  border: 1px solid rgba(183, 154, 224, 0.28);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.6), 0 0 30px rgba(183, 154, 224, 0.1);
}
.story-chapter figcaption {
  margin-top: 10px; text-align: center;
  font-family: var(--f-arc); font-style: italic; font-size: 0.85rem; color: #9d92b8;
}
.story-chapter .ch-k {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--gold-soft);
}
.story-chapter h3 {
  font-family: var(--f-arc); font-weight: 400;
  font-size: clamp(1.5rem, 3vw, 2.1rem); color: #f0eaf8; margin: 6px 0 14px;
}
.story-chapter p {
  font-family: var(--f-arc); font-size: 1.05rem; line-height: 1.75;
  color: #c9bfdd; margin: 0 0 14px;
}
.story-chapter p:first-of-type::first-letter {
  font-size: 2.6em; line-height: 0.9; float: left; padding-right: 8px;
  color: var(--gold); font-family: var(--f-arc);
}
.story-chapter blockquote {
  margin: 18px 0; padding: 14px 20px;
  border-left: 3px solid var(--arc-soft);
  background: rgba(183, 154, 224, 0.06); border-radius: 0 8px 8px 0;
}
.story-chapter blockquote p { margin: 0 0 8px; color: #e2d9f2; font-style: italic; }
.story-chapter blockquote p:last-child { margin: 0; }

@media (max-width: 760px) {
  .story-chapter, .story-chapter:nth-child(even) { grid-template-columns: 1fr; }
  .story-chapter:nth-child(even) figure { order: 0; }
  .story-chapter figure { position: static; }
}

/* ── The numbers Terra carries ──────────────────────────────────── */
.terra-numbers {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px; max-width: 1000px; margin: 0 auto;
}
.terra-numbers .tn {
  text-align: center; padding: 26px 16px;
  border: 1px solid rgba(183, 154, 224, 0.24); border-radius: 12px;
  background: linear-gradient(180deg, rgba(183, 154, 224, 0.06), rgba(16, 13, 30, 0.6));
}
.terra-numbers .tn .n {
  display: block; font-family: var(--f-arc);
  font-size: clamp(2rem, 4vw, 2.8rem); color: var(--gold);
  text-shadow: 0 0 22px rgba(255, 207, 136, 0.3);
}
.terra-numbers .tn .l {
  display: block; margin-top: 6px; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.18em; text-transform: uppercase; color: #ab9fc4;
}

/* ── The Atlas ──────────────────────────────────────────────────── */

#atlas { max-width: 880px; margin: 0 auto; }
.atlas-count { font-family: var(--f-arc); font-style: italic; color: #9d92b8; margin: 0 0 16px; }
.atlas-region {
  border: 1px solid rgba(183, 154, 224, 0.24); border-radius: 12px;
  background: rgba(16, 13, 30, 0.72); margin: 0 0 14px; overflow: hidden;
}
.atlas-region summary {
  cursor: pointer; padding: 15px 20px; font-weight: 700; letter-spacing: 0.06em;
  font-size: 1.08rem; color: #f0eaf8; list-style: none; position: relative;
}
.atlas-region summary::-webkit-details-marker { display: none; }
.atlas-region summary::after {
  content: "◂"; position: absolute; right: 20px; color: var(--arc-hi);
  transition: transform 0.25s ease;
}
.atlas-region[open] summary::after { transform: rotate(-90deg); }
.atlas-region summary:hover { color: var(--gold); }
.atlas-region summary .count {
  display: inline-block; margin-left: 10px; padding: 1px 10px;
  font-size: 0.75rem; color: var(--arc-hi);
  border: 1px solid var(--arc-line); border-radius: 999px;
}
.atlas-list { list-style: none; margin: 0; padding: 4px 20px 16px; }
.atlas-entry { padding: 14px 0; border-top: 1px solid rgba(183, 154, 224, 0.12); }
.ae-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ae-head h4 { margin: 0; font-size: 1.05rem; letter-spacing: 0.04em; color: #ffe3ae; }
.ae-kind { margin: 2px 0 6px; font-size: 0.82rem; color: #9d92b8; font-family: var(--f-arc); }
.ae-blurb { margin: 0 0 6px; font-family: var(--f-arc); line-height: 1.6; color: #c9bfdd; }
.ae-meta { margin: 0 0 6px; font-size: 0.85rem; color: #ab9fc4; line-height: 1.55; }
.ae-meta b { color: #cfc3e6; font-weight: 600; }
.ae-tags span {
  display: inline-block; margin: 2px 6px 0 0; padding: 1px 9px;
  font-size: 0.72rem; letter-spacing: 0.06em; color: var(--arc-hi);
  border: 1px solid rgba(183, 154, 224, 0.3); border-radius: 999px;
}
.danger {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 10px; border-radius: 999px; border: 1px solid currentColor;
}
.d-low     { color: #a8c8a0; }
.d-med     { color: var(--gold); }
.d-high    { color: #e0906a; }
.d-extreme { color: #e06a6a; }
.d-res     { color: #b79ae0; }
.d-var     { color: #cfc3e6; }
.d-unk     { color: #7d7396; }

/* ── The creed band ─────────────────────────────────────────────── */
/* THE DECREE — an inscription, not a widget: centered by force at
   every level, framed in gold rules, each line waking as the eye
   arrives (portal.js reveal, per line), and answering the hand with a
   soft gold breath on hover. */
.creed {
  max-width: 900px; margin: 0 auto; text-align: center;
  padding: clamp(10px, 2vw, 26px) 12px;
}
.creed .creed-rule {
  text-align: center; color: rgba(216, 176, 106, 0.55); letter-spacing: 0.3em;
  font-size: 0.8rem; margin: 0 0 26px; user-select: none;
}
.creed .creed-rule:last-of-type { margin: 8px 0 18px; }
.creed .line {
  font-family: var(--f-arc); text-align: center;
  font-size: clamp(1.25rem, 2.7vw, 1.7rem);
  color: #e2d9f2; margin: 0 0 24px; line-height: 1.65;
  transition: text-shadow 0.4s ease, color 0.4s ease;
}
.creed .line b {
  color: var(--gold); font-weight: 400;
  text-shadow: 0 0 18px rgba(255, 207, 136, 0.3);
  transition: text-shadow 0.4s ease;
}
.creed .line:hover { color: #f4eefc; text-shadow: 0 0 24px rgba(183, 154, 224, 0.25); }
.creed .line:hover b { text-shadow: 0 0 26px rgba(255, 207, 136, 0.6), 0 0 46px rgba(255, 207, 136, 0.25); }
.creed .attr { font-family: var(--f-arc); font-style: italic; font-size: 0.9rem; color: #9d92b8; text-align: center; }
/* the lines wake in order, not at once */
.creed .line.reveal { transition-delay: 0s; }
.creed .line.reveal:nth-of-type(3) { transition-delay: 0.18s; }
.creed .line.reveal:nth-of-type(4) { transition-delay: 0.36s; }

@media (prefers-reduced-motion: reduce) {
  .atlas-region summary::after { transition: none; }
}

/* ═══ THE BOUND ATLAS ═══════════════════════════════════════════════
   Paper things stay paper: the Atlas is a book. The chain below is the
   No-JS truth; when JS lives, the tome stands in front and the chain
   folds away. Erez's plates: cover.webp for the tome, page-index /
   page-entry veiled under parchment so their ornate frames ghost
   through while real ink stays readable. */
html.atlas-on #atlas { display: none; }
html:not(.atlas-on) .atlas-tome-stand { display: none; }

.atlas-tome-stand { text-align: center; }
.atlas-tome {
  display: inline-block; cursor: pointer; background: none; border: none; padding: 0;
  position: relative; max-width: min(620px, 92vw);
}
.atlas-tome img {
  width: 100%; height: auto; display: block;
  filter: drop-shadow(0 26px 30px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 26px rgba(255, 207, 136, 0.1));
  transition: transform 0.35s ease, filter 0.35s ease;
}
.atlas-tome .tome-label {
  position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%);
  font-family: var(--f-ui); font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase; white-space: nowrap;
  color: var(--gold); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  padding: 10px 22px; border: 1px solid var(--gold-soft); border-radius: 4px;
  background: rgba(10, 9, 22, 0.55);
  transition: box-shadow 0.35s ease, background 0.35s ease;
}
.atlas-tome:hover img { transform: translateY(-5px) rotate(-0.6deg); filter: drop-shadow(0 34px 38px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 34px rgba(255, 207, 136, 0.22)); }
.atlas-tome:hover .tome-label { box-shadow: 0 0 24px rgba(255, 207, 136, 0.35); background: rgba(10, 9, 22, 0.75); }

body.codex-lock { overflow: hidden; }

.codex-overlay[hidden] { display: none; }
.codex-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(5, 4, 12, 0.88);
  display: grid; place-items: center; padding: 3vh 2vw;
}
.codex-book {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr;
  width: min(1180px, 96vw); height: min(760px, 88vh);
  border-radius: 10px; overflow: hidden;
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.8), 0 0 60px rgba(183, 154, 224, 0.12);
}
/* the spine shadow where the pages meet */
.codex-book::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 60px;
  transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(42, 30, 16, 0.35) 45%, rgba(20, 14, 8, 0.5) 50%, rgba(42, 30, 16, 0.35) 55%, transparent);
}
.codex-page { overflow-y: auto; padding: clamp(22px, 3.5vw, 44px); color: var(--ink); }
.codex-index {
  background:
    linear-gradient(rgba(232, 220, 192, 0.84), rgba(232, 220, 192, 0.84)),
    url("../images/atlas/page-index.webp") center / cover;
}
.codex-entry {
  background:
    linear-gradient(rgba(236, 226, 200, 0.86), rgba(236, 226, 200, 0.86)),
    url("../images/atlas/page-entry.webp") center / cover;
  position: relative;
}

.codex-close {
  position: absolute; top: 0; right: 26px; z-index: 5; cursor: pointer;
  font-family: var(--f-ui); font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--parch); background: #6d1f1f;
  border: none; border-radius: 0 0 6px 6px; padding: 12px 16px 10px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
}
.codex-close:hover { background: #8a2727; }

/* ── the index page ── */
.cx-head {
  font-family: var(--f-arc); font-size: 1.5rem; text-align: center;
  margin: 0 0 14px; color: var(--ink);
}
.cx-search {
  width: 100%; font-family: var(--f-arc); font-style: italic; font-size: 1rem;
  color: var(--ink); background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(74, 61, 44, 0.5); border-radius: 6px; padding: 10px 14px;
}
.cx-search:focus { outline: none; border-color: #8a6d3b; box-shadow: 0 0 0 3px rgba(138, 109, 59, 0.2); }
.cx-status { font-family: var(--f-arc); font-style: italic; font-size: 0.85rem; color: var(--ink-soft); min-height: 1.2em; margin: 8px 0 0; }
.cx-region {
  font-family: var(--f-arc); font-weight: 400; font-size: 1.05rem;
  margin: 20px 0 6px; padding-bottom: 4px; color: #5d3f14;
  border-bottom: 1px solid rgba(74, 61, 44, 0.35);
}
.cx-region .cx-count { font-size: 0.75rem; color: var(--ink-soft); }
.cx-list { list-style: none; margin: 0; padding: 0; }
.cx-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; cursor: pointer;
  background: none; border: none; border-bottom: 1px dotted rgba(74, 61, 44, 0.3);
  font-family: var(--f-arc); font-size: 0.98rem; color: var(--ink);
  padding: 7px 4px;
}
.cx-row:hover { background: rgba(138, 109, 59, 0.1); }
.cx-row.open { background: rgba(138, 109, 59, 0.16); font-weight: 700; }
.seals { display: inline-flex; gap: 4px; align-items: center; flex: 0 0 auto; }
.seals .seal {
  width: 11px; height: 11px; border-radius: 50%;
  border: 1px solid rgba(109, 31, 31, 0.55);
  background: transparent;
}
.seals .seal.on { background: radial-gradient(circle at 35% 30%, #c25454, #6d1f1f 70%); border-color: #4d1414; }
.seals .seal.on.d-extreme { background: radial-gradient(circle at 35% 30%, #e06a6a, #4d0f0f 75%); }
.seals.glyph { font-weight: 700; font-size: 0.9rem; color: #6d1f1f; }

/* ── the entry page ── */
.cx-entry-host { min-height: 100%; }
.cx-seal-stamp {
  float: right; margin: 0 0 10px 14px; padding: 8px 14px;
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--parch); background: radial-gradient(circle at 35% 30%, #a03434, #5d1717 80%);
  border-radius: 50% 46% 52% 48% / 48% 52% 46% 54%;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), inset 0 0 10px rgba(0, 0, 0, 0.3);
  max-width: 40%; text-align: center;
}
.cx-seal-stamp.d-low { background: radial-gradient(circle at 35% 30%, #6d8a5a, #3d5230 80%); }
.cx-seal-stamp.d-med { background: radial-gradient(circle at 35% 30%, #b08b3e, #6d531f 80%); }
.cx-seal-stamp.d-var, .cx-seal-stamp.d-unk { background: radial-gradient(circle at 35% 30%, #7a7a7a, #444 80%); }
.cx-seal-stamp.d-res { background: radial-gradient(circle at 35% 30%, #7a5aa0, #46325d 80%); }
.cx-name { font-family: var(--f-arc); font-weight: 400; font-size: clamp(1.6rem, 2.6vw, 2.2rem); margin: 0 0 4px; color: var(--ink); }
.cx-name .cap {
  float: left; font-size: 2.4em; line-height: 0.82; padding: 4px 10px 0 0;
  color: #5d3f14;
}
.cx-kind { clear: none; font-family: var(--f-arc); font-style: italic; font-size: 0.95rem; color: var(--ink-soft); margin: 0 0 16px; }
.cx-blurb { font-family: var(--f-arc); font-size: 1.08rem; line-height: 1.75; color: var(--ink); clear: left; margin: 0 0 16px; }
.cx-meta { font-size: 0.92rem; line-height: 1.6; color: var(--ink-soft); border-left: 3px solid rgba(138, 109, 59, 0.5); padding-left: 14px; margin: 0 0 16px; }
.cx-meta b { color: #5d3f14; }
.cx-tags span {
  display: inline-block; margin: 0 6px 6px 0; padding: 2px 12px;
  font-size: 0.74rem; letter-spacing: 0.08em; color: #5d3f14;
  border: 1px solid rgba(93, 63, 20, 0.5); border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}
.cx-sources { font-family: var(--f-arc); font-style: italic; font-size: 0.8rem; color: var(--ink-soft); border-top: 1px solid rgba(74, 61, 44, 0.3); padding-top: 8px; margin-top: 18px; }

/* the page turn */
@keyframes page-turn {
  0%   { opacity: 0.25; transform: perspective(1200px) rotateY(-14deg); box-shadow: -30px 0 40px rgba(0,0,0,0.25) inset; }
  100% { opacity: 1;    transform: perspective(1200px) rotateY(0deg); }
}
.codex-entry.turning .cx-entry-host { animation: page-turn 0.45s ease-out; transform-origin: left center; }

.cx-back { display: none; }

/* ── one page at a time on small screens ── */
@media (max-width: 760px) {
  .codex-book { grid-template-columns: 1fr; height: min(820px, 92vh); }
  .codex-entry { display: none; }
  .codex-book.entry-open .codex-index { display: none; }
  .codex-book.entry-open .codex-entry { display: block; }
  .cx-back {
    display: inline-block; position: sticky; bottom: 0; margin-top: 18px;
    cursor: pointer; font-family: var(--f-ui); font-size: 0.78rem; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--parch); background: #4a3d2c; border: none; border-radius: 6px;
    padding: 12px 20px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .atlas-tome img, .atlas-tome .tome-label { transition: none; }
  .atlas-tome:hover img { filter: drop-shadow(0 26px 30px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 26px rgba(255, 207, 136, 0.1)); }
  .atlas-tome:hover img { transform: none; }
  .codex-entry.turning .cx-entry-host { animation: none; }
}

/* the chain keeps its tiny sources line (No-JS view) */
.ae-sources { margin: 0; font-size: 0.78rem; font-family: var(--f-arc); font-style: italic; color: #8d82a8; }
