/* Archive dossier + enhanced codex map */

.archive-dossier {
  position: relative;
  z-index: 10;
  margin: 0 auto 48px;
  max-width: 100%;
  padding: 28px 32px 32px;
  border: 1px solid rgba(201, 162, 39, 0.22);
  background:
    linear-gradient(165deg, rgba(36, 30, 22, 0.95) 0%, rgba(18, 15, 11, 0.98) 100%);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, 0.45),
    inset 0 0 0 1px rgba(201, 162, 39, 0.06);
}
.archive-dossier::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1px dashed rgba(201, 162, 39, 0.12);
  pointer-events: none;
}

.dossier-stamp {
  display: inline-block;
  font-family: 'Special Elite', monospace;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(107, 40, 48, 0.75);
  border: 2px double rgba(107, 40, 48, 0.45);
  padding: 8px 16px;
  margin-bottom: 18px;
  transform: rotate(-2deg);
}

.dossier-lead {
  font-family: 'IM Fell English', 'EB Garamond', serif;
  font-size: 18px;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 20px;
  max-width: 720px;
}

.dossier-stats {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin: 0 0 24px;
  padding: 0;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.dossier-stats li::before {
  content: '◆ ';
  color: var(--accent-dim);
  opacity: 0.6;
}

.dossier-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding: 12px;
  border: 1px solid rgba(201, 162, 39, 0.1);
  background: rgba(0, 0, 0, 0.25);
}
.dossier-index-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s, background 0.2s;
}
.dossier-index-item:hover {
  border-color: rgba(201, 162, 39, 0.35);
  background: rgba(201, 162, 39, 0.06);
}
.dossier-cat {
  font-family: 'Special Elite', monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--accent-dim);
}
.dossier-name {
  font-family: 'Cinzel', serif;
  font-size: 11px;
  color: #d4c4a8;
}

.node-provenance {
  position: relative;
  z-index: 1;
  margin-top: 10px;
  font-family: 'Special Elite', monospace;
  font-size: 8px;
  letter-spacing: 0.1em;
  color: rgba(201, 162, 39, 0.45);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

#map-modal .modal {
  width: min(1180px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
#map-modal .codex-modal {
  overflow: hidden;
}
.codex-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px 8px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.1);
}
.codex-control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.codex-control-group--zoom {
  flex: 0 0 auto;
  justify-content: flex-end;
}
.codex-toolbar-label {
  font-family: 'Cinzel', serif;
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: 4px;
}
.codex-filter,
.codex-zoom-btn {
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 12px;
  border: 1px solid rgba(201, 162, 39, 0.22);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}
.codex-filter:hover,
.codex-zoom-btn:hover {
  border-color: rgba(201, 162, 39, 0.45);
  color: var(--text);
}
.codex-filter.active {
  border-color: rgba(201, 162, 39, 0.55);
  background: rgba(201, 162, 39, 0.12);
  color: var(--accent);
}
.codex-zoom-btn {
  min-width: 36px;
  padding: 6px 10px;
}

.codex-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px 0;
}
.codex-status-item {
  padding: 4px 8px;
  border: 1px solid rgba(201, 162, 39, 0.16);
  background: rgba(0, 0, 0, 0.24);
  font-family: 'Special Elite', monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.55);
}

#map-modal .codex-modal-body {
  padding: 10px 12px 16px;
  max-height: min(72vh, 780px);
  overflow: hidden;
}
.codex-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
  align-items: stretch;
  min-height: 0;
}
.codex-viewport {
  position: relative;
  height: min(72vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(201, 162, 39, 0.18);
  background: #0a0806;
  cursor: grab;
  touch-action: none;
}
.codex-viewport::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(201, 162, 39, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201, 162, 39, 0.025) 1px, transparent 1px);
  background-size: 36px 36px;
  opacity: 0.75;
}
.codex-viewport:active {
  cursor: grabbing;
}
.codex-pan-layer {
  position: relative;
  z-index: 1;
  transform-origin: 0 0;
  will-change: transform;
}
.codex-pan-layer.codex-pan-animate {
  transition: transform 0.2s ease-out;
}
#lore-svg .codex-legend {
  pointer-events: none;
}
#lore-svg .codex-hint {
  display: none;
}
#map-modal #lore-svg {
  width: 100%;
  height: auto;
  display: block;
  min-height: 360px;
}

