/* Spreadwire v2 component library
   Built on tokens.css. No hex values here; everything references tokens.
   Each component is self-contained and reusable. */

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--sw-bg);
  color: var(--sw-ink);
  font-family: var(--sw-font-body);
  font-size: var(--sw-text-md);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  max-width: 100%;
}
h1, h2, h3, h4 { font-family: var(--sw-font-display); font-weight: 600; line-height: 1.2; overflow-wrap: break-word; }
h1 { font-size: var(--sw-text-3xl); }
h2 { font-size: var(--sw-text-xl); }
h3 { font-size: var(--sw-text-lg); }
p { max-width: var(--sw-max-text); overflow-wrap: break-word; }
a { color: var(--sw-link); text-decoration: none; }
a:hover { color: var(--sw-link-hover); text-decoration: underline; }
code { font-family: var(--sw-font-mono); font-size: .85em; background: var(--sw-surface-2); padding: 1px 5px; border-radius: var(--sw-radius-sm); overflow-wrap: break-word; }
:focus-visible { outline: 2px solid var(--sw-link); outline-offset: 3px; }

/* Layout */
.sw-page { max-width: var(--sw-max-page); margin: 0 auto; padding: 0 var(--sw-space-5); }
.sw-narrow { max-width: 800px; margin: 0 auto; }

