/* V2 — "Codex": editorial / HUD mag-style */

.v2-root {
  --ink: #e5e7eb;
  --ink-dim: rgba(255,255,255,0.62);
  --ink-mute: rgba(255,255,255,0.38);
  --line: rgba(255,255,255,0.08);
  --line-2: rgba(255,255,255,0.16);
  --bg-card: rgba(255,255,255,0.02);
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  background: var(--bg);
  color: var(--ink);
  font-family: "Lexend", sans-serif;
  position: relative;
  padding: 48px 56px 80px;
  min-height: 100%;
  overflow: hidden;
  transition: background 600ms ease, color 600ms ease;
}
.v2-root[data-density="compact"] { padding: 36px 40px 60px; }
.v2-root * { box-sizing: border-box; }

/* Subtle scanline + glow bg */
.v2-bg { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.v2-bg-glow {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  width: 900px; height: 900px;
  background: radial-gradient(circle, var(--accent-soft), transparent 70%);
  filter: blur(80px); opacity: 0.4;
}
.v2-bg-scan {
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(
    180deg, transparent, transparent 3px, rgba(255,255,255,0.012) 3px, rgba(255,255,255,0.012) 4px
  );
  opacity: 0.6;
}

/* HUD frame */
.v2-hud-frame {
  position: absolute; inset: 24px; pointer-events: none;
  z-index: 1;
}
.v2-hud-corner { position: absolute; width: 18px; height: 18px; }
.v2-hud-corner span { position: absolute; background: var(--accent); display: block; }
.v2-hud-corner span:nth-child(1) { left: 0; top: 0; width: 18px; height: 1px; }
.v2-hud-corner span:nth-child(2) { left: 0; top: 0; width: 1px; height: 18px; }
.v2-hud-corner.tl { top: 0; left: 0; }
.v2-hud-corner.tr { top: 0; right: 0; transform: scaleX(-1); }
.v2-hud-corner.bl { bottom: 0; left: 0; transform: scaleY(-1); }
.v2-hud-corner.br { bottom: 0; right: 0; transform: scale(-1, -1); }
.v2-hud-side {
  position: absolute;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.32em;
  color: var(--accent); opacity: 0.6;
  writing-mode: vertical-rl; text-orientation: mixed;
}
.v2-hud-side.left { left: 8px; top: 50%; transform: translateY(-50%) rotate(180deg); }
.v2-hud-side.right { right: 8px; top: 50%; transform: translateY(-50%); }

/* === MASTHEAD === */
.v2-cover {
  position: relative;
  z-index: 2;
}
.v2-mast {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.v2-mast-num {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.4em;
  color: var(--ink);
}
.v2-mast-mono {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.22em; color: var(--ink-mute);
  text-transform: lowercase; margin-bottom: 4px;
}
.v2-mast-mid {
  text-align: center;
  display: flex; flex-direction: column; gap: 2px;
}
.v2-mast-coord {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.15em; color: var(--ink-mute);
}
.v2-mast-right { display: flex; justify-content: flex-end; }

.v2-search {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 0;
  background: rgba(0,0,0,0.4);
  width: 320px;
}
.v2-search-lbl {
  font-family: var(--mono); font-size: 10px;
  color: var(--accent); letter-spacing: 0.16em;
}
.v2-search input {
  flex: 1; background: transparent; border: 0; outline: 0;
  color: var(--ink); font-size: 12px; font-family: inherit;
  padding: 0; min-width: 0; line-height: 1;
}
.v2-search input::placeholder { color: var(--ink-mute); }
.v2-search-pop {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--bg-soft);
  border: 1px solid var(--line-2);
  z-index: 30;
}
.v2-search-row {
  display: flex; gap: 14px; align-items: baseline;
  padding: 8px 12px; font-size: 12px;
  border-bottom: 1px solid var(--line);
}
.v2-search-row:last-child { border-bottom: 0; }
.v2-search-kind {
  font-family: var(--mono); font-size: 10px;
  color: var(--accent); letter-spacing: 0.1em; min-width: 60px;
}
.v2-search-name { color: var(--ink); }

/* === COVER BODY === */
.v2-cover-body { padding-top: 32px; }
.v2-cover-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  color: var(--ink-dim); margin-bottom: 32px;
}
.v2-tick {
  display: inline-block; width: 18px; height: 1px;
  background: var(--accent); position: relative;
}
.v2-tick::before {
  content: ''; position: absolute; left: 0; top: -3px;
  width: 6px; height: 7px; background: var(--accent);
}