.codex-inspector {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 14px;
  border: 1px solid rgba(201, 162, 39, 0.18);
  background:
    linear-gradient(180deg, rgba(201, 162, 39, 0.06), transparent 36%),
    rgba(0, 0, 0, 0.34);
}
.codex-inspector-kicker {
  font-family: 'Special Elite', monospace;
  font-size: 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.56);
}
.codex-inspector-title {
  margin: 10px 0 8px;
  font-family: 'Cinzel Decorative', serif;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0.08em;
  color: #d8c694;
}
.codex-inspector-meta {
  margin: 0 0 12px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(168, 152, 128, 0.8);
}
.codex-inspector-body {
  flex: 1 1 auto;
  margin: 0 0 14px;
  overflow: auto;
  font-family: 'IM Fell English', 'EB Garamond', serif;
  font-size: 15px;
  line-height: 1.5;
  color: rgba(220, 204, 176, 0.86);
}
.codex-open-fragment {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid rgba(201, 162, 39, 0.42);
  background: rgba(201, 162, 39, 0.1);
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  cursor: pointer;
}
.codex-open-fragment:disabled {
  cursor: default;
  opacity: 0.45;
}
.codex-open-fragment:not(:disabled):hover {
  background: rgba(201, 162, 39, 0.16);
  border-color: rgba(201, 162, 39, 0.62);
}

.mob-group-label {
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 28px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(201, 162, 39, 0.12);
}
.mob-group-label.first {
  margin-top: 8px;
}

.dossier-index-tall {
  max-height: 320px;
}

.dossier-subhead {
  margin: 28px 0 8px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.65);
}

.dossier-sublead {
  margin: 0 0 16px;
  font-family: 'IM Fell English', serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text-dim);
  max-width: 680px;
}

.dossier-index-head {
  margin-top: 32px;
}

.archive-guide {
  margin-bottom: 8px;
}

.guide-tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-width: 640px;
}

.guide-tips li {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-family: 'IM Fell English', serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
}

.guide-tips kbd {
  flex-shrink: 0;
  min-width: 2.2em;
  padding: 4px 8px;
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
  border: 1px solid rgba(201, 162, 39, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: var(--accent);
}

.reading-paths-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}

.reading-path-card {
  padding: 16px 14px;
  border: 1px solid rgba(201, 162, 39, 0.18);
  background: rgba(0, 0, 0, 0.28);
  transition: border-color 0.2s, background 0.2s;
}

.reading-path-card:hover {
  border-color: rgba(201, 162, 39, 0.38);
  background: rgba(201, 162, 39, 0.04);
}

.reading-path-title {
  margin: 0 0 8px;
  font-family: 'Cinzel Decorative', serif;
  font-size: 13px;
  letter-spacing: 0.1em;
  color: #d4c4a8;
}

.reading-path-desc {
  margin: 0 0 12px;
  font-family: 'IM Fell English', serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-dim);
}