/* Masthead */
.sw-masthead {
  background: var(--sw-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sw-space-2) var(--sw-space-3);
  padding: var(--sw-space-3) var(--sw-space-4);
}
.sw-masthead .sw-logo { display: flex; align-items: center; gap: var(--sw-space-2); text-decoration: none; color: inherit; flex-shrink: 0; }
.sw-masthead .sw-logo-mark {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--sw-amber);
  background: transparent; color: var(--sw-amber);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--sw-font-display); font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.sw-masthead .sw-logo-text { font-family: var(--sw-font-display); font-weight: 700; font-size: 18px; color: #fff; white-space: nowrap; }
.sw-nav { display: flex; gap: var(--sw-space-4); list-style: none; }
.sw-nav a { color: rgba(255,255,255,.75); font-size: var(--sw-text-sm); font-weight: 500; text-decoration: none; padding: var(--sw-space-1) 0; white-space: nowrap; }
.sw-nav a:hover, .sw-nav a[aria-current] { color: #fff; text-decoration: none; border-bottom: 2px solid var(--sw-amber); }
.sw-menu-btn { display: none; }

/* Footer */
.sw-footer {
  background: var(--sw-navy);
  color: rgba(255,255,255,.7);
  padding: var(--sw-space-5) var(--sw-space-5) var(--sw-space-6);
  font-size: var(--sw-text-xs);
  line-height: 1.6;
}
.sw-footer a { color: rgba(255,255,255,.7); }
.sw-footer a:hover { color: #fff; }
.sw-footer-legal { font-size: var(--sw-text-xs); color: rgba(255,255,255,.55); margin-top: var(--sw-space-4); max-width: 680px; }

/* Primary button (amber, navy text) */
.sw-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sw-space-1);
  background: var(--sw-amber);
  color: var(--sw-navy);
  font-family: var(--sw-font-body);
  font-size: var(--sw-text-sm);
  font-weight: 600;
  padding: var(--sw-space-2) var(--sw-space-4);
  min-height: 44px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.sw-btn:hover { filter: brightness(1.05); }
.sw-btn:active { filter: brightness(.95); }
.sw-btn:disabled { background: var(--sw-surface-2); color: var(--sw-muted); border: 1px solid var(--sw-border); cursor: not-allowed; filter: none; }

/* Secondary link */
.sw-link-arrow {
  color: var(--sw-link);
  font-size: var(--sw-text-sm);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sw-link-arrow::after { content: '→'; }
.sw-link-arrow:hover { color: var(--sw-link-hover); }

/* Card */
.sw-card {
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius);
  padding: var(--sw-space-4);
  box-shadow: var(--sw-shadow);
}

/* Ledger row: fixed 3-cell grid (date | move | body) so every row aligns identically */
.sw-ledger-row {
  display: grid;
  grid-template-columns: 92px 84px 1fr;
  grid-template-areas: "date move body";
  gap: var(--sw-space-1) var(--sw-space-3);
  padding: var(--sw-space-3) 0;
  border-bottom: 1px solid var(--sw-border);
  align-items: start;
}
.sw-ledger-date { grid-area: date; font-size: var(--sw-text-xs); color: var(--sw-muted); font-weight: 500; padding-top: 6px; }
.sw-ledger-time { display: block; color: var(--sw-muted); }
.sw-ledger-move { grid-area: move; font-family: var(--sw-font-display); font-size: var(--sw-text-xl); font-weight: 700; line-height: 1.1; }
.sw-ledger-body { grid-area: body; min-width: 0; }
.sw-ledger-move.up { color: var(--sw-up); }
.sw-ledger-move.up::before { content: '▲ '; font-size: .7em; }
.sw-ledger-move.down { color: var(--sw-down); }
.sw-ledger-move.down::before { content: '▼ '; font-size: .7em; }

/* Persistence tag */
.sw-tag {
  display: inline-flex;
  align-items: center;
  font-size: var(--sw-text-xs);
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  line-height: 1.3;
}
.sw-tag-held { background: var(--sw-held-bg); color: var(--sw-held-fg); }
.sw-tag-faded { background: var(--sw-faded-bg); color: var(--sw-faded-fg); }
.sw-tag-pending { background: var(--sw-pending-bg); color: var(--sw-pending-fg); }
.sw-tag-flagged { background: var(--sw-flagged-bg); color: var(--sw-flagged-fg); }

/* Notice banner */
.sw-note {
  background: var(--sw-note-bg);
  color: var(--sw-note-fg);
  font-size: var(--sw-text-sm);
  padding: var(--sw-space-2) var(--sw-space-4);
  border-radius: var(--sw-radius-sm);
  line-height: 1.5;
}

/* Odds table */
.sw-odds-table-wrap { overflow-x: auto; max-width: 100%; -webkit-overflow-scrolling: touch; }
.sw-odds-table { width: 100%; border-collapse: collapse; font-size: var(--sw-text-sm); }
.sw-odds-table th {
  text-align: left;
  font-size: var(--sw-text-xs);
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--sw-muted);
  padding: 0 6px 8px;
  border-bottom: 1px solid var(--sw-border);
}
.sw-odds-table td { padding: 10px 6px; border-bottom: 1px solid var(--sw-border); vertical-align: middle; overflow-wrap: break-word; }
.sw-odds-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sw-odds-table .b { font-weight: 700; }
.sw-odds-table th:not(.num) { white-space: normal; }
.sw-odds-detail { display: none; }
.sw-odds-detail-inner { display: flex; gap: var(--sw-space-3); align-items: center; flex-wrap: wrap; }

/* Range bar (30-day) */
.sw-range-bar { position: relative; height: 14px; background: var(--sw-surface-2); border-radius: 7px; min-width: 60px; max-width: 200px; }
.sw-range-band { position: absolute; top: 4px; height: 6px; border-radius: 3px; background: var(--sw-range); }
.sw-range-dot {
  position: absolute; top: 1px; width: 12px; height: 12px;
  left: min(max(calc(var(--sw-dot, 50%) - 6px), 0px), calc(100% - 12px));
  border-radius: 50%; background: var(--sw-amber);
  border: 2px solid var(--sw-ink);
}

/* Direction indicator (never colour alone; neutral below 0.2 shows muted grey, no arrow) */
.sw-dir { font-variant-numeric: tabular-nums; font-weight: 600; }
.sw-dir.up { color: var(--sw-up); }
.sw-dir.up::before { content: '▲ '; font-size: .8em; }
.sw-dir.down { color: var(--sw-down); }
.sw-dir.down::before { content: '▼ '; font-size: .8em; }
.sw-dir.flat { color: var(--sw-muted); font-weight: 500; }

/* Subscribe form */
.sw-form label { display: block; font-size: var(--sw-text-sm); font-weight: 500; color: var(--sw-ink-2); margin-bottom: 4px; }
.sw-form input[type="email"], .sw-form input[type="text"] {
  width: 100%;
  background: var(--sw-surface);
  border: 1px solid var(--sw-border);
  color: var(--sw-ink);
  border-radius: var(--sw-radius-sm);
  padding: var(--sw-space-2) var(--sw-space-3);
  font: inherit;
  font-size: var(--sw-text-sm);
  min-height: 44px;
}
.sw-form input:focus { border-color: var(--sw-link); outline: 1px solid var(--sw-link); }
.sw-form .sw-form-error { color: var(--sw-down); font-size: var(--sw-text-xs); margin-top: 4px; }

/* Pricing table */
.sw-pricing { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--sw-space-4); }
.sw-pricing .sw-card h3 { margin-bottom: var(--sw-space-1); }
.sw-pricing .sw-price { font-family: var(--sw-font-display); font-size: var(--sw-text-xl); font-weight: 700; margin: var(--sw-space-2) 0; }
.sw-pricing ul { list-style: none; padding: 0; font-size: var(--sw-text-sm); color: var(--sw-ink-2); }
.sw-pricing li { padding: 4px 0; }
.sw-pricing li::before { content: '·'; color: var(--sw-amber); font-weight: 700; margin-right: 6px; }

