:root {
  --bg: #050505;
  --fg: #ddd8c9;
  --accent: #a40000;
  --dim: #8c867c;
  --link: #8cb3ff;
  --rail: #0c0c0c;
}

* { box-sizing: border-box; }

html {
  background:
    linear-gradient(rgba(255,255,255,.02), rgba(255,255,255,0)),
    repeating-linear-gradient(0deg, rgba(110, 0, 0, .05) 0 1px, transparent 1px 3px),
    #050505;
}

body {
  margin: 0;
  color: var(--fg);
  font-family: "Courier New", Courier, monospace;
  line-height: 1.45;
  background-image:
    radial-gradient(rgba(180, 0, 0, .06) 1px, transparent 1px),
    radial-gradient(rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 7px 7px, 3px 3px;
  background-position: 0 0, 13px 9px;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,.04) 1px, transparent 1px);
  background-size: 3px 3px;
  mix-blend-mode: soft-light;
  opacity: .16;
}

.container {
  position: relative;
  max-width: 930px;
  margin: 18px auto 40px;
  padding: 16px 18px 28px;
  border-left: 2px solid #262626;
  border-right: 1px dashed #222;
  border-top: 1px solid #1d1d1d;
  border-bottom: 1px solid #1d1d1d;
  background: rgba(8, 8, 8, .93);
  box-shadow: 0 0 0 1px rgba(80,0,0,.15), 0 0 25px rgba(0,0,0,.35);
}

header {
  margin-bottom: 12px;
}

.blinkbar {
  display: inline-block;
  margin: 0 0 10px;
  padding: 2px 8px;
  color: #ffb6b6;
  background: #260000;
  border: 1px dotted #5f1d1d;
  font-size: .82rem;
  letter-spacing: .6px;
}

h1 {
  margin: 2px 0 0;
  color: var(--accent);
  letter-spacing: 2px;
  text-shadow: 1px 0 0 #fff1;
}

.sub {
  color: var(--dim);
  font-size: .92rem;
  margin: 4px 0 3px;
}

.tiny-note, .micro, .stamp {
  color: #8f8a82;
  font-size: .82rem;
}

hr {
  border: 0;
  border-top: 1px dashed #2c2c2c;
  margin: 10px 0 12px;
}

h2, h3 {
  color: #f0ece4;
}

h2 {
  margin-top: 0;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
}

a:hover {
  color: #fff;
}

/* companion render block — cascade-block variant, no longer hero-locked */
.companion-figure {
  margin: 0;
  border: 1px solid #333;
  background: #090909;
  padding: 6px;
}

.companion-figure img {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.08) brightness(.94);
}

.companion-copy p {
  margin: 0 0 10px;
}

/* wanted block — cascade-block variant, preserves poster aesthetic */
.cascade-wanted {
  background: rgba(20, 16, 12, .88);
  color: var(--fg);
  border: 1px dashed #4c4032 !important;
  box-shadow: 0 0 0 1px rgba(80,40,20,.18);
}

.cascade-wanted h3 {
  margin: 0 0 8px;
  color: #efe4d1;
  text-align: left;
  font-size: 1.08rem;
  letter-spacing: .3px;
  text-transform: none;
}

.wanted-figure {
  margin: 0 0 10px;
  padding: 6px;
  border: 1px solid #4b4034;
  background: #0a0a0a;
}

.wanted-figure img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #2b241d;
  filter: contrast(1.05) saturate(.85);
}

.wanted-copy,
.wanted-notes {
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  font-size: .92rem;
  line-height: 1.45;
  color: #ddd8c9;
}

.wanted-copy p,
.wanted-notes p,
.wanted-notes li {
  margin: 0 0 9px;
}

.dossier-block {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px dashed #4c4032;
  font-family: "Courier New", Courier, monospace;
  font-size: .9rem;
  line-height: 1.4;
}

.dossier-block h4 {
  margin: 8px 0 6px;
  color: #efe4d1;
  font-size: .92rem;
  letter-spacing: .3px;
  text-transform: none;
}

.dossier-block p {
  margin: 0 0 7px;
}

.post, .links {
  clear: both;
  border: 1px dashed #313131;
  padding: 12px 13px;
  margin: 14px 0;
  background: rgba(12,12,12,.82);
}