.reading-path-stops {
  margin: 0 0 14px;
  padding: 0 0 0 18px;
  font-family: 'Cinzel', serif;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.reading-path-stop {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(201, 162, 39, 0.35);
  text-underline-offset: 3px;
}

.reading-path-stop:hover {
  color: var(--accent);
}

.reading-path-begin {
  width: 100%;
  padding: 8px 12px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid rgba(201, 162, 39, 0.4);
  background: rgba(201, 162, 39, 0.08);
  color: var(--accent);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.reading-path-begin:hover {
  background: rgba(201, 162, 39, 0.16);
  border-color: rgba(201, 162, 39, 0.6);
}

.archive-annex {
  margin-top: 48px;
  padding-top: 8px;
}

.annex-lead {
  font-family: 'IM Fell English', serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  max-width: 720px;
  margin-bottom: 24px;
}

.annex-subhead {
  margin: 0 0 12px;
  font-family: 'Cinzel', serif;
  font-size: 9px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(201, 162, 39, 0.55);
}

.catalog-legend-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 20px;
  max-width: 640px;
  margin: 0 0 28px;
}

.catalog-legend-list dt {
  font-family: 'Special Elite', monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.catalog-legend-list dd {
  margin: 0;
  font-family: 'IM Fell English', serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-dim);
}

.annex-note {
  font-family: 'IM Fell English', serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-dim);
  max-width: 720px;
  margin: 0 0 14px;
  padding-left: 14px;
  border-left: 2px solid rgba(201, 162, 39, 0.2);
}

/* Mob grid columns: cards-layout.css (auto-fit + grid-cols-N) */

.node-wrap.node-unseal-flash .node {
  animation: node-unseal-pulse 0.65s ease-out;
}
@keyframes node-unseal-pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 162, 39, 0.45); }
  70% { box-shadow: 0 0 28px 4px rgba(201, 162, 39, 0.15); }
  100% { box-shadow: none; }
}

/* ── Codex links by zone ── */
#lore-svg .lore-link {
  stroke-width: 1.25;
  stroke-linecap: round;
  transition: stroke-opacity 0.2s, stroke-width 0.2s;
}
#lore-svg .lore-link.link-zone-canon {
  stroke: rgba(90, 122, 106, 0.22);
}
#lore-svg .lore-link.link-zone-myth {
  stroke: rgba(139, 48, 56, 0.28);
}
#lore-svg .lore-link.link-zone-mob {
  stroke: rgba(74, 106, 90, 0.16);
}
#lore-svg .lore-link.link-zone-culture {
  stroke: rgba(106, 122, 154, 0.24);
}
#lore-svg .lore-link.link-zone-shrine {
  stroke: rgba(201, 162, 39, 0.26);
}
#lore-svg .lore-link.link-cross {
  stroke: rgba(201, 162, 39, 0.14);
}
#lore-svg .lore-link.link-whisper {
  stroke: rgba(139, 48, 56, 0.12);
  stroke-dasharray: 4 6;
}
#lore-svg .lore-link.link-active {
  stroke: var(--accent) !important;
  stroke-width: 2.4 !important;
  stroke-opacity: 1 !important;
  stroke-dasharray: none !important;
}

/* ── Nodes ── */
#lore-svg .map-node-group {
  cursor: pointer;
}
#lore-svg .map-node-label {
  paint-order: stroke fill;
  stroke: rgba(8, 6, 4, 0.85);
  stroke-width: 2.5px;
  letter-spacing: 0.06em;
}
#lore-svg .map-node-group[data-zone="mob"] .map-node-label {
  opacity: 0.72;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
#lore-svg .map-node-group[data-zone="mob"]:hover .map-node-label,
#lore-svg .map-node-group[data-zone="mob"].map-active .map-node-label,
#lore-svg .map-node-group[data-zone="mob"]:focus-within .map-node-label {
  opacity: 1;
}
#lore-svg .map-node-group.map-active .map-node-label,
#lore-svg .map-node-group:hover .map-node-label {
  fill: #e8dcc0;
}
#lore-svg .map-node-group.map-node-hub .lore-node-circle {
  stroke-width: 2.5;
}
#lore-svg .map-node-group[data-zone="mob"] .lore-node-circle {
  stroke-opacity: 0.9;
}
#lore-svg .map-node-group:not(.map-discovered) .lore-node-circle {
  opacity: 0.55;
}
#lore-svg .map-node-group.map-discovered .lore-node-circle {
  opacity: 1;
}
#lore-svg .map-node-group:hover .lore-node-circle,
#lore-svg .map-node-group.map-active .lore-node-circle {
  filter: brightness(1.2);
  stroke-width: 3;
}
#lore-svg .map-node-group.map-active .map-node-ring {
  stroke-opacity: 0.45;
  stroke-width: 1.5;
}