.v2-cover-title {
  margin: 0;
  font-size: clamp(56px, 8vw, 124px);
  font-weight: 200;
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--ink);
}
.v2-title-line { display: block; }
.v2-title-1 { font-style: italic; font-weight: 200; }
.v2-title-2 { font-weight: 500; }
.v2-title-3 { font-weight: 300; font-style: italic; }
.v2-title-3 i { font-style: italic; font-weight: 400; }

.v2-cover-grid {
  display: grid; grid-template-columns: 1.2fr 1fr;
  gap: 64px;
  margin-top: 64px;
  padding-top: 40px;
  border-top: 1px solid var(--line);
}

.v2-cover-lede {
  position: relative;
  padding-left: 32px;
}
.v2-block-num {
  position: absolute; left: 0; top: 0;
  font-family: var(--mono); font-size: 11px;
  color: var(--accent); letter-spacing: 0.16em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.v2-cover-lede p {
  font-size: 18px; line-height: 1.6; font-weight: 200;
  color: var(--ink-dim);
  margin: 0 0 28px;
  max-width: 480px;
}
.v2-cover-quote {
  position: relative;
  font-style: italic;
  font-size: 24px; line-height: 1.4;
  color: var(--ink); font-weight: 300;
  padding: 18px 24px;
  border-top: 1px solid var(--accent-soft);
  border-bottom: 1px solid var(--accent-soft);
  max-width: 480px;
}
.v2-q-open, .v2-q-close {
  font-family: Georgia, serif; font-style: normal;
  font-size: 40px; color: var(--accent); vertical-align: -10px;
}
.v2-q-close { vertical-align: -20px; }

/* faction stack */
.v2-cover-faction-col { padding-top: 4px; }
.v2-faction-stack { display: flex; flex-direction: column; gap: 1px; }
.v2-faction-card {
  appearance: none; border: 0;
  display: grid;
  grid-template-columns: 38px 48px 1fr auto;
  align-items: center; gap: 14px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.015);
  cursor: pointer; text-align: left;
  color: var(--ink);
  font-family: inherit;
  border-left: 2px solid transparent;
  transition: border-color 200ms, background 200ms, transform 200ms;
}
.v2-faction-card:hover {
  background: rgba(255,255,255,0.04);
  transform: translateX(4px);
}
.v2-faction-card[data-active="true"] {
  border-left-color: var(--c);
  background: color-mix(in srgb, var(--c) 8%, transparent);
}
.v2-faction-num {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; color: var(--ink-mute);
}
.v2-faction-card[data-active="true"] .v2-faction-num { color: var(--c); }
.v2-faction-card img { width: 48px; height: 48px; object-fit: contain; opacity: 0.7; }
.v2-faction-card[data-active="true"] img {
  opacity: 1;
  filter: drop-shadow(0 0 12px var(--accent-soft));
}
.v2-faction-name { font-size: 16px; font-weight: 400; color: var(--ink); }
.v2-faction-short {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; color: var(--ink-mute); margin-top: 2px;
}
.v2-faction-eco {
  font-family: var(--mono);
  text-align: right; font-size: 18px; font-weight: 300;
  color: #f87171;
  display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1;
}
.v2-faction-eco[data-pos="true"] { color: var(--c); }
.v2-faction-eco span {
  font-size: 9px; letter-spacing: 0.16em; color: var(--ink-mute); margin-top: 4px;
}

