/* ============================================================================
   ATLAS REDESIGN — Marketing (Tools) screen styles  ·  Phase 2
   Branch: atlas-redesign-2026-06-29

   Prefix: .rd-marketing. Tokens only (--r-*) so Calm (almanac) + Operator
   themes both work automatically. No hardcoded hex. Theme-specific selectors
   (html[data-rtheme="operator"] …) are used only where a token can't express
   the tweak (rare).
   ========================================================================== */

.rd-marketing {
  font-family: var(--r-font-body);
  color: var(--r-body);
  padding: var(--r-gutter);
  max-width: var(--r-page-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- page header --------------------------------------------------------- */
.rd-mkt-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rd-mkt-eyebrow {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-clay);
}
.rd-mkt-h1 {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h1);
  font-weight: 600;
  line-height: 1.1;
  color: var(--r-ink);
  margin: 0;
}
.rd-mkt-sub {
  margin: 2px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--r-muted);
  max-width: 640px;
}
.rd-mkt-org {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--r-mint-ink);
  background: var(--r-mint-surface);
  border-radius: var(--r-radius-pill);
  padding: 1px 8px;
}

/* ---- KPI strip (4-up) ---------------------------------------------------- */
.rd-mkt-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.rd-mkt-kpi {
  background: var(--r-surface);
  border: 1px solid var(--r-hairline-2);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.rd-mkt-kpi-label {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-faint);
}
.rd-mkt-kpi-value {
  font-family: var(--r-font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: var(--r-ink);
}

/* ---- main grid (campaigns | sources) ------------------------------------- */
.rd-mkt-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: start;
  min-height: 0;
}
.rd-mkt-col-main,
.rd-mkt-col-side {
  min-width: 0;
}

/* ---- shared card chrome -------------------------------------------------- */
.rd-mkt-campaigns,
.rd-mkt-sources {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 20px 22px;
  transition: box-shadow var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease);
}
.rd-mkt-campaigns:hover,
.rd-mkt-sources:hover {
  box-shadow: var(--r-shadow-hover);
  transform: translateY(-2px);
}
.rd-mkt-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.rd-mkt-card-title {
  margin: 0;
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  color: var(--r-ink);
}
.rd-mkt-card-note {
  font-size: 12px;
  color: var(--r-muted);
}

/* ---- campaigns list ------------------------------------------------------ */
.rd-mkt-camp-list {
  display: flex;
  flex-direction: column;
  margin-top: 6px;
  overflow: auto;
  max-height: calc(100vh - 360px);
}
.rd-mkt-camp {
  padding: 13px 8px;
  margin: 0 -8px;
  border-top: 1px solid var(--r-hairline);
  border-radius: var(--r-radius-control);
  transition: background var(--r-dur) var(--r-ease);
}
.rd-mkt-camp:first-child { border-top: none; }
/* polish-only — no per-row date/URL exists yet, so no cross-nav here. */
.rd-mkt-camp:hover { background: var(--r-canvas-raised); }
.rd-mkt-camp-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rd-mkt-camp-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--r-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* channel tag (META / GOOGLE / EMAIL …) — semantic tone only */
.rd-mkt-tag {
  flex: 0 0 auto;
  font-family: var(--r-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: var(--r-radius-chip);
  padding: 2px 7px;
  background: var(--r-well);
  color: var(--r-muted);
}
.rd-mkt-tag[data-tone="info"] {
  background: color-mix(in srgb, var(--r-info) 16%, transparent);
  color: var(--r-info);
}
.rd-mkt-tag[data-tone="good"] {
  background: var(--r-mint-surface);
  color: var(--r-mint-ink);
}

.rd-mkt-camp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-muted);
  margin: 6px 0;
}
.rd-mkt-camp-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* budget-progress bar */
.rd-mkt-bar {
  height: 6px;
  border-radius: 5px;
  background: var(--r-well);
  overflow: hidden;
}
.rd-mkt-bar-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--r-primary);
  transition: width var(--r-dur) var(--r-ease);
}
.rd-mkt-bar-fill[data-tone="good"] { background: var(--r-primary-2); }
.rd-mkt-bar-fill[data-empty="1"] { width: 0; background: transparent; }

