/* ══════════════════════════════════════════════════════════════════════════
   POSITIONS PAGE (/positions.html)

   The Sniper Desk's positions ticker opened up into its own screen — the same
   relationship /feed.html has to the desk's compact feed preview. Everything
   structural (nav, footer, page head, sell buttons, badges, whale/moon-bag rows,
   the spark chart wrapper) is inherited from style.css + snipe.css; this file only
   adds the summary strip and the card layouts that don't exist anywhere else.
   ══════════════════════════════════════════════════════════════════════════ */

.positions-history-link {
  align-self: center;
}

/* ─── Summary strip ──────────────────────────────────────────────────────── */
/* Unrealized P&L gets the wide first tile because it's the number the page exists
   to answer; the rest are equal-weight context around it. */
.pos-summary {
  display: grid;
  grid-template-columns: 1.4fr repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

@media (max-width: 1180px) {
  .pos-summary { grid-template-columns: repeat(3, 1fr); }
  .pos-stat--hero { grid-column: span 3; }
}

@media (max-width: 620px) {
  .pos-summary { grid-template-columns: repeat(2, 1fr); }
  .pos-stat--hero { grid-column: span 2; }
}

.pos-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  padding: 14px 16px;
  min-width: 0;
}

.pos-stat--hero {
  background:
    linear-gradient(180deg, rgba(var(--safe-rgb), 0.05), transparent 70%),
    var(--card);
}

.pos-stat-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.pos-stat-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 500;
  color: var(--paper);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.pos-stat--hero .pos-stat-value {
  font-size: 28px;
}

/* Sign colouring is applied by renderPositionsSummary(), not by the markup — a value
   that is exactly zero stays neutral rather than being painted green. */
.pos-stat-value.pos { color: var(--safe); }
.pos-stat-value.neg { color: var(--danger); }

.pos-stat-sub {
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  color: var(--ink-dim);
}

/* ─── Section headings ───────────────────────────────────────────────────── */
.positions-section-label {
  margin-bottom: 6px;
}

.positions-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.positions-section-header .positions-section-label {
  margin-bottom: 0;
}

/* Overrides sell-btn's default block/full-width shape (meant for one card) — this one
   sits inline in the section header next to the label instead. */
.sell-btn--all {
  display: inline-block;
  width: auto;
  margin-top: 0;
  padding: 6px 14px;
}

.positions-section-note {
  font-size: 12px;
  color: var(--ink-dim);
  margin: 0 0 12px;
  max-width: 70ch;
}

.pos-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
  margin-bottom: 34px;
}

/* An empty state is a sentence, not a card — it shouldn't be squeezed into one
   column of the grid with dead space beside it. */
.pos-board .sidebar-empty {
  grid-column: 1 / -1;
}

/* ─── Position card ──────────────────────────────────────────────────────── */
.pos-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-left: 3px solid var(--card-edge);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
  transition: border-color 0.15s;
}

/* The left edge carries the position's direction, so a board of ten reads at a glance
   before any number is parsed. */
.pos-card.pos { border-left-color: var(--safe); }
.pos-card.neg { border-left-color: var(--danger); }

.pos-card:hover {
  border-color: var(--card-edge);
  border-left-color: inherit;
}

.pos-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pos-card-id {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pos-card-symbol {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--paper);
}

.pos-card-name {
  font-size: 11.5px;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pos-card-pnl {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.pos-card-pnl-pct {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 19px;
  font-weight: 500;
}

.pos-card.pos .pos-card-pnl-pct { color: var(--safe); }
.pos-card.neg .pos-card-pnl-pct { color: var(--danger); }

.pos-card-pnl-sol {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  color: var(--ink-dim);
}

.pos-card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Empty on most cards (no dry-run tag, no exit risk, no price reading yet) — collapsed
   so it doesn't leave a gap where nothing is drawn. */
.pos-card-badges:empty {
  display: none;
}

.pos-card-tag {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--pin);
  border: 1px solid rgba(var(--pin-rgb), 0.4);
  border-radius: 5px;
  padding: 2px 6px;
}

/* The chart is a button (it opens the full position chart modal), so it has to shed
   every default button style and lay its two children out as a block. */
.pos-card-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  width: 100%;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.pos-card-chart .pnl-spark-wrap {
  width: 100%;
}

.pos-card-chart-hint {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: 'Rajdhani', sans-serif;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  transition: color 0.15s;
}

.pos-card-chart:hover .pnl-spark-wrap {
  border-color: var(--safe);
}

.pos-card-chart:hover .pos-card-chart-hint {
  color: var(--safe);
}

/* Two columns of label→value rows rather than a four-across strip of stacked pairs: a
   meme-coin price runs to nine decimals ($0.000041200), which wraps mid-number in a
   quarter-card column and makes the figure genuinely hard to read. */
.pos-card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 18px;
}

