/* ==========================================================================
   TrueView — Monthly Wrap-Up (Performance Report) tab
   Paired with js/report.js. Screen styles echo the T.V. Signal editorial system
   (paper/panel surfaces, --tvs-* hairlines, Newsreader headlines, Inter data,
   small-caps kickers, generous whitespace). Print rules are scoped to
   body.rp-active so they ONLY affect printing while the report tab is active.
   All colors reference --tvs-* vars (defined in index.html) except where a value
   must match a Chart.js JS constant, which charts render to <canvas> (CSS can't
   reach it) so there is nothing to match here.
   ========================================================================== */

/* ---- container ---- */
.rp-report { display: block; }

/* ---- shared card surface (own class so print scoping is clean) ---- */
.rp-card {
  background: var(--tvs-panel);
  border: 1px solid var(--tvs-line);
  border-radius: 0;
  padding: 18px 20px;
  margin-bottom: 18px;
}

.rp-section-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16.5px;
  font-weight: 500;
  color: var(--tvs-ink);
  margin: 0 0 10px 0;
}

.rp-caption {
  font-size: 10.5px;
  color: var(--tvs-muted);
  letter-spacing: 0.2px;
  margin: 10px 0 0;
}

/* ==========================================================================
   MASTHEAD
   ========================================================================== */
.rp-masthead {
  border: none;
  border-top: 2px solid var(--tvs-ink);
  border-bottom: 2px solid var(--tvs-ink);
  padding: 18px 2px 16px;
  background: transparent;
}
.rp-mast-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.rp-mast-lead { min-width: 0; }
.rp-kicker {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--tvs-rust);
  margin-bottom: 8px;
}
.rp-headline {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  line-height: 1.08;
  letter-spacing: -0.3px;
  color: var(--tvs-ink);
  margin: 0 0 8px 0;
}
.rp-subline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--tvs-ink-2);
  letter-spacing: 0.2px;
}
.rp-subline .rp-dot { color: var(--tvs-line); }

.rp-badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--tvs-good);
  color: var(--tvs-good);
  border-radius: 0;
  font-family: 'Inter', sans-serif;
  font-size: 8.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  white-space: nowrap;
}
.rp-badge-you {
  border-color: var(--tvs-warn);
  color: var(--tvs-warn);
  margin-left: 6px;
}

/* ---- actions row ---- */
.rp-actions { display: flex; gap: 8px; align-items: center; flex: 0 0 auto; }
.rp-btn {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  color: #fff;
  background: var(--tvs-ink);
  border: 1px solid var(--tvs-ink);
  border-radius: 0;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.rp-btn:hover { background: var(--tvs-rust); border-color: var(--tvs-rust); }

/* ---- month sub-tabs (reuse .camp-tabs/.camp-tab from global CSS; local spacing) ---- */
.rp-month-tabs { margin: 0 0 18px; }

/* ==========================================================================
   KPI GRID (scorecard, channel mini-scorecard, market dealer_kpis)
   ========================================================================== */
.rp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border: 1px solid var(--tvs-line);
  background: var(--tvs-panel);
}
.rp-kpi-grid-tight { grid-template-columns: repeat(5, 1fr); }
.rp-kpi {
  border-right: 1px solid var(--tvs-line-soft);
  border-bottom: 1px solid var(--tvs-line-soft);
  padding: 12px 14px;
}
.rp-kpi-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tvs-muted);
  font-weight: 500;
}
.rp-kpi-value {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 23px;
  font-weight: 500;
  color: var(--tvs-ink);
  margin-top: 5px;
  letter-spacing: -0.3px;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.rp-kpi-sub { font-size: 10px; color: var(--tvs-muted); margin-top: 3px; }
.rp-kpi-delta {
  font-size: 10px;
  font-weight: 600;
  margin-top: 6px;
  letter-spacing: 0.2px;
  font-variant-numeric: tabular-nums;
}

/* delta / cell direction colors */
.rp-good { color: var(--tvs-good); }
.rp-warn { color: var(--tvs-warn); }
.rp-bad { color: var(--tvs-bad); }
.rp-muted { color: var(--tvs-muted); }
.rp-info { color: var(--tvs-info); }

/* ==========================================================================
   TABLES (month-over-month, market competitive set)
   ========================================================================== */
.rp-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rp-table th {
  text-align: left;
  padding: 7px 9px;
  color: var(--tvs-muted);
  font-weight: 600;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-top: 1px solid var(--tvs-ink);
  border-bottom: 1px solid var(--tvs-line);
}
.rp-table th.num, .rp-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rp-table td {
  padding: 6px 9px;
  border-bottom: 1px solid var(--tvs-line-soft);
  font-size: 12px;
  color: var(--tvs-body);
}
.rp-table tbody tr:hover td { background: var(--tvs-wash); }
.rp-mom td:first-child { color: var(--tvs-ink); font-weight: 500; }
.rp-table tr.rp-self td { background: var(--tvs-wash); font-weight: 600; }

/* ==========================================================================
   TRENDS (charts)
   ========================================================================== */
.rp-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rp-chart-wrap { position: relative; margin-top: 10px; width: 100%; }
.rp-chart-wrap.rp-h240 { height: 240px; }
.rp-chart-wrap.rp-h280 { height: 280px; }

/* ==========================================================================
   CHANNEL SPLIT (pure-CSS stacked share bars)
   ========================================================================== */
.rp-split-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.rp-split-block { min-width: 0; }
.rp-mini-label {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--tvs-muted);
  font-weight: 600;
  margin-bottom: 6px;
}
.rp-split-track {
  display: flex;
  height: 14px;
  background: var(--tvs-wash);
  overflow: hidden;
  border: 1px solid var(--tvs-line);
}
.rp-split-seg { height: 100%; }
.rp-split-ctv { background: var(--tvs-ink); }
.rp-split-aud { background: var(--tvs-rust); }
.rp-split-legend {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--tvs-body);
  font-variant-numeric: tabular-nums;
}
.rp-sw {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  vertical-align: middle;
}
.rp-sw-ctv { background: var(--tvs-ink); }
.rp-sw-aud { background: var(--tvs-rust); }