.post {
  width: calc(100% - 4px);
}

.post-skew-1 {
  margin-left: 2px;
  border-left: 3px solid #4a1111;
}

.post-skew-2 {
  margin-left: 18px;
  width: calc(100% - 22px);
  border-right: 2px dotted #5b5b5b;
}

.post-skew-3 {
  margin-left: 7px;
  width: calc(100% - 10px);
  background: rgba(10,10,10,.7);
}

.messy-links {
  border-style: solid dashed dashed solid;
}

.messy-links li:nth-child(odd) {
  margin-left: 6px;
}

/* ── CASCADING POST BLOCKS ─────────────────────────────────────────────── */
/* Used by branch_publish.py for all future posts.                          */
/* Existing posts were hand-assigned on initial conversion.                 */

.cascade-block {
  clear: both;
  position: relative;
  padding: 12px 14px;
  margin: 18px 0;
  border: 1px dashed #313131;
  background: rgba(12,12,12,.82);
}

.cascade-block h2 {
  margin-top: 0;
}

/* Rich card — inline content, full teaser or body visible */
.cascade-rich {
  border-left: 3px solid #4a1111;
}

/* Lean link card — minimal, just label + hyperlink */
.cascade-link {
  background: rgba(7,7,7,.55);
  border-style: solid dashed;
  border-color: #252525 #484848;
}

.cascade-link h2 {
  font-size: .97rem;
  color: #b8b2a5;
  margin: 0 0 5px;
  letter-spacing: .3px;
}

.cascade-link .lean-link {
  font-size: .9rem;
  display: block;
  margin-bottom: 4px;
}

/* Node card — junction page link; marks a branching point */
.cascade-node {
  border-style: dotted;
  border-color: #3a3a3a;
  background: rgba(6,6,6,.5);
}

.cascade-node::after {
  content: "→ node";
  position: absolute;
  top: 9px;
  right: 11px;
  color: #3d3a36;
  font-size: .78rem;
  letter-spacing: .4px;
}

/* ── STAGGER POSITIONS (cp-a … cp-g, cycles for new posts) ────────────── */

.cp-a {
  margin-left: 0;
  width: 93%;
}

.cp-b {
  margin-left: 26px;
  width: 76%;
  border-right: 2px dotted #5b5b5b;
  border-left-color: #2a2a2a;
}

.cp-c {
  margin-left: 9px;
  width: 88%;
  background: rgba(10,10,10,.7);
}

.cp-d {
  margin-left: 44px;
  width: 63%;
  border-left: 2px solid #2a1a1a;
  border-style: dashed dashed dashed solid;
}

.cp-e {
  margin-left: 16px;
  width: 82%;
}

.cp-f {
  margin-left: 0;
  width: 56%;
  border: 1px solid #252525;
  border-left: 3px solid #330000;
  background: rgba(14,8,8,.6);
}

.cp-g {
  margin-left: 36px;
  width: 73%;
  border-style: dashed;
  border-color: #3d3d3d;
}

/* ── ORIENTATION VARIANTS ─────────────────────────────────────────────── */
/* Applied via data-orientation attr; class added by branch_publish.py v2  */

/* Vertical (default): stacked image below text — no extra rules needed    */
.cascade-orient-vertical {
  /* inherits standard cascade-block layout */
}

/* Horizontal: image left, text right, side by side                        */
.cascade-orient-horizontal {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: nowrap;
}

.cascade-orient-horizontal .horiz-media {
  flex: 0 0 220px;
  max-width: 220px;
}

.cascade-orient-horizontal .horiz-media .evidence {
  margin: 0;
}

.cascade-orient-horizontal .horiz-text {
  flex: 1 1 auto;
  min-width: 0;
}

.cascade-orient-horizontal .horiz-text h2 {
  margin-top: 0;
}

/* Horizontal link/node cards keep lean layout — just add a left accent    */
.cascade-orient-horizontal.cascade-link,
.cascade-orient-horizontal.cascade-node {
  border-left: 3px solid #2a2a2a;
}