/* ---- lead sources list --------------------------------------------------- */
.rd-mkt-src-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin-top: 14px;
}
.rd-mkt-src {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  margin: 0 -8px;
  border-radius: var(--r-radius-control);
  cursor: pointer;
  transition: background var(--r-dur) var(--r-ease);
}
/* cross-nav to Client CRM — see marketing.js sourceRowHTML() */
.rd-mkt-src:hover,
.rd-mkt-src:focus-visible { background: var(--r-canvas-raised); }
.rd-mkt-src-caret {
  flex: none;
  color: var(--r-muted);
  font-size: 12px;
  opacity: 0;
  transition: opacity .12s ease;
}
.rd-mkt-src:hover .rd-mkt-src-caret,
.rd-mkt-src:focus-visible .rd-mkt-src-caret { opacity: .9; }
.rd-mkt-src-label {
  flex: none;
  width: 64px;
  font-size: 12.5px;
  color: var(--r-body);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-mkt-src[data-ai="1"] .rd-mkt-src-label {
  color: var(--r-mint-ink);
  font-weight: 600;
}
.rd-mkt-src-bar {
  flex: 1;
  height: 8px;
  border-radius: 5px;
  background: var(--r-well);
  overflow: hidden;
}
.rd-mkt-src-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--r-primary);
  transition: width var(--r-dur) var(--r-ease);
}
.rd-mkt-src-fill[data-tone="good"] { background: var(--r-primary-2); }
.rd-mkt-src-fill[data-empty="1"] { width: 0; background: transparent; }
.rd-mkt-src-pct {
  flex: none;
  width: 34px;
  text-align: right;
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-muted);
}
.rd-mkt-src[data-ai="1"] .rd-mkt-src-pct { color: var(--r-mint-ink); }

/* ---- empty states (honest, dashed) --------------------------------------- */
.rd-mkt-empty {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .02em;
  line-height: 1.6;
  color: var(--r-faint);
  text-align: center;
  padding: 26px 14px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
  margin: 10px 2px 2px;
}

/* ---- focus visibility (keyboard) ----------------------------------------- */
.rd-marketing :focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* ---- entrance motion (respects reduced-motion) ---------------------------- */
.rd-mkt-campaigns, .rd-mkt-sources { animation: rdMktIn .28s var(--r-ease); }
@keyframes rdMktIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- honest states: loading (transient) vs empty/not-connected (durable) —
   only the initial "Loading…" shell state pulses; a real not-connected or
   no-data message stays a static, calm dashed box. -------------------------- */
.rd-mkt-empty[data-state="loading"] { animation: rdMktPulse 1.4s ease-in-out infinite; }
@keyframes rdMktPulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .rd-mkt-campaigns, .rd-mkt-sources { animation: none; }
  .rd-mkt-campaigns:hover, .rd-mkt-sources:hover { transform: none; }
  .rd-mkt-empty[data-state="loading"] { animation: none; }
}

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 980px) {
  .rd-mkt-grid { grid-template-columns: 1fr; }
  .rd-mkt-camp-list { max-height: 52vh; }
}
@media (max-width: 720px) {
  .rd-mkt-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .rd-marketing { padding: 14px; }
  .rd-mkt-campaigns, .rd-mkt-sources { padding: 16px; }
  .rd-mkt-camp-meta { flex-wrap: wrap; }
  .rd-mkt-src-label { width: 52px; }
  .rd-mkt-kw { flex-wrap: wrap; }
  .rd-mkt-kw-q { flex: 1 1 100%; }
}

/* W-F5S3: search-performance card (real GSC rows) */
.rd-mkt-kw-list { display: flex; flex-direction: column; }
.rd-mkt-kw {
  display: flex; align-items: baseline; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--r-hairline-2);
}
.rd-mkt-kw:last-child { border-bottom: 0; }
.rd-mkt-kw-q { flex: 1 1 auto; font-size: 13.5px; color: var(--r-ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rd-mkt-kw-clicks { font-family: var(--r-font-mono); font-size: 12px; color: var(--r-muted); white-space: nowrap; }
.rd-mkt-kw-pos { font-family: var(--r-font-mono); font-size: 12.5px; color: var(--r-body); width: 52px; text-align: right; }
.rd-mkt-kw-delta { font-family: var(--r-font-mono); font-size: 12px; width: 52px; text-align: right; }
.rd-mkt-kw-delta[data-tone="good"]  { color: var(--r-good); }
.rd-mkt-kw-delta[data-tone="alert"] { color: var(--r-alert); }
.rd-mkt-rank-chips { display: inline-flex; gap: 8px; margin-left: 10px; }
.rd-mkt-rank { font-family: var(--r-font-mono); font-size: 12px; padding: 2px 8px; border-radius: var(--r-radius-badge); border: 1px solid var(--r-border); }
.rd-mkt-rank[data-tone="good"]  { color: var(--r-good); }
.rd-mkt-rank[data-tone="alert"] { color: var(--r-alert); }
.rd-mkt-search { margin-bottom: 14px; }