/* ==========================================================================
   THE READ (narrative)
   ========================================================================== */
.rp-read .rp-lead {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: grid;
  gap: 6px;
  border-bottom: 1px solid var(--tvs-line);
  padding-bottom: 14px;
}
.rp-lead-bullet {
  position: relative;
  padding: 2px 0 2px 26px;
  font-family: 'Newsreader', Georgia, serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--tvs-body);
}
.rp-lead-bullet::before {
  content: "—";
  position: absolute;
  left: 0;
  top: 2px;
  color: var(--tvs-rust);
  font-size: 15px;
}
.rp-read-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 28px;
  margin-top: 14px;
}
.rp-read-group { break-inside: avoid; }
.rp-read-kicker {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--tvs-rust);
  margin: 8px 0 4px;
}
.rp-read-list { list-style: none; margin: 0 0 6px; padding: 0; }
.rp-read-item {
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--tvs-body);
  padding: 3px 0;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.rp-footer {
  margin-top: 6px;
  padding: 12px 2px;
  text-align: center;
  color: var(--tvs-muted);
  font-size: 11px;
  font-family: 'Newsreader', Georgia, serif;
  font-style: italic;
  border-top: 1px solid var(--tvs-line);
}

/* ==========================================================================
   EMPTY / GATED STATES
   ========================================================================== */
.rp-empty {
  text-align: center;
  padding: 40px 30px;
  border: 1px dashed var(--tvs-line);
  background: transparent;
}
.rp-empty-title {
  font-family: 'Newsreader', Georgia, serif;
  font-size: 18px;
  color: var(--tvs-ink);
  margin-bottom: 6px;
}
.rp-empty-body { font-size: 12px; color: var(--tvs-muted); }

/* ==========================================================================
   RESPONSIVE (screen)
   ========================================================================== */
@media (max-width: 1200px) {
  .rp-kpi-grid, .rp-kpi-grid-tight { grid-template-columns: repeat(2, 1fr); }
  .rp-grid-2, .rp-split-wrap, .rp-read-groups { grid-template-columns: 1fr; }
  .rp-headline { font-size: 25px; }
}

/* ==========================================================================
   PRINT — scoped to body.rp-active so it ONLY bites while the report tab is
   active. On any other tab the guard in report.js removes .rp-active, so these
   rules never touch other tabs' printing.
   ========================================================================== */
@media print {
  body.rp-active {
    background: #fff !important;
    color: var(--tvs-ink) !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  /* Hide interactive chrome + anything opted out of print */
  body.rp-active .topbar-controls,
  body.rp-active .tabs,
  body.rp-active .camp-tabs,
  body.rp-active .rp-month-tabs,
  body.rp-active .rp-actions,
  body.rp-active #statusPill,
  body.rp-active #monthSelect,
  body.rp-active #clientSelect,
  body.rp-active #logoutLink,
  body.rp-active select,
  body.rp-active .no-print {
    display: none !important;
  }

  body.rp-active .wrap { max-width: none; margin: 0; padding: 0; }

  /* Keep the brand + report h1 as a printed letterhead */
  body.rp-active .topbar {
    border-bottom: 2px solid var(--tvs-ink);
    padding: 0 0 8px;
    margin-bottom: 8px;
  }

  /* Masthead spans full width */
  body.rp-active .rp-masthead { width: 100%; }

  /* Cards should not break across pages */
  body.rp-active .rp-card { break-inside: avoid; page-break-inside: avoid; }
  body.rp-active .rp-read-group { break-inside: avoid; page-break-inside: avoid; }
  body.rp-active .rp-table tr { break-inside: avoid; page-break-inside: avoid; }

  /* Charts must keep their canvas height (print collapses unsized wrappers) */
  body.rp-active .rp-chart-wrap.rp-h240 { height: 240px !important; }
  body.rp-active .rp-chart-wrap.rp-h280 { height: 280px !important; }
  body.rp-active .rp-chart-wrap canvas { max-height: 100% !important; }

  /* Footer prominent on the printed sheet */
  body.rp-active .rp-footer {
    font-style: normal;
    font-size: 12px;
    color: var(--tvs-ink);
    border-top: 2px solid var(--tvs-ink);
    margin-top: 14px;
  }

  body.rp-active .rp-card { border-color: var(--tvs-line); }

  @page { margin: 14mm; }
}