/* Theme toggle */
.sw-theme-toggle {
  background: none;
  border: 1px solid var(--sw-border);
  border-radius: var(--sw-radius-sm);
  color: var(--sw-ink-2);
  font: inherit;
  font-size: var(--sw-text-xs);
  padding: var(--sw-space-1) var(--sw-space-3);
  cursor: pointer;
  min-height: 36px;
}
.sw-theme-toggle:hover { border-color: var(--sw-border-strong); color: var(--sw-ink); }

/* Typography helpers */
.sw-eyebrow {
  font-size: var(--sw-text-xs);
  font-weight: 600;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--sw-amber-text);
  margin-bottom: var(--sw-space-2);
}
.sw-lede { font-size: var(--sw-text-lg); line-height: 1.45; max-width: 640px; }
.sw-mono { font-family: var(--sw-font-mono); font-variant-numeric: tabular-nums; }

/* Page sections */
.sw-section { margin-top: var(--sw-space-7); }
.sw-section-head { display: flex; flex-wrap: wrap; gap: var(--sw-space-2) var(--sw-space-4); align-items: baseline; justify-content: space-between; }

/* Page: hero */
.sw-hero { padding: var(--sw-space-6) 0 var(--sw-space-5); }
.sw-hero-cta { display: flex; flex-wrap: wrap; gap: var(--sw-space-3) var(--sw-space-4); align-items: center; margin-top: var(--sw-space-4); }

/* Page: credibility strip (numbers computed live from the database) */
.sw-credibility {
  display: flex; flex-wrap: wrap; gap: var(--sw-space-3) var(--sw-space-6);
  padding: var(--sw-space-4) 0; border-top: 1px solid var(--sw-border); border-bottom: 1px solid var(--sw-border);
}
.sw-credibility .sw-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sw-credibility .sw-stat b { font-family: var(--sw-font-display); font-size: var(--sw-text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.sw-credibility .sw-stat span { font-size: var(--sw-text-xs); color: var(--sw-muted); }

/* Page: filters (GET form, server-rendered) */
.sw-filter-form { display: flex; flex-wrap: wrap; gap: var(--sw-space-2) var(--sw-space-3); align-items: flex-end; margin: var(--sw-space-4) 0 var(--sw-space-3); }
.sw-filter-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--sw-text-xs); font-weight: 500; color: var(--sw-ink-2); }
.sw-form select, .sw-filter-form select, .sw-filter-form input {
  background: var(--sw-surface); border: 1px solid var(--sw-border); color: var(--sw-ink);
  border-radius: var(--sw-radius-sm); padding: var(--sw-space-1) var(--sw-space-2);
  font: inherit; font-size: var(--sw-text-sm); min-height: 44px; max-width: 100%;
}

/* Page: breadcrumb */
.sw-breadcrumb { font-size: var(--sw-text-xs); color: var(--sw-muted); margin-bottom: var(--sw-space-2); }
.sw-breadcrumb a { color: var(--sw-muted); }
.sw-breadcrumb a:hover { color: var(--sw-link); }

/* Page: odds history chart (inline SVG, token colours only) */
.sw-chart { display: block; width: 100%; height: auto; }
.sw-chart text { font-family: var(--sw-font-body); font-size: 10.5px; fill: var(--sw-axis); }
.sw-chart .sw-grid-line { stroke: var(--sw-grid); stroke-width: 1; }
.sw-chart .sw-series { fill: none; stroke: var(--sw-amber); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.sw-chart .sw-today-dot { fill: var(--sw-amber); stroke: var(--sw-navy); stroke-width: 2; }
.sw-chart-mobile { display: none; }
.sw-chart-mobile text { font-size: 12px; }

/* Page: channel cards */
.sw-channel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--sw-space-4); }
.sw-channel-grid .sw-card h2 { margin-bottom: var(--sw-space-1); }
.sw-channel-grid .sw-card p { margin-top: var(--sw-space-1); }
.sw-channel-grid .sw-card .sw-channel-link { display: inline-block; margin-top: var(--sw-space-3); }

