/* Consensus — sharp data-journalism: editorial type, one accent, data-forward. */

:root {
  --paper: #f6f5f1;
  --card: #ffffff;
  --ink: #16202b;
  --muted: #6b7280;
  --line: #e4e2da;
  --accent: #1e3a5f;
  --accent-soft: #eef2f7;
  --gold: #b0821f;          /* editorial accent — Alaska warm, no party clash */
  --pos: #2f6b3a;
  --neg: #8a3324;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }

/* header */
.site-header {
  background: var(--accent);
  color: #fff;
  border-bottom: 3px solid #16293f;
}
.header-row {
  display: flex; align-items: center; gap: 1.5rem; min-height: 3.4rem;
  flex-wrap: wrap; padding-top: .4rem; padding-bottom: .4rem;
}
.wordmark {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: .01em;
  font-size: 1.28rem;
  color: #fff;
  font-weight: 700;
}
.wordmark:hover { text-decoration: none; }
.wm-mark { flex: 0 0 auto; display: block; }
.tagline {
  align-self: center; color: #9fb0c4; font-size: .68rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase;
  padding-left: .85rem; border-left: 1px solid rgba(255,255,255,.22);
}
.nav-toggle { display: none; }
.site-header nav { display: flex; gap: 1.1rem; flex: 1; }
.site-header nav a { color: #d8e1ec; font-size: .95rem; }
.site-header nav a:hover { color: #fff; text-decoration: none; }
.header-user { display: flex; align-items: center; gap: .9rem; }
.header-user a { color: #d8e1ec; font-size: .95rem; }
.user-chip {
  background: rgba(255,255,255,.12);
  padding: .25rem .7rem;
  border-radius: 999px;
  color: #fff !important;
  font-variant-numeric: tabular-nums;
}

/* layout basics */
main { flex: 1 0 auto; }
/* <main> also carries class .wrap, whose `padding: 0 1.25rem` shorthand
   outranks a plain `main` selector on specificity — so a `main { padding }`
   rule silently loses and top padding falls back to 0. Vertical padding MUST
   be set at >= .wrap specificity. (This regressed the header gap 3x.) */
main.wrap { padding-top: 3.25rem; padding-bottom: 3.5rem; }
h1 { font-family: Georgia, serif; font-size: 1.7rem; margin: 0 0 .3rem; }
h2 { font-family: Georgia, serif; font-size: 1.2rem; margin: 2rem 0 .7rem; }
h3 { font-size: 1rem; margin: 1.4rem 0 .5rem; }
.page-head { margin-bottom: 1.4rem; }
.lede { color: var(--muted); margin: .2rem 0 0; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .84rem; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }

/* flashes & notices */
.flash {
  padding: .6rem .9rem; border-radius: 6px; margin-bottom: .9rem;
  border: 1px solid var(--line); background: var(--card); font-size: .95rem;
}
.flash-ok { border-left: 4px solid var(--pos); }
.flash-err { border-left: 4px solid var(--neg); }
.notice {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 8px; padding: .9rem 1.1rem; margin-bottom: 1.2rem;
}
.notice-resolved { border-left: 4px solid var(--pos); }
.notice-voided { border-left: 4px solid var(--neg); }

/* chips */
.chip {
  display: inline-block; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .07em; padding: .12rem .55rem; border-radius: 999px;
  vertical-align: middle;
}
.chip-open { background: #e5efe7; color: var(--pos); }
.chip-closed, .chip-draft { background: #efece3; color: #7a6a33; }
.chip-resolved { background: var(--accent-soft); color: var(--accent); }
.chip-voided { background: #f6e8e3; color: var(--neg); }

/* Alaska Landmine partnership byline — navy pill so the white logo reads */
.partner-byline {
  display: inline-flex; align-items: center; gap: .8rem; margin-top: 1rem;
  background: var(--accent); border-radius: 8px; padding: .5rem .95rem;
  color: #c3cedb; font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em;
}
.partner-byline:hover { text-decoration: none; box-shadow: 0 2px 10px rgba(22,32,43,.14); }
.partner-byline img { display: block; height: 22px; width: auto; }

/* section headers: small-caps label + editorial rule line */
.section-head {
  display: flex; align-items: center; gap: .85rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .15em; color: var(--muted);
  margin: 2.4rem 0 1.1rem;
}
.section-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* market cards */
.market-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr));
  gap: 1.1rem; align-items: stretch;
}
.market-card {
  display: flex; flex-direction: column; height: 100%; position: relative;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 6px; padding: 1.15rem 1.3rem 1.1rem; color: var(--ink);
  transition: box-shadow .14s, transform .14s, border-color .14s;
}
/* thin editorial accent rail that lights up on hover */
.market-card::before {
  content: ""; position: absolute; left: -1px; top: 1.15rem; bottom: 1.15rem;
  width: 3px; border-radius: 3px; background: transparent; transition: background .14s;
}
.market-card:hover {
  text-decoration: none; box-shadow: 0 6px 22px rgba(22,32,43,.10);
  transform: translateY(-2px); border-color: #d0cdc2;
}
.market-card:hover::before { background: var(--gold); }
.market-card-title {
  font-family: Georgia, "Times New Roman", serif; font-weight: 700;
  font-size: 1.16rem; line-height: 1.3; letter-spacing: -.01em;
  margin-bottom: 1.05rem; color: var(--ink);
}
.market-card-prices { display: flex; flex-direction: column; gap: .5rem; }
/* margin-top:auto pins the meta line to the card bottom, so it lands in the
   same place whether the card has 2 outcomes or 5. */
.market-card-meta {
  display: flex; justify-content: space-between; gap: .5rem; align-items: baseline;
  color: var(--muted); font-size: .82rem; margin-top: auto; padding-top: 1.1rem;
}

/* price rows: label + % on one line, bar as a full-width underline below —
   data-forward and never truncates the candidate name */
.price-row {
  display: grid; grid-template-columns: 1fr auto;
  grid-template-areas: "label value" "bar bar";
  align-items: baseline; gap: .25rem .7rem;
}
/* the frontrunner (first row, since rows are sorted by probability) reads bold;
   trailing outcomes recede — the data-journalism "who's ahead" move */
.price-row.lead .price-label { font-weight: 600; color: var(--ink); }
.price-row.lead .price-value { color: var(--ink); }
.price-row:not(.lead) .price-value { color: #5a6570; }
.price-label {
  grid-area: label; font-size: .92rem; min-width: 0; color: #35404d;
  display: flex; align-items: center;
}
.price-bar-track {
  grid-area: bar; height: 6px; background: #edeae1; border-radius: 4px;
  overflow: hidden;
}
.price-bar-track.wide {
  display: inline-block; width: 140px; margin-right: .7rem; vertical-align: middle;
}
.price-bar { display: block; height: 100%; border-radius: 4px; transition: width .3s ease; }
.price-value {
  grid-area: value; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em;
}
.price-more { color: var(--muted); font-size: .8rem; margin-top: .1rem; }
.swatch {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: .45rem; vertical-align: middle; flex: 0 0 auto;
}

/* market page */
.market-meta { display: flex; align-items: center; gap: .9rem; color: var(--muted);
  font-size: .9rem; flex-wrap: wrap; }
.market-columns { display: grid; grid-template-columns: 1fr 300px; gap: 1.6rem; }
@media (max-width: 820px) {
  /* minmax(0,1fr) + min-width:0 let wide children (tables) scroll internally
     instead of forcing the whole page wider than the viewport. */
  .market-columns { grid-template-columns: minmax(0, 1fr); }
  .market-main, .market-side { min-width: 0; }
}

.outcomes-table, .data-table {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  font-size: .93rem;
}
.outcomes-table th, .outcomes-table td,
.data-table th, .data-table td {
  padding: .55rem .8rem; border-bottom: 1px solid var(--line); text-align: left;
}
.outcomes-table tr:last-child td, .data-table tr:last-child td { border-bottom: 0; }
.outcomes-table thead th, .data-table thead th {
  background: var(--accent-soft); font-size: .78rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent);
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* price chart (interactive, static/chart.js) */
.chart-block { margin-top: 1.2rem; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.1rem 1.2rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; margin-bottom: .7rem; }
.chart-legend .lg { display: flex; align-items: center; gap: .45rem; font-size: .86rem; }
.chart-legend .lg .sw { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.chart-legend .lg .lgval { font-variant-numeric: tabular-nums; font-weight: 600; }
.chart-wrap { position: relative; }
.price-chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.price-chart-svg .gridline { stroke: var(--line); stroke-width: 1; }
.price-chart-svg .axis-label { fill: var(--muted); font-size: 11px; }
.price-chart-svg .series-line { fill: none; stroke-width: 2.25;
  stroke-linejoin: round; stroke-linecap: round; }
.price-chart-svg .crosshair { stroke: var(--muted); stroke-width: 1;
  stroke-dasharray: 3 3; }
.price-chart-svg .hoverdot { stroke: #fff; stroke-width: 1.5; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; top: 8px;
  background: #14181d; color: #f3f4f6; border-radius: 6px; padding: .5rem .6rem;
  font-size: .78rem; line-height: 1.5; box-shadow: 0 4px 14px rgba(0,0,0,.25);
  white-space: nowrap; opacity: 0; transition: opacity .08s;
}
.chart-tip .tt-date { color: #aab3bf; margin-bottom: .3rem; font-size: .72rem; }
.chart-tip .tt-row { display: flex; align-items: center; gap: .45rem; }
.chart-tip .tt-row .sw { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.chart-tip .tt-row .tt-val { margin-left: 1.1rem; font-variant-numeric: tabular-nums;
  font-weight: 600; }

.resolution-block {
  margin-top: 1.3rem; background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--accent); border-radius: 8px; padding: .9rem 1.1rem;
}
.resolution-block h3 { margin-top: 0; }
.resolution-block p { margin: .4rem 0; font-size: .93rem; }

/* trade panel */
.trade-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.1rem; position: sticky; top: 1rem;
}
.trade-panel h3 { margin: .2rem 0 .6rem; }

/* trade ticket */
.ticket-tabs { display: flex; gap: .25rem; background: var(--accent-soft);
  padding: .25rem; border-radius: 8px; margin-bottom: 1rem; }
.ticket-tab { flex: 1; padding: .45rem; border: 0; background: transparent;
  border-radius: 6px; font: inherit; font-weight: 600; color: var(--muted);
  cursor: pointer; }
.ticket-tab.is-active { background: var(--card); color: var(--ink);
  box-shadow: 0 1px 3px rgba(28,39,51,.10); }

.ticket-outcomes { display: grid; gap: .5rem; margin-bottom: 1rem; }
.ticket-outcomes.is-binary { grid-template-columns: 1fr 1fr; }
.outcome-btn { display: flex; flex-direction: column; align-items: flex-start;
  gap: .1rem; padding: .55rem .7rem; border: 1.5px solid var(--line);
  border-radius: 9px; background: var(--card); cursor: pointer; font: inherit;
  text-align: left; transition: border-color .1s, background .1s, box-shadow .1s; }
.outcome-btn:hover:not([disabled]) { border-color: var(--oc); }
.outcome-btn.is-selected { border-color: var(--oc);
  background: color-mix(in srgb, var(--oc) 8%, #fff);
  box-shadow: inset 0 0 0 1px var(--oc); }
.outcome-btn[disabled] { opacity: .45; cursor: not-allowed; }
.ob-label { font-weight: 600; font-size: .9rem; }
.ob-price { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums;
  color: var(--oc); }
.ob-held { font-size: .72rem; color: var(--muted); }

.ticket-amount { margin-bottom: 1rem; }
.ticket-amount label { display: block; font-size: .85rem; color: var(--muted);
  margin-bottom: .35rem; }
#amt { width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; font-size: 1.05rem;
  font-variant-numeric: tabular-nums; }
.amount-chips { display: flex; gap: .4rem; margin-top: .5rem; flex-wrap: wrap; }
.amount-chips button { padding: .3rem .65rem; border: 1px solid var(--line);
  border-radius: 999px; background: var(--card); color: var(--ink); cursor: pointer;
  font-size: .82rem; }
.amount-chips button:hover { border-color: var(--accent); }

.ticket-preview { background: var(--accent-soft); border-radius: 9px;
  padding: .6rem .8rem; margin-bottom: .8rem; }
.pv-row { display: flex; justify-content: space-between; align-items: baseline;
  padding: .18rem 0; font-size: .88rem; }
.pv-row span { color: var(--muted); }
.pv-row strong { font-variant-numeric: tabular-nums; }
.ticket-msg { min-height: 1.1em; color: var(--neg); margin-bottom: .6rem; }
.ticket-msg:empty { min-height: 0; margin: 0; }

.btn-block { width: 100%; display: block; padding: .65rem; font-size: 1rem; }
.btn:disabled { background: #b8c0cb; cursor: not-allowed; }

/* buttons & forms */
.btn {
  display: inline-block; background: var(--accent); color: #fff; border: 0;
  padding: .5rem 1.1rem; border-radius: 6px; font-size: .95rem; cursor: pointer;
}
.btn:hover { background: #16293f; text-decoration: none; }
.btn-small { padding: .3rem .8rem; font-size: .85rem; }
.btn-danger { background: var(--neg); }
.btn-danger:hover { background: #6d2114; }
.linklike {
  background: none; border: 0; padding: 0; color: inherit; cursor: pointer;
  font: inherit; text-decoration: underline; opacity: .85;
}
.inline-form { display: inline; }

/* stats */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: .8rem 1.2rem; min-width: 10rem;
}
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); }
.stat-value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* auth */
.auth-box { max-width: 26rem; margin: 2rem auto; background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 1.6rem 1.8rem; }
.auth-box label { display: block; font-size: .88rem; color: var(--muted);
  margin: .9rem 0; }
.auth-box input {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; font-size: 1rem;
}
.auth-box .btn { width: 100%; margin-top: .6rem; }

/* admin */
.admin-market {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem 1.15rem; margin-bottom: .9rem;
}
/* title on its own line + chip pinned top-right, so long and short titles
   produce identical layouts (no flex-wrap drift). */
.admin-market-top { display: flex; align-items: flex-start; gap: .8rem; }
.admin-market-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 1.02rem; line-height: 1.35;
  color: var(--ink);
}
.admin-market-top .chip { flex: 0 0 auto; margin-top: .15rem; }
.admin-stats {
  display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .6rem;
  color: var(--muted); font-size: .82rem; font-variant-numeric: tabular-nums;
}
.admin-stats .k { color: var(--ink); font-weight: 600; }
.admin-prices {
  display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; margin-top: .5rem;
  font-size: .84rem;
}
.admin-price { display: inline-flex; align-items: center; gap: .1rem; }
.admin-price .swatch { margin-right: .35rem; }
.admin-market-fine { margin-top: .5rem; }
.admin-market-actions { display: flex; align-items: flex-start; gap: .6rem;
  margin-top: .8rem; flex-wrap: wrap; padding-top: .8rem;
  border-top: 1px solid var(--line); }
.admin-resolve summary { list-style: none; }
.admin-resolve summary::-webkit-details-marker { display: none; }
.admin-resolve form {
  margin-top: .6rem; padding: .8rem; background: var(--accent-soft);
  border-radius: 8px; max-width: 28rem;
}
.admin-resolve label { display: block; font-size: .85rem; color: var(--muted);
  margin-bottom: .6rem; }
.admin-resolve select, .admin-resolve textarea {
  display: block; width: 100%; margin-top: .25rem; padding: .4rem .5rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
.market-form { max-width: 40rem; }
.market-form label { display: block; font-size: .88rem; color: var(--muted);
  margin: 1rem 0; }
.market-form input, .market-form textarea, .market-form select {
  display: block; width: 100%; margin-top: .3rem; padding: .5rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}

/* footer */
.site-footer {
  border-top: 1px solid var(--line); background: var(--card);
  padding: 1.1rem 0 1.4rem; color: var(--muted); font-size: .85rem;
}
.site-footer .wrap { display: flex; justify-content: center; gap: 1rem;
  flex-wrap: wrap; text-align: center; }
.footer-fine { font-size: .8rem; }

/* audit trail */
.audit-detail { max-width: 28rem; word-break: break-all; font-family: ui-monospace, monospace; font-size: 0.72rem; }
.log-tail { background: #14181d; color: #cdd5df; padding: 1rem; border-radius: 6px; font-size: 0.72rem; overflow-x: auto; max-height: 24rem; overflow-y: auto; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  main.wrap { padding-top: 2.25rem; padding-bottom: 2.5rem; }
  .wrap { padding: 0 1rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.1rem; }
  .lede { font-size: .95rem; }
  .tagline { display: none; }

  /* header: wordmark + hamburger on one clean row; tap opens a stacked menu.
     Keep the 1rem horizontal padding (a bare `.55rem 0` here would zero the
     inset .wrap provides and jam the wordmark against the edge). */
  .header-row { min-height: 0; padding: .55rem 1rem; gap: 0 1rem;
    align-items: center; flex-wrap: wrap; }
  .wordmark { letter-spacing: .01em; font-size: 1.2rem; order: 1; }
  .nav-toggle { display: flex; order: 2; margin-left: auto; flex-direction: column;
    justify-content: center; gap: 5px; width: 40px; height: 34px; padding: 7px;
    background: transparent; border: 0; cursor: pointer; }
  .nav-toggle span { display: block; height: 2px; width: 100%; background: #fff;
    border-radius: 2px; transition: transform .2s, opacity .2s; }
  .site-header.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .site-header.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .site-header.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  .site-header nav, .header-user { display: none; order: 3; flex-basis: 100%; }
  .site-header.nav-open nav { display: flex; flex-direction: column; gap: 0;
    padding-top: .6rem; }
  .site-header.nav-open .header-user { display: flex; flex-direction: column;
    align-items: flex-start; gap: .7rem; padding-top: .7rem; margin-top: .5rem;
    border-top: 1px solid rgba(255,255,255,.16); }
  .site-header nav a { padding: .55rem 0; font-size: 1.02rem; }
  /* in the stacked menu, render the Join button as a plain aligned link */
  .site-header.nav-open .header-user .btn { background: transparent; padding: 0;
    font-size: 1.02rem; }
  .site-header.nav-open .header-user .btn:hover { background: transparent;
    text-decoration: underline; }
  .site-header.nav-open .header-user .user-chip { margin-bottom: .2rem; }

  /* market cards: let outcome labels wrap; bar drops to its own full-width row */
  .market-grid { gap: .8rem; }
  .market-card { padding: 1rem; }
  .price-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "label value" "bar bar";
    gap: .25rem .6rem;
  }
  .price-label { grid-area: label; white-space: normal; }
  .price-value { grid-area: value; }
  .price-bar-track { grid-area: bar; height: 6px; }

  /* recent-trades table is genuinely wide -> scroll inside its own box */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
  /* outcomes table should just fit; shrink the bar so label + bar + % all fit */
  .price-bar-track.wide { width: 68px; margin-right: .4rem; }
}