@media (max-width: 460px) {
  .pos-card-grid { grid-template-columns: 1fr; }
}

.pos-card-cell {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  padding-bottom: 4px;
}

.pos-card-cell-label {
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.pos-card-cell-value {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}

/* The whale badge is a pill that brings its own colour — it shouldn't inherit the
   monospace figure styling of the cells around it, and it must not wrap: the pill has a
   background, so a second line breaks out of the cell rather than flowing under it. */
.pos-card-cell-value .cluster-tag {
  font-size: 9.5px;
  white-space: nowrap;
}

/* ─── Armed ("waiting for entry") card ───────────────────────────────────── */
/* Amber and dashed, exactly like the ticker's armed chip — an order that hasn't spent
   anything yet must never read like an open position. */
.armed-pos-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card);
  border: 1px dashed rgba(var(--pin-rgb), 0.45);
  border-radius: 16px;
  padding: 16px;
  min-width: 0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.armed-pos-card:hover {
  border-color: var(--pin);
}

.armed-pos-card.is-urgent {
  border-color: rgba(var(--pin-rgb), 0.9);
}

.armed-pos-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.armed-pos-card-head .ticker-chip-symbol {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--paper);
}

.armed-pos-card-cancel {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  background: none;
  border: 1px solid var(--card-edge);
  border-radius: 6px;
  color: var(--ink-dim);
  cursor: pointer;
}

.armed-pos-card-cancel:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.armed-pos-card-read {
  font-size: 13px;
  color: var(--ink);
}

.armed-pos-card-detail {
  font-size: 11.5px;
  color: var(--ink-dim);
}

.armed-pos-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--ink-dim);
}

/* How much of the wait window is left — the card's version of the chip's countdown arc. */
.armed-pos-card-bar {
  height: 3px;
  border-radius: 3px;
  background: rgba(var(--pin-rgb), 0.15);
  overflow: hidden;
}

.armed-pos-card-bar span {
  display: block;
  height: 100%;
  background: var(--pin);
  transition: width 0.6s linear;
}

/* Overrides .sniper-theme .cancel-arm-btn, which is a full-width block button sized for
   the vertical armed card the ticker replaced — here it's an X in the card's header row,
   so it needs the theme-scoped selector to outrank it. */
.sniper-theme .armed-pos-card-cancel {
  display: inline-flex;
  width: 22px;
  padding: 0;
  margin: 0 0 0 auto;
  font-size: 11px;
  border-radius: 6px;
}

/* ── Command Center ──────────────────────────────────────────────────────────────────
   Reads the same neon-terminal language as the rest of the desk, but the exit STATE and
   ACTION carry the colour, because on this panel those two are what a glance is for. */