/* Page: ledger entry sources and secondary verdict */
.sw-entry-src { font-size: var(--sw-text-xs); color: var(--sw-muted); margin-top: 4px; overflow-wrap: break-word; }
.sw-entry-src a { color: var(--sw-link); }
.sw-verdict-muted { font-size: var(--sw-text-xs); color: var(--sw-muted); }

/* Page: prose pages (legal, privacy) */
.sw-prose { max-width: var(--sw-max-text); }
.sw-prose h2 { margin-top: var(--sw-space-5); }
.sw-prose p, .sw-prose ul { margin-top: var(--sw-space-2); }
.sw-prose ul { padding-left: 20px; }

/* Page: brief */
.sw-brief-head h1 { margin-top: var(--sw-space-2); }
.sw-brief-actions { margin-top: var(--sw-space-4); }
.sw-brief-section { margin-top: var(--sw-space-7); break-inside: avoid-page; }
.sw-brief-method { border-top: 1px solid var(--sw-border); padding-top: var(--sw-space-4); font-size: var(--sw-text-sm); color: var(--sw-ink-2); max-width: var(--sw-max-text); }
.sw-two-cards { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sw-space-4); }
.sw-watch-row { display: grid; grid-template-columns: 110px 1fr; gap: var(--sw-space-4); padding: var(--sw-space-3) 0; border-bottom: 1px solid var(--sw-border); font-size: var(--sw-text-md); line-height: 1.5; }
.sw-watch-when { font-weight: 600; color: var(--sw-amber-text); }

/* Mobile */
@media (max-width: 640px) {
  .sw-page { padding: 0 var(--sw-space-4); max-width: 100%; }
  .sw-masthead { padding: var(--sw-space-3) var(--sw-space-4); }
  .sw-nav { display: none; }
  .sw-masthead.sw-menu-open .sw-nav {
    display: flex; flex-direction: column; gap: var(--sw-space-2);
    width: 100%; padding-top: var(--sw-space-2);
  }
  .sw-menu-btn {
    display: flex;
    background: none;
    border: 1px solid rgba(255,255,255,.25);
    border-radius: var(--sw-radius-sm);
    color: #fff;
    font: inherit;
    font-size: var(--sw-text-sm);
    padding: var(--sw-space-1) var(--sw-space-3);
    min-height: 44px;
    cursor: pointer;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  h1 { font-size: var(--sw-text-2xl); }
  h2 { font-size: var(--sw-text-lg); }
  .sw-lede { font-size: var(--sw-text-md); }
  .sw-hero { padding: var(--sw-space-4) 0; }
  .sw-credibility { gap: var(--sw-space-3) var(--sw-space-4); }
  .sw-filter-form { flex-direction: column; align-items: stretch; }
  .sw-filter-form select, .sw-filter-form input { width: 100%; }
  .sw-channel-grid { grid-template-columns: 1fr; }
  .sw-ledger-row { grid-template-columns: 92px 84px; grid-template-areas: "date move" "body body"; }
  .sw-odds-table .sw-desk-only { display: none; }
  .sw-odds-detail { display: table-row; }
  .sw-odds-detail td { padding: 0 6px 10px; border-bottom: 1px solid var(--sw-border); }
  .sw-chart-desktop { display: none; }
  .sw-chart-mobile { display: block; }
  .sw-pricing { grid-template-columns: 1fr; }
  .sw-two-cards { grid-template-columns: 1fr; }
  .sw-watch-row { grid-template-columns: 1fr; gap: var(--sw-space-1); }
}

/* Print (brief export: A4; tokens.css forces the light palette when printing) */
@media print {
  @page { size: A4; margin: 14mm; }
  .sw-masthead, .sw-footer, .sw-btn, .sw-theme-toggle, .sw-brief-print-hide { display: none !important; }
  body { background: var(--sw-bg); color: var(--sw-ink); font-size: 12pt; }
  .sw-page { padding: 0; max-width: none; }
  .sw-card { border: 1px solid var(--sw-border-strong); box-shadow: none; padding: 4mm; }
  .sw-brief-section { break-inside: avoid-page; }
  .sw-ledger-row, .sw-watch-row, .sw-odds-detail, tr { break-inside: avoid; }
  .sw-note, .sw-tag, .sw-range-band, .sw-range-dot, .sw-odds-table td, .sw-odds-table th {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