/* cover stat strip */
.v2-cover-strip {
  margin-top: 48px;
  display: grid; grid-template-columns: repeat(5, 1fr);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.v2-strip {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}
.v2-strip:last-child { border-right: 0; }
.v2-strip-l {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.2em; color: var(--ink-mute);
  text-transform: uppercase; margin-bottom: 10px;
}
.v2-strip-v {
  font-size: 24px; font-weight: 300; color: var(--ink);
  line-height: 1; font-variant-numeric: tabular-nums;
}
.v2-strip-v.mono { font-family: var(--mono); font-size: 13px; letter-spacing: 0.05em; }
.v2-strip-s {
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); margin-top: 8px; letter-spacing: 0.08em;
}

/* === SECTION HEADS === */
.v2-section { margin-top: 96px; position: relative; z-index: 2; }
.v2-sec-head {
  display: flex; gap: 24px; align-items: baseline;
  padding-bottom: 24px; margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.v2-sec-num {
  font-family: var(--mono); font-size: 13px;
  letter-spacing: 0.16em; color: var(--accent);
  min-width: 80px;
}
.v2-sec-title {
  margin: 0;
  font-size: 40px; font-weight: 300;
  letter-spacing: -0.02em; color: var(--ink);
  font-style: italic;
}
.v2-sec-sub {
  font-size: 13px; color: var(--ink-mute);
  margin-top: 8px; max-width: 540px;
}

/* === BALANCE === */
.v2-balance {
  display: grid; grid-template-columns: 1fr 240px 1fr;
  gap: 40px; align-items: center;
  padding: 40px 32px;
  border: 1px solid var(--line);
  background: var(--bg-card);
}
.v2-balance-col {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px;
}
.v2-balance-lbl {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; color: var(--ink-mute);
  text-transform: uppercase;
}
.v2-balance-num {
  font-size: 48px; font-weight: 200;
  color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.v2-balance-industry .v2-balance-num { color: #f87171; }
.v2-balance-nature .v2-balance-num { color: var(--accent); }

.v2-bar {
  display: flex; gap: 3px; width: 100%; max-width: 300px;
  height: 28px;
}
.v2-bar.mirror { transform: scaleX(-1); }
.v2-bar-cell {
  flex: 1; transition: background 300ms ease;
}

.v2-balance-fulcrum {
  position: relative; width: 240px; height: 240px;
}
.v2-balance-net {
  position: absolute; left: 50%; bottom: -8px;
  transform: translateX(-50%);
  text-align: center;
  font-family: var(--mono);
}
.v2-balance-net-lbl {
  display: block; font-size: 9px;
  letter-spacing: 0.16em; color: var(--ink-mute);
}
.v2-balance-net-num {
  font-size: 22px; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.v2-balance-net-num[data-pos="true"] { color: var(--accent); }
.v2-balance-net-num[data-neg="true"] { color: #f87171; }

.v2-balance-stats {
  margin-top: 24px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.v2-stat {
  background: var(--bg);
  padding: 18px 20px;
}
.v2-stat-l {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.2em; color: var(--ink-mute);
  text-transform: uppercase; margin-bottom: 12px;
}
.v2-stat-v {
  font-size: 22px; color: var(--ink); font-weight: 300;
  font-variant-numeric: tabular-nums;
}
.v2-stat-h {
  font-size: 11px; color: var(--ink-mute);
  margin-top: 6px; font-style: italic;
}

/* === BUILDING DECK === */
.v2-deck {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.v2-root[data-density="compact"] .v2-deck { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.v2-plate {
  position: relative;
  aspect-ratio: 1;
  perspective: 1200px;
  background: var(--bg);
}
.v2-plate-idx {
  position: absolute; top: 10px; left: 12px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.16em; color: var(--ink-mute);
  z-index: 2;
}
.v2-plate-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 600ms cubic-bezier(.5, 1.6, .5, 1);
  transform-style: preserve-3d;
}
.v2-plate.is-flipped .v2-plate-inner { transform: rotateY(180deg); }
.v2-plate-front, .v2-plate-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  padding: 24px 20px 18px;
  display: flex; flex-direction: column;
  background: var(--bg);
}
.v2-plate-back { transform: rotateY(180deg); }

.v2-plate-front img {
  width: 56px; height: 56px; object-fit: contain;
  filter: drop-shadow(0 0 12px var(--accent-soft));
  margin-bottom: auto;
}
.v2-plate-tier {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.18em; color: var(--accent);
  margin-bottom: 6px;
}
.v2-plate-name {
  font-size: 18px; font-weight: 300;
  color: var(--ink); margin: 0 0 14px;
  letter-spacing: -0.01em; line-height: 1.15;
  font-style: italic;
}
.v2-plate-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.v2-plate-grid > div {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink); font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; gap: 4px;
}
.v2-plate-grid > div span {
  font-size: 9px; color: var(--ink-mute);
  letter-spacing: 0.12em; text-transform: uppercase;
}
.v2-plate-grid > div[data-pos="true"] { color: var(--accent); }
.v2-plate-grid > div[data-pos="false"] { color: #f5a78c; }

.v2-plate-back-head {
  font-size: 14px; font-weight: 400; color: var(--ink);
  padding-bottom: 10px; border-bottom: 1px solid var(--line);
  margin-bottom: 12px; font-style: italic;
}
.v2-plate-io {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; flex: 1;
}
.v2-plate-io-l {
  font-family: var(--mono); font-size: 9px;
  letter-spacing: 0.18em; color: var(--accent);
  margin-bottom: 6px; text-transform: uppercase;
}
.v2-plate-io-row {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ink-dim);
  padding: 2px 0;
}
.v2-plate-io-row img { width: 18px; height: 18px; object-fit: contain; }
.v2-plate-io-empty { font-size: 11px; color: var(--ink-mute); }
.v2-plate-counter {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 10px;
  padding: 6px; border: 1px solid var(--line);
}
.v2-plate-counter button {
  appearance: none; border: 0;
  width: 28px; height: 28px;
  background: transparent;
  color: var(--ink); cursor: pointer;
  font-family: inherit; font-size: 14px;
}
.v2-plate-counter button:hover { background: var(--accent-soft); color: var(--accent); }
.v2-plate-counter span {
  font-family: var(--mono); font-size: 14px;
  color: var(--ink); font-variant-numeric: tabular-nums;
}

/* === CHAIN === */
.v2-chain {
  position: relative;
  height: 520px;
  border: 1px solid var(--line);
  background: var(--bg);
  overflow: hidden;
  cursor: grab;
}
.v2-chain-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at center, black, transparent 90%);
}
.v2-chain-coords {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; gap: 16px;
  font-family: var(--mono); font-size: 10px;
  color: var(--accent); letter-spacing: 0.12em;
  pointer-events: none;
  background: var(--bg);
  padding: 6px 10px;
  border: 1px solid var(--line);
}
.v2-chain-svg {
  width: 100%; height: 100%;
  transition: transform 80ms ease-out;
}

/* === DOSSIERS === */
.v2-dossiers {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--line); border: 1px solid var(--line);
}
.v2-root[data-density="compact"] .v2-dossiers { grid-template-columns: repeat(3, 1fr); }
.v2-dossier {
  background: var(--bg);
  padding: 24px;
  display: grid; grid-template-columns: 110px 1fr;
  gap: 24px;
}
.v2-dossier-idx {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.2em; color: var(--ink-mute);
  margin-bottom: 10px;
}
.v2-dossier-portrait {
  width: 100px; height: 100px;
  background: var(--bg-soft) center / cover no-repeat;
  border: 1px solid var(--accent-soft);
}
.v2-dossier-name {
  font-size: 22px; font-weight: 300;
  color: var(--ink); letter-spacing: -0.01em;
}
.v2-dossier-role {
  font-style: italic; color: var(--accent);
  font-size: 14px; margin-top: 4px;
}
.v2-dossier-meta {
  margin-top: 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.v2-dossier-meta span {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.14em; color: var(--ink-mute);
}
.v2-dossier-tags {
  display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap;
}
.v2-dossier-tags span {
  font-family: var(--mono); font-size: 10px;
  padding: 4px 8px; border: 1px solid var(--line-2);
  color: var(--ink-dim); letter-spacing: 0.1em;
}

/* === FOOT === */
.v2-foot {
  margin-top: 96px; padding-top: 24px;
  display: flex; justify-content: space-between;
  border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px;
  color: var(--ink-mute); letter-spacing: 0.2em;
}