/* ── LINK CARD THUMBNAIL ──────────────────────────────────────────────── */
/* Rendered when the surface media roll hits on a link/convergence card.   */
/* Hard rule: if roll hits, media MUST be visibly shown on the card.       */
/* If roll misses, .link-thumb is never emitted — no image shown.          */

/* Image-led layout: image fills full card width; text below conforms to
   that width naturally. Card width is set by grid/cp-* class.
   min-width prevents degenerate thumbnails; max-height+cover crops extreme portraits. */
.link-thumb {
  margin: 0 0 10px;
  border: 1px dashed #3a3a3a;
  padding: 6px;
  background: #0a0a0a;
  min-width: 160px;
}

.link-thumb img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  max-height: 520px;
  object-fit: cover;
  object-position: center top;
  background: #060606;
  border: 1px solid #1f1f1f;
  filter: contrast(1.05) brightness(.93);
}

@media (max-width: 580px) {
  .cascade-orient-horizontal {
    flex-direction: column;
  }
  .cascade-orient-horizontal .horiz-media {
    flex: none;
    max-width: 100%;
    width: 100%;
  }
}

/* ── NODE PAGE STYLES ──────────────────────────────────────────────────── */
/* Applied on generated nodes/*.html pages                                  */

.node-shell {
  padding: 14px 16px;
  border: 1px dashed #2e2e2e;
  background: rgba(10,10,10,.75);
  margin: 16px 0;
}

.node-shell .node-label {
  color: #5a5650;
  font-size: .8rem;
  margin: 0 0 10px;
  letter-spacing: .5px;
}

.node-threads {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-top: 1px dashed #2c2c2c;
  background: rgba(6,6,6,.4);
}

.node-threads h4 {
  margin: 0 0 8px;
  color: #6a6560;
  font-size: .88rem;
  letter-spacing: .3px;
}

.node-threads ul {
  margin: 0;
  padding-left: 16px;
}

.node-threads li {
  margin: 0 0 6px;
  font-size: .92rem;
}

.branch-depth-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 5px;
  background: #181818;
  border: 1px dotted #333;
  color: #565250;
  font-size: .75rem;
  vertical-align: middle;
}

marquee {
  color: #ff4e4e;
  border-top: 1px solid #2a2a2a;
  border-bottom: 1px solid #2a2a2a;
  padding: 6px 0;
  background: rgba(25, 0, 0, .22);
}

.evidence {
  margin: 14px 0;
  border: 1px dashed #3a3a3a;
  padding: 8px;
  background: #0a0a0a;
}

.evidence img {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid #1f1f1f;
}

.evidence figcaption {
  margin-top: 6px;
  color: #9a9a9a;
  font-size: .85rem;
}

@media (max-width: 780px) {
  .post-skew-2,
  .post-skew-3,
  .post-skew-1 {
    width: 100%;
    margin-left: 0;
  }
}

/* ── INLINE PROSE LINKS (Phase 1 inline-link branching) ─────────────── */
/* Hard rule: inline links inside generated body text must be UNMISTAKABLE. */
/* High-contrast amber/gold colour on dark background + thick underline.    */
/* Visible on mobile, keyboard-focusable, WCAG AA contrast on dark bg.     */

.wire-body a.wire-inline-link,
.wire-inline-link {
  color: #f5c842;                /* bright amber — max contrast on dark bg */
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
  font-weight: bold;
  letter-spacing: .03em;
  border-bottom: 1px solid rgba(245, 200, 66, 0.45);
  padding: 0 1px;
  transition: color .12s, background .12s, border-color .12s;
}

.wire-body a.wire-inline-link:hover,
.wire-body a.wire-inline-link:focus,
.wire-inline-link:hover,
.wire-inline-link:focus {
  color: #fff;
  background: rgba(245, 200, 66, 0.22);
  border-color: #f5c842;
  text-decoration-color: #fff;
  outline: none;
}

/* small "↗ inline" marker after the link — scannable, obvious */
.wire-body a.wire-inline-link::after,
.wire-inline-link::after {
  content: ' ↗';
  font-size: .78em;
  opacity: .7;
  font-weight: normal;
}

/* ── Nav affordances (v7 up/down/home) ───────────────────────────────── */
.nav-up, .nav-down, .nav-home {
  margin: 4px 0;
  font-size: .85rem;
}