/* ── Zone filters ── */
#lore-svg .map-node-group[data-zone="culture"] .map-node-label,
#lore-svg .map-node-group[data-zone="shrine"] .map-node-label {
  font-size: 8px;
  letter-spacing: 0.04em;
}
#lore-svg .map-node-group.map-node-dense .lore-node-circle {
  stroke-width: 1.4;
}

#lore-svg[data-codex-filter="canon"] .map-node-group:not([data-zone="canon"]),
#lore-svg[data-codex-filter="myth"] .map-node-group:not([data-zone="myth"]),
#lore-svg[data-codex-filter="mobs"] .map-node-group:not([data-zone="mob"]),
#lore-svg[data-codex-filter="culture"] .map-node-group:not([data-zone="culture"]),
#lore-svg[data-codex-filter="creators"] .map-node-group:not([data-zone="shrine"]) {
  opacity: 0.12 !important;
  pointer-events: none !important;
  animation: none !important;
  transform: none !important;
}
#lore-svg[data-codex-filter="canon"] .lore-link:not(.link-zone-canon),
#lore-svg[data-codex-filter="myth"] .lore-link:not(.link-zone-myth),
#lore-svg[data-codex-filter="mobs"] .lore-link:not(.link-zone-mob),
#lore-svg[data-codex-filter="culture"] .lore-link:not(.link-zone-culture),
#lore-svg[data-codex-filter="creators"] .lore-link:not(.link-zone-shrine) {
  opacity: 0.04;
}
#lore-svg[data-codex-filter="canon"] .map-node-group[data-zone="canon"],
#lore-svg[data-codex-filter="myth"] .map-node-group[data-zone="myth"],
#lore-svg[data-codex-filter="mobs"] .map-node-group[data-zone="mob"],
#lore-svg[data-codex-filter="culture"] .map-node-group[data-zone="culture"],
#lore-svg[data-codex-filter="creators"] .map-node-group[data-zone="shrine"] {
  opacity: 1;
  pointer-events: auto;
}
#lore-svg[data-codex-filter="canon"] .lore-link.link-active,
#lore-svg[data-codex-filter="myth"] .lore-link.link-active,
#lore-svg[data-codex-filter="mobs"] .lore-link.link-active,
#lore-svg[data-codex-filter="culture"] .lore-link.link-active,
#lore-svg[data-codex-filter="creators"] .lore-link.link-active,
#lore-svg[data-codex-filter="canon"] .lore-link.link-cross.link-active,
#lore-svg[data-codex-filter="myth"] .lore-link.link-cross.link-active,
#lore-svg[data-codex-filter="mobs"] .lore-link.link-cross.link-active,
#lore-svg[data-codex-filter="culture"] .lore-link.link-cross.link-active,
#lore-svg[data-codex-filter="creators"] .lore-link.link-cross.link-active {
  opacity: 1;
}

.codex-band-label {
  pointer-events: none;
  user-select: none;
}

@media (max-width: 820px) {
  #map-modal .modal {
    width: 98vw;
    max-height: 94vh;
  }

  .codex-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .codex-control-group--zoom {
    justify-content: flex-start;
  }

  .codex-shell {
    grid-template-columns: 1fr;
  }

  .codex-viewport {
    height: min(54vh, 520px);
  }

  .codex-inspector {
    max-height: 220px;
  }
}

@media (max-width: 520px) {
  .codex-filter,
  .codex-zoom-btn {
    flex: 1 1 auto;
    padding: 7px 8px;
    font-size: 9px;
  }

  .codex-toolbar-label {
    flex: 1 1 100%;
  }

  .codex-status {
    padding-inline: 12px;
  }

  #map-modal .codex-modal-body {
    padding-inline: 8px;
  }
}