.sniper-theme .cc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.sniper-theme .cc-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.02);
}
.sniper-theme .cc-card--stale { opacity: 0.62; border-style: dashed; }
.sniper-theme .cc-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.sniper-theme .cc-symbol { font-family: 'Rajdhani', sans-serif; font-weight: 700; font-size: 17px; }
.sniper-theme .cc-variant {
  font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--ink-dim);
}
.sniper-theme .cc-state {
  margin-left: auto; font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.09em; padding: 3px 8px; border-radius: 5px; border: 1px solid currentColor;
}
.sniper-theme .cc-state--momentum  { color: #4ade80; }
.sniper-theme .cc-state--protect   { color: #5ac8fa; }
.sniper-theme .cc-state--weakening { color: var(--pin); }
.sniper-theme .cc-state--reversal  { color: #ff8a4c; }
.sniper-theme .cc-state--emergency { color: var(--danger); }
.sniper-theme .cc-state--discovery { color: var(--ink-dim); }

.sniper-theme .cc-metrics {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px 10px; margin-bottom: 13px;
}
.sniper-theme .cc-metric { display: flex; flex-direction: column; gap: 2px; }
.sniper-theme .cc-metric-k {
  font-family: 'IBM Plex Mono', monospace; font-size: 9.5px;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--ink-dim);
}
.sniper-theme .cc-metric-v {
  font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.sniper-theme .cc-pos { color: var(--safe); }
.sniper-theme .cc-neg { color: var(--danger); }

.sniper-theme .cc-verdict { border-top: 1px solid var(--line); padding-top: 11px; }
.sniper-theme .cc-verdict-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 7px; }
.sniper-theme .cc-verdict-action {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; font-weight: 700;
  letter-spacing: 0.07em; padding: 3px 8px; border-radius: 5px;
}
.sniper-theme .cc-action--hold         { color: var(--ink-dim); border: 1px solid var(--line); }
.sniper-theme .cc-action--tighten      { color: var(--pin); border: 1px solid var(--pin); }
.sniper-theme .cc-action--partial_exit { color: #5ac8fa; border: 1px solid #5ac8fa; }
.sniper-theme .cc-action--full_exit    { color: var(--danger); border: 1px solid var(--danger); }
.sniper-theme .cc-score, .sniper-theme .cc-trail {
  font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: var(--ink-dim);
}
.sniper-theme .cc-score b { color: var(--ink); }
.sniper-theme .cc-reason { font-size: 13px; color: var(--ink-dim); margin: 0 0 8px; line-height: 1.45; }
.sniper-theme .cc-muted { font-style: italic; }
.sniper-theme .cc-rug {
  font-family: 'IBM Plex Mono', monospace; font-size: 11.5px; color: var(--danger);
  margin: 0 0 8px; padding: 6px 9px; border-radius: 5px;
  background: rgba(var(--danger-rgb), 0.09); border: 1px solid rgba(var(--danger-rgb), 0.3);
}
.sniper-theme .cc-stale-note {
  font-size: 12px; color: var(--pin); margin: 8px 0 0; font-style: italic;
}

/* The score's contributing factors. Present because an exit engine whose reasoning cannot
   be inspected gets switched off the first time it does something surprising. */
.sniper-theme .cc-factors { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.sniper-theme .cc-factor {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: baseline;
  font-family: 'IBM Plex Mono', monospace; font-size: 11px;
}
.sniper-theme .cc-factor-name { color: var(--ink-dim); }
.sniper-theme .cc-factor-detail { color: var(--ink-faint, var(--ink-dim)); opacity: 0.75; }
.sniper-theme .cc-factor-pts { font-variant-numeric: tabular-nums; }
.sniper-theme .cc-factor--risk .cc-factor-pts { color: var(--danger); }
.sniper-theme .cc-factor--good .cc-factor-pts { color: var(--safe); }

.sniper-theme .cc-engine-badge {
  margin-left: 10px; font-family: 'IBM Plex Mono', monospace; font-size: 10px;
  letter-spacing: 0.08em; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--ink-dim);
}
.sniper-theme .cc-engine-badge--live { color: var(--safe); border-color: var(--safe); }

@media (max-width: 560px) {
  .sniper-theme .cc-grid { grid-template-columns: 1fr; }
  .sniper-theme .cc-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* Use the same shared charcoal palette as Discover and the Desk. */
body[data-page="positions"] {
  --card: var(--d-panel);
  --card-edge: var(--d-border);
  --line: var(--d-border);
  --ink: var(--d-text);
  --ink-dim: var(--d-text-2);
  --ink-faint: var(--d-muted);
  background: var(--d-canvas);
  color: var(--d-text);
  font-family: var(--d-font);
}
body[data-page="positions"] .positions-layout { max-width: 1440px; margin-inline: auto; }
body[data-page="positions"].sniper-theme::before { display: none; }
body[data-page="positions"] :is(.feed-page-title, .feed-back-link, .feed-preview-count, .pos-stat-label, .positions-section-label, .pos-card-symbol, .pos-card-name, .pos-card-cell-label, .pos-card-chart-hint, .sidebar-empty, .positions-section-note) {
  font-family: var(--d-font);
  letter-spacing: normal;
  text-transform: none;
}
body[data-page="positions"] .feed-page-title { font-size: 28px; }
body[data-page="positions"] :is(.pos-stat-label, .pos-card-cell-label, .pos-card-chart-hint) { font-size: 13px; }
body[data-page="positions"] .pos-stat--hero { background: var(--d-panel-2); border-color: var(--d-border); }
body[data-page="positions"] .pos-stat { min-width: 0; }
body[data-page="positions"] .pos-stat-value { overflow-wrap: anywhere; }
body[data-page="positions"] :is(.pos-card, .pos-stat) { box-shadow: none; border-radius: 12px; }
body[data-page="positions"] :is(.sell-btn, .partial-sell-btn, .edit-arm-amount-btn, .armed-pos-card-cancel, .feed-back-link) { min-height: 44px; }
body[data-page="positions"] .sell-btn:disabled { opacity: .45; cursor: not-allowed; }
body[data-page="positions"] .sell-btn.hidden { display: none; }
body[data-page="positions"] :is(button, a):focus-visible { outline: 2px solid var(--d-accent); outline-offset: 3px; }
@media (max-width: 620px) {
  body[data-page="positions"] .positions-layout { padding-inline: 12px; }
  body[data-page="positions"] .feed-page-head { flex-wrap: wrap; gap: 12px; }
}