.nav-up a, .nav-down a, .nav-home a {
  color: #7c7570;
  text-decoration: none;
  letter-spacing: .5px;
}

.nav-up a:hover, .nav-down a:hover, .nav-home a:hover {
  color: var(--link);
}

.nav-up::before  { content: ''; }
.nav-down::before { content: ''; }

/* ═══════════════════════════════════════════════════════════════════════
   COLLAGE LAYOUT — full-width staggered grid on large screens
   Mobile stays: linear readable stack (< 900px — no changes).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Expand container edge-to-edge on desktop ─────────────────────────── */
@media (min-width: 900px) {
  .container {
    max-width: none;
    width: calc(100% - 28px);
    margin: 18px 14px 40px;
  }
}

@media (min-width: 1400px) {
  .container {
    margin: 18px 20px 40px;
    width: calc(100% - 40px);
  }
}

/* ── The collage grid wrapper ─────────────────────────────────────────── */
.cascade-feed {
  /* Mobile: plain block flow */
  display: block;
}

@media (min-width: 900px) {
  .cascade-feed {
    display: grid;
    /* 12 equal-width columns; content spreads the full container */
    grid-template-columns: repeat(12, 1fr);
    column-gap: 14px;
    row-gap: 0;             /* vertical spacing handled per-card via margin */
    align-items: start;     /* cards don't stretch to fill row — each is own height */
  }

  /* By default every cascade-block takes full 12 cols (fallback / override by cp-*) */
  .cascade-feed .cascade-block {
    grid-column: span 12;
    margin-left: 0;
    width: auto;           /* let grid control sizing, not legacy % widths */
  }

  /* ── cp-* → grid span + stagger offset ─────────────────────────────── */
  /* Spans are deliberately uneven (5,7,8,6,9,4,10) to create imperfect fill.
     margin-top stagger offsets give the 'cards trying to fit but off-beat' feel.
     No two adjacent classes should look the same.                          */

  .cascade-feed .cp-a {
    grid-column: span 7;
    margin-top: 0;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-b {
    grid-column: span 5;
    margin-top: 22px;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-c {
    grid-column: span 8;
    margin-top: 10px;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-d {
    grid-column: span 6;
    margin-top: 30px;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-e {
    grid-column: span 9;
    margin-top: 6px;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-f {
    grid-column: span 4;
    margin-top: 18px;
    margin-left: 0;
    width: auto;
  }

  .cascade-feed .cp-g {
    grid-column: span 10;
    margin-top: 14px;
    margin-left: 0;
    width: auto;
  }

  /* ── Horizontal orientation cards need extra minimum width on grid ──── */
  .cascade-feed .cascade-orient-horizontal {
    min-width: 0;   /* allow flex children to shrink inside grid cell */
  }

  /* ── Wanted + companion pinned sections: span more for visual weight ── */
  .cascade-feed .cascade-wanted {
    grid-column: span 5;
    margin-top: 8px;
    width: auto;
    margin-left: 0;
  }

  /* companion render: wide card to anchor the collage */
  .cascade-feed [data-entry="companion-render"] {
    grid-column: span 7;
    margin-top: 20px;
  }
}

/* ── Ultra-wide (>1600px): tighten column gap for denser feel ─────────── */
@media (min-width: 1600px) {
  .cascade-feed {
    column-gap: 18px;
  }
}

/* ── Mobile: strip grid artefacts, restore original stagger classes ────── */
@media (max-width: 899px) {
  .cascade-feed .cascade-block,
  .cascade-feed .cp-a,
  .cascade-feed .cp-b,
  .cascade-feed .cp-c,
  .cascade-feed .cp-d,
  .cascade-feed .cp-e,
  .cascade-feed .cp-f,
  .cascade-feed .cp-g {
    /* restore original margin/width behaviour for mobile */
    grid-column: unset;
    margin-top: 0;
  }
  /* restore legacy cp-* offsets on mobile for slight visual variety */
  .cascade-feed .cp-b { margin-left: 26px; width: calc(100% - 30px); }
  .cascade-feed .cp-d { margin-left: 24px; width: calc(100% - 28px); }
  .cascade-feed .cp-g { margin-left: 18px; width: calc(100% - 22px); }
}
