/* ===================================================================
   MiningNewsTerminal — v2 stylesheet (deepdive.ca-inspired)
   =================================================================== */

:root {
  --brand-red: #D71920;
  --brand-red-dark: #b71218;
  --ink: #1a1a1a;
  --ink-soft: #444;
  --ink-mute: #6b6b6b;
  --line: #e1e1de;
  --line-soft: #ececea;
  --bg: #ffffff;
  --bg-soft: #f7f7f6;
  --bg-strip: #f4f4f2;
  --link: #0b5aa6;
  --content-w: 1100px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.55 "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

/* ============== Ticker strip (top) ============== */
.ticker-strip {
  background: var(--bg-strip);
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.ticker-strip-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0.4rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.ts-date { color: var(--ink-mute); white-space: nowrap; }
.ts-latest {
  display: inline-block;
  background: var(--brand-red);
  color: #fff;
  padding: 0.18rem 0.7rem;
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ts-headline {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ts-headline a { color: var(--ink); }
.ts-headline a:hover { color: var(--brand-red); text-decoration: none; }
.ts-search input {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 2px;
  font: inherit;
  width: 180px;
  background: #fff;
}

/* ============== Masthead ============== */
.masthead {
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1.25rem 1.25rem;
  position: relative;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--ink);
}
.brand-link:hover { text-decoration: none; }
.brand-logo {
  height: 44px;
  width: auto;
  display: block;
}
.brand-divider {
  font-size: 1.6rem;
  color: var(--ink-mute);
  font-weight: 300;
  margin-top: -3px;
}
.brand-wordmark {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.masthead-right {
  position: absolute;
  right: 1.25rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.88rem;
}
.admin-link { color: var(--ink-mute); margin-left: 0.5rem; }
.linkbtn { background: none; border: 0; cursor: pointer; font: inherit; color: var(--ink-mute); padding: 0; }
.inline { display: inline; }

/* ============== Primary nav ============== */
.primary-nav {
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 2px solid var(--ink);
}
.primary-nav-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  gap: 0.25rem;
}
.primary-nav a {
  color: var(--ink);
  padding: 0.85rem 1.1rem;
  font-weight: 500;
  font-size: 0.95rem;
  position: relative;
}
.primary-nav a:hover {
  color: var(--brand-red);
  text-decoration: none;
}
.primary-nav a.active {
  color: var(--brand-red);
}
.primary-nav a.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background: var(--brand-red);
}

/* ============== Page title ============== */
.page-title {
  margin: 0.25rem 0 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ============== Filters ============== */
.filters, .fin-filters {
  margin: 0.75rem 0 1.25rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.92rem;
}
.filters select, .fin-filters select {
  padding: 0.4rem 0.55rem;
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px;
}
.fin-filters .muted { color: var(--ink-mute); margin-left: auto; font-size: 0.85rem; }

/* ============== Category chips ============== */
.category-filter {
  background: #fff;
  border: 1px solid var(--line);
  padding: 0.65rem 0.8rem;
  margin: 0 0 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.5rem;
  align-items: center;
  border-radius: 0;
}
.cat-filter-label {
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-weight: 600;
  margin-right: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.22rem 0.6rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.82rem;
  cursor: pointer;
  user-select: none;
}
.cat-chip:hover { background: #ebebe8; }
.cat-chip input { margin: 0; accent-color: var(--brand-red); }
.cat-chip-name { color: var(--ink); }
.cat-chip-count { color: var(--ink-mute); font-size: 0.75rem; }
.cat-chip-on { background: var(--brand-red); border-color: var(--brand-red); }
.cat-chip-on .cat-chip-name, .cat-chip-on .cat-chip-count { color: #fff; }
.cat-clear { font-size: 0.85rem; color: var(--brand-red); margin-left: 0.5rem; }

/* ============== Two-column layout for News feed ============== */
.feed-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 2rem;
  align-items: start;
}
@media (max-width: 880px) {
  .feed-grid { grid-template-columns: 1fr; }
}

.events { list-style: none; margin: 0; padding: 0; }
.event { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.event-meta { font-size: 0.82rem; color: var(--ink-mute); display: flex; gap: 0.75rem; flex-wrap: wrap; }
.event-meta .ticker { font-weight: 700; color: var(--brand-red); }
.event h3 {
  margin: 0.25rem 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;
}
.event h3 a { color: var(--ink); }
.event h3 a:hover { color: var(--brand-red); text-decoration: none; }
.event .excerpt { margin: 0; color: var(--ink-soft); }

.event-cats { margin-top: 0.4rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.cat-badge {
  display: inline-block; padding: 0.08rem 0.45rem;
  font-size: 0.72rem; font-weight: 600;
  border-radius: 2px;
  background: #f0f0ec; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.03em;
}

/* Latest News sidebar */
.sidebar-card {
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
}
.sidebar-card .sc-header {
  background: var(--brand-red);
  color: #fff;
  padding: 0.6rem 0.9rem;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.sidebar-card ul { list-style: none; margin: 0; padding: 0; }
.sidebar-card li {
  border-bottom: 1px solid var(--line-soft);
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
  line-height: 1.4;
}
.sidebar-card li:last-child { border-bottom: 0; }
.sidebar-card li a { color: var(--ink); }
.sidebar-card li a:hover { color: var(--brand-red); text-decoration: none; }

/* ============== Financings table ============== */
.fin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--line);
  font-size: 0.9rem;
}
.fin-table th, .fin-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  white-space: nowrap;
}
.fin-table thead th {
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.fin-table tbody tr:hover { background: #fafaf6; }
.fin-ticker { font-weight: 700; color: var(--brand-red); }
.fin-amt { font-variant-numeric: tabular-nums; text-align: right; }
.fin-warrant { color: var(--ink-soft); white-space: normal; max-width: 180px; }
.fin-kind { color: var(--ink-mute); font-size: 0.82rem; }
.fin-date { color: var(--ink-mute); font-size: 0.85rem; }
.fin-tranches { color: var(--ink-mute); font-size: 0.78rem; margin-left: 0.25rem; }

.fin-status {
  display: inline-block; padding: 0.12rem 0.5rem;
  border-radius: 2px; font-size: 0.72rem;
  background: #eee; color: #333; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.fin-status-announced      { background: #e6f0fb; color: #0b5aa6; }
.fin-status-upsized        { background: #d6eaff; color: #0b3a78; }
.fin-status-tranche_closed { background: #fff1c5; color: #7a5a00; }
.fin-status-closed         { background: #d7f1d9; color: #1b5c22; }
.fin-status-amended        { background: #f7e3d4; color: #7a3300; }
.fin-status-terminated     { background: #f3d3d3; color: var(--brand-red-dark); }
.fin-status-mention        { background: #f3f3f0; color: var(--ink-mute); }

/* ============== Event detail ============== */
.event-detail { max-width: 760px; margin: 0 auto; padding: 0.5rem 0; }
.event-detail h1 { line-height: 1.25; margin-top: 0.25rem; font-weight: 700; }
.event-detail .body p { margin: 0.75em 0; }
.event-detail .backlink { margin-top: 2rem; }
.event-detail .sourcelink { font-size: 0.95rem; }

.body-html { line-height: 1.6; }
.body-html img { max-width: 560px; width: 100%; height: auto; display: block; margin: 1em auto; border: 1px solid var(--line); border-radius: 2px; }
.body-html table { border-collapse: collapse; margin: 1em 0; font-size: 0.93em; display: block; overflow-x: auto; max-width: 100%; }
.body-html th, .body-html td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
.body-html th { background: #f4f4f4; font-weight: 600; }
.body-html tr:nth-child(odd) td { background: #fafafa; }
.body-html p { margin: 0 0 0.85em 0; }
.body-html ul, .body-html ol { margin: 0 0 0.85em 1.4em; }
.body-html a { color: var(--link); }

/* ============== Footer ============== */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--bg-soft);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-mute);
}
.site-footer a { color: var(--brand-red); }

/* ============== Empty states ============== */
.empty { color: var(--ink-mute); font-style: italic; }

/* ============== Admin (legacy, lightly themed) ============== */
.admin .notice { background: #fff7d6; border: 1px solid #e6cf6f; padding: 0.6rem 0.8rem; border-radius: 2px; margin-bottom: 1rem; font-size: 0.9rem; }
.admin .filters { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.admin .bulkbar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.admin .muted { color: var(--ink-mute); margin-left: auto; font-size: 0.9rem; }
.admin button { padding: 0.4rem 0.8rem; border: 1px solid var(--line); background: var(--bg-soft); border-radius: 2px; cursor: pointer; font: inherit; }
.admin button.danger { background: var(--brand-red); color: #fff; border-color: var(--brand-red-dark); }
.admin button.small { padding: 0.25rem 0.55rem; font-size: 0.85rem; }

.events-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); font-size: 0.92rem; }
.events-table th, .events-table td { padding: 0.45rem 0.6rem; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.events-table thead th { background: #f0f0ec; position: sticky; top: 0; }

.status { font-size: 0.74rem; padding: 0.1rem 0.45rem; border-radius: 2px; background: #eee; color: #333; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.status-auto_approved { background: #d7f1d9; color: #1b5c22; }
.status-pending       { background: #fff3bf; color: #7a5a00; }
.status-rejected      { background: #f3d3d3; color: var(--brand-red-dark); }

.login { max-width: 360px; margin: 3rem auto; background: #fff; padding: 1.5rem; border: 1px solid var(--line); border-radius: 2px; }
.login label { display: block; margin-bottom: 0.25rem; font-weight: 600; }
.login input { width: 100%; padding: 0.5rem; font: inherit; border: 1px solid var(--line); border-radius: 2px; margin-bottom: 0.75rem; }
.login button { padding: 0.55rem 1rem; background: var(--brand-red); color: #fff; border: 0; border-radius: 2px; cursor: pointer; font: inherit; font-weight: 600; }
.login .error { color: var(--brand-red-dark); }
/* ============== v3 overrides — clean masthead, no ticker strip ============== */

/* Hide the ticker strip from older base.html if anything still emits it */
.ticker-strip { display: none !important; }

/* New masthead layout: left-aligned brand, right-aligned meta */
.masthead {
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  padding: 0;
  display: block;
}
.masthead-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}
.brand-link:hover { text-decoration: none; }
.brand-icon {
  width: 40px;
  height: 40px;
  display: block;
  border-radius: 4px;
}
.brand-divider { display: none; }
.brand-logo { display: none; }
.brand-wordmark {
  font-family: "Roboto", sans-serif;
  font-size: 1.55rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1;
}
.masthead-right {
  position: static;
  transform: none;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--ink-mute);
}
.masthead-date {
  color: var(--ink-mute);
  font-size: 0.85rem;
}
.admin-link { color: var(--ink-mute); margin-left: 0; }

/* Polish the primary nav */
.primary-nav {
  background: #fff;
  border-top: 1px solid var(--line);
  border-bottom: 2px solid var(--ink);
}
.primary-nav-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  gap: 0;
}
.primary-nav a {
  color: var(--ink);
  padding: 0.85rem 1.2rem;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  position: relative;
  transition: color 0.12s;
}
.primary-nav a:first-child { padding-left: 0; }
.primary-nav a:hover { color: var(--brand-red); text-decoration: none; }
.primary-nav a.active { color: var(--brand-red); font-weight: 700; }
.primary-nav a.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--brand-red);
}
.primary-nav a:first-child.active::after { left: 0; }

/* Page chrome */
main {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}
.page-title {
  font-family: "Roboto", sans-serif;
  font-weight: 900;
  font-size: 1.75rem;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--line);
}

/* News article cards — bigger headlines, more whitespace, deepdive feel */
.event {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--line-soft);
}
.event-meta {
  font-size: 0.78rem;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.event-meta .ticker {
  font-weight: 700;
  color: var(--brand-red);
  letter-spacing: 0.04em;
}
.event h3 {
  margin: 0.5rem 0 0.6rem;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.event h3 a { color: var(--ink); text-decoration: none; }
.event h3 a:hover { color: var(--brand-red); }

/* Sidebar headers — match deepdive's red bar */
.sidebar-card .sc-header {
  background: var(--brand-red);
  color: #fff;
  padding: 0.7rem 1rem;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sidebar-card { border: 1px solid var(--line); }
.sidebar-card li { padding: 0.75rem 1rem; font-size: 0.92rem; }

/* Footer — slimmer */
.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink-mute);
}
.site-footer a { color: var(--brand-red); }

/* Financings table polish */
.fin-table thead th {
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.6rem 0.7rem;
}
.fin-table td { padding: 0.55rem 0.7rem; }
.fin-ticker { font-weight: 700; color: var(--brand-red); letter-spacing: 0.02em; }

/* === v3.1 fine alignment of brand === */
.masthead-inner {
  padding: 1.1rem 1.25rem;
  align-items: center;
}
.brand-link {
  align-items: center;
  gap: 0.65rem;
  line-height: 1;
}
.brand-icon {
  width: 44px;
  height: 44px;
  display: block;
  flex-shrink: 0;
}
.brand-wordmark {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--ink);
  display: inline-block;
  /* Optical lift to match heavy icon */
  position: relative;
  top: 1px;
}

/* === v3.2 tighten brand to match steve's mockup === */
.brand-link {
  align-items: center;
  gap: 0.4rem;
}
.brand-icon {
  width: 30px;
  height: 30px;
}
.brand-wordmark {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  top: 0;
}

/* === v3.3 even tighter brand pairing === */
.brand-link { gap: 3px; }
.brand-icon { width: 32px; height: 32px; margin-right: 0; }
.brand-wordmark { margin-left: 0; }

/* === v3.4 shrink icon 15% === */
.brand-icon { width: 27px; height: 27px; }

/* === v3.5 logo +15%, gap a touch larger === */
.brand-icon { width: 31px; height: 31px; }
.brand-link { gap: 5px; }
.brand-wordmark { font-size: 1.45rem; }

/* === v3.6 narrow gap 20%, raise icon 10% (3px) === */
.brand-link { gap: 4px; }
.brand-icon { transform: translateY(-3px); }

/* === v3.7 search bar in primary nav === */
.primary-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.primary-nav-links { display: flex; }
.primary-nav-search {
  display: flex;
  align-items: center;
  margin-left: auto;
}
.primary-nav-search input[type="search"] {
  padding: 0.32rem 0.6rem;
  font: inherit;
  font-size: 0.88rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 2px 0 0 2px;
  width: 200px;
  outline: none;
}
.primary-nav-search input[type="search"]:focus {
  border-color: var(--brand-red);
}
.primary-nav-search button {
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--brand-red);
  background: var(--brand-red);
  color: #fff;
  border-radius: 0 2px 2px 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.primary-nav-search button:hover { background: var(--brand-red-dark); border-color: var(--brand-red-dark); }

/* search results page */
.search-q-pill {
  display: inline-block;
  background: var(--brand-red);
  color: #fff;
  padding: 0.18rem 0.6rem;
  font-size: 0.85rem;
  border-radius: 2px;
  margin-left: 0.5rem;
  vertical-align: middle;
  font-weight: 700;
}
.muted { color: var(--ink-mute); font-size: 0.88rem; }

/* === v3.8 Recent Financings sidebar with quick link === */
.recfin-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.25rem;
}
.recfin-amt {
  margin-left: auto;
  color: var(--ink-mute);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
}
.recfin-link {
  display: block;
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.35;
  margin-top: 0.15rem;
  text-decoration: none;
}
.recfin-link:hover { color: var(--brand-red); text-decoration: none; }
