/* ============================================================================
   Lab — Lore archives
   A classified-terminal skin over the Dreamless canon: monospace chrome, a
   phosphor classmark, wax-sealed sections badged. The look nods to the
   pre-Effondrement terminals of the bridge without ever claiming to be one —
   the archives don't exist in-world. Reading surface stays plain and legible;
   only the chrome is theatrical.
   ============================================================================ */

.archives {
  max-width: 62rem;
  margin: 0 auto;
  padding: var(--sp-6, 2rem) var(--sp-5, 1.5rem) var(--sp-8, 3rem);
  color: var(--text);
}

/* -------------------------------------------------------------- classmark */

.archives-head {
  border: 1px solid var(--rule-on-wood);
  border-radius: 4px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  background:
    repeating-linear-gradient(
      to bottom,
      color-mix(in oklch, var(--mist) 4%, transparent) 0 1px,
      transparent 1px 3px
    ),
    var(--wood-dark);
}

.archives-classmark {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--amber);
  margin: 0;
}

.archives-title {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  color: var(--text);
  margin: 0.35rem 0 0;
}

.archives-sub {
  font-size: var(--fs-sm);
  color: var(--text-faint);
  margin: 0.4rem 0 0;
}

.archives-back {
  display: inline-block;
  margin-top: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--mist);
  text-decoration: none;
}
.archives-back::before { content: "← "; }
.archives-back:hover { color: var(--text); }

/* ----------------------------------------------------------------- search */

.archives-search {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
}

.archives-query {
  flex: 1;
  padding: 0.6rem 0.85rem;
  background: var(--wood-deep);
  border: 1px solid var(--wood-edge);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-base);
}
.archives-query:focus {
  outline: none;
  border-color: var(--mist);
}

.archives-go {
  padding: 0.6rem 1.1rem;
  background: var(--wood-mid);
  border: 1px solid var(--wood-edge);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.archives-go:hover { border-color: var(--mist); }

/* -------------------------------------------------------- offline / empty */

.archives-offline,
.archives-empty {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-faint);
  padding: 1rem 0;
}
.archives-offline::before { content: "// "; color: var(--wine-bright); }

/* --------------------------------------------------------------- results */

.archives-results {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 2.5rem;
}

.archives-hit {
  border: 1px solid var(--rule-on-wood);
  border-left: 2px solid var(--wood-edge);
  border-radius: 4px;
  padding: 0.85rem 1rem;
  background: var(--wood-dark);
}

.hit-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.hit-source {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--mist);
  text-decoration: none;
}
.hit-source:hover { color: var(--text); text-decoration: underline; }

/* ------------------------------------------------------------------ fiche */

.fiche-head {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule-on-wood);
}
.fiche-title {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  color: var(--text);
  margin: 0;
}
.fiche-path {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
  margin: 0.25rem 0 0;
}
.fiche-summary {
  font-size: var(--fs-base);
  color: var(--text-soft);
  margin: 0.75rem 0 0;
}
.fiche-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
  padding: 0;
}
.fiche-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--text-faint);
  border: 1px solid var(--rule-on-wood);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
  text-decoration: none;
}
.fiche-tag:hover {
  color: var(--text);
  border-color: var(--mist);
}

.fiche-section {
  margin-bottom: 1.75rem;
  scroll-margin-top: 1.5rem; /* breathing room when jumped to via #anchor */
  border-radius: 4px;
}
.fiche-section.sealed {
  border-left: 2px solid var(--wine-bright);
  padding-left: 1rem;
}

/* Arriving from a search hit: hold the passage lit, then let it settle.
   Background only, so a sealed section keeps its wine border underneath. */
.fiche-section:target {
  animation: fiche-flash 1.6s ease-out;
}
@keyframes fiche-flash {
  0%, 55% { background: color-mix(in oklch, var(--amber) 20%, transparent); }
  100%    { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .fiche-section:target { animation: none; background: color-mix(in oklch, var(--amber) 12%, transparent); }
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  color: var(--text);
  margin: 0;
}

/* ------------------------------------------------------------ seal badge */

.seal-badge {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--wine-glow);
  border: 1px solid var(--wine-bright);
  border-radius: 3px;
  padding: 0.05rem 0.45rem;
  white-space: nowrap;
}

/* -------------------------------------------------------------- markdown */
/* The rendered lore body — plain and legible, no terminal theatrics here. */

.prose { color: var(--text-soft); font-size: var(--fs-base); line-height: 1.7; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 0.85rem; }
.prose h3, .prose h4 {
  font-family: var(--font-serif);
  color: var(--text);
  margin: 1.4rem 0 0.5rem;
}
.prose ul, .prose ol { margin: 0 0 0.85rem; padding-left: 1.4rem; }
.prose li { margin: 0.2rem 0; }
.prose strong { color: var(--text); }
.prose em { color: var(--text); font-style: italic; }
.prose a { color: var(--mist); }
.prose code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--wood-deep);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}
.prose blockquote {
  border-left: 2px solid var(--wood-edge);
  margin: 0 0 0.85rem;
  padding-left: 0.9rem;
  color: var(--text-faint);
  font-style: italic;
}
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1rem;
  font-size: var(--fs-sm);
  display: block;
  overflow-x: auto; /* wide tables scroll instead of breaking the layout */
}
.prose thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--wood-edge);
}
.prose th, .prose td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--rule-on-wood);
  vertical-align: top;
}
/* Keep the first column (year, name, term — a short key in our lore
   tables) on one line so "~An 210–212" doesn't break at the en dash. The
   prose column keeps wrapping; a genuinely wide table scrolls (overflow-x
   above) rather than mangling. */
.prose th:first-child, .prose td:first-child { white-space: nowrap; }
.prose tbody tr:last-child td { border-bottom: none; }
