/* ============================================================================
   ATLAS REDESIGN — Goals & Targets screen styles  ·  Phase 2
   Branch: atlas-redesign-2026-06-29

   Prefix: .rd-goals. 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). Inner panels scroll; the outer frame never does.
   ========================================================================== */

.rd-goals {
  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-goals-head {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rd-goals-eyebrow {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--r-clay);
}
.rd-goals-h1 {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h1);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--r-ink);
  margin: 0;
}
.rd-goals-sub {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--r-muted);
  max-width: 640px;
}

/* ---- KPI strip (4-up) ---------------------------------------------------- */
.rd-goals-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.rd-goals-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: 6px;
}
.rd-goals-kpi-label {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--r-faint);
}
.rd-goals-kpi-value {
  font-family: var(--r-font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: var(--r-ink);
}
.rd-goals-kpi-sub {
  font-size: 12px;
  color: var(--r-faint);
}
.rd-goals-kpi[data-tone="good"] .rd-goals-kpi-sub { color: var(--r-good); font-weight: 600; }
.rd-goals-kpi[data-tone="warn"] .rd-goals-kpi-sub { color: var(--r-amber); font-weight: 600; }

/* ---- not-connected banner ------------------------------------------------ */
.rd-goals-banner {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .03em;
  color: var(--r-muted);
  background: var(--r-well);
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
  padding: 9px 14px;
}

/* ---- two-column grid ----------------------------------------------------- */
.rd-goals-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 16px;
  align-items: start;
  min-height: 0;
}
.rd-goals-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

/* ---- shared card --------------------------------------------------------- */
.rd-goals-card {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 18px 20px;
  animation: rdGoalsIn .28s var(--r-ease);
  transition: box-shadow var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease);
}
.rd-goals-card:hover {
  box-shadow: var(--r-shadow-hover);
  transform: translateY(-2px);
}
@keyframes rdGoalsIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.rd-goals-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.rd-goals-card-title {
  margin: 0;
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  color: var(--r-ink);
}
.rd-goals-card-meta {
  font-size: 12px;
  color: var(--r-muted);
}
.rd-goals-card-meta strong { color: var(--r-ink); font-weight: 600; }

/* ---- annual progress bar ------------------------------------------------- */
.rd-goals-bar {
  position: relative;
  height: 14px;
  border-radius: var(--r-radius-badge);
  background: var(--r-well);
  overflow: hidden;
  margin-top: 14px;
}
.rd-goals-bar-fill {
  height: 100%;
  border-radius: var(--r-radius-badge);
  background: linear-gradient(90deg, var(--r-primary), var(--r-primary-2));
  transition: width var(--r-dur) var(--r-ease);
}
/* ahead/behind pace — derived from the real pctNum vs. the real elapsed-year
   pace mark already computed in buildModel(). "good" keeps the default
   gradient (already reads as on-track); "warn" flags genuinely behind. */
.rd-goals-bar-fill[data-tone="warn"] { background: linear-gradient(90deg, var(--r-amber), var(--r-amber)); }
.rd-goals-bar-pace {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--r-amber);
}
.rd-goals-bar-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-faint);
}
.rd-goals-bar-marker { color: var(--r-amber); }
.rd-goals-proj {
  margin: 13px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--r-body);
}
.rd-goals-proj strong { color: var(--r-ink); font-weight: 600; }

/* ---- quarter scorecard --------------------------------------------------- */
.rd-goals-scorelist { margin-top: 6px; }
.rd-goals-scorerow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--r-hairline);
  border-radius: 8px;
  transition: background var(--r-dur) var(--r-ease);
}
.rd-goals-scorerow:first-child { border-top: none; }
.rd-goals-scorerow:hover { background: var(--r-canvas-raised); }
.rd-goals-scorerow-name {
  flex: 1;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--r-ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rd-goals-scorerow-goal {
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-faint);
}
.rd-goals-scorerow-actual {
  font-family: var(--r-font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--r-ink);
  width: 64px;
  text-align: right;
}
.rd-goals-scorerow-flag {
  font-family: var(--r-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: 5px;
  padding: 2px 7px;
  background: var(--r-well);
  color: var(--r-muted);
}
.rd-goals-scorerow-flag[data-tone="good"] { background: var(--r-mint-surface); color: var(--r-mint-ink); }
.rd-goals-scorerow-flag[data-tone="warn"] {
  background: color-mix(in srgb, var(--r-amber) 16%, transparent);
  color: var(--r-amber);
}

/* ---- conversion funnel --------------------------------------------------- */
.rd-goals-funnel {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-top: 16px;
}
.rd-goals-funnel-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.rd-goals-funnel-label { color: var(--r-body); }
.rd-goals-funnel-meta {
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-faint);
}
.rd-goals-funnel-bar {
  height: 9px;
  border-radius: 6px;
  background: var(--r-well);
  overflow: hidden;
}
.rd-goals-funnel-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--r-primary), var(--r-primary-2));
  transition: width var(--r-dur) var(--r-ease);
}
.rd-goals-funnel-fill[data-last="1"] { background: var(--r-primary-2); }

/* ---- team goals ---------------------------------------------------------- */
.rd-goals-agents { margin-top: 8px; }
.rd-goals-agent {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--r-hairline);
  border-radius: 8px;
  transition: background var(--r-dur) var(--r-ease);
}
.rd-goals-agent:first-child { border-top: none; }
.rd-goals-agent:hover { background: var(--r-canvas-raised); }
.rd-goals-agent-av {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--r-well);
  color: var(--r-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--r-font-mono);
  font-size: 11px;
  font-weight: 600;
}
.rd-goals-agent-body { flex: 1; min-width: 0; }
.rd-goals-agent-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--r-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rd-goals-agent-bar {
  height: 5px;
  border-radius: 4px;
  background: var(--r-well);
  margin-top: 5px;
  overflow: hidden;
}
.rd-goals-agent-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--r-primary);
  transition: width var(--r-dur) var(--r-ease);
}
.rd-goals-agent-fill[data-tone="good"] { background: var(--r-primary-2); }
.rd-goals-agent-fill[data-tone="warn"] { background: var(--r-amber); }
.rd-goals-agent-nums { flex: none; text-align: right; }
.rd-goals-agent-val {
  font-family: var(--r-font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--r-ink);
}
.rd-goals-agent-goal {
  font-size: 12px;
  color: var(--r-faint);
}

/* ---- weekly activity goals ----------------------------------------------- */
.rd-goals-activities { margin-top: 8px; }
.rd-goals-activity {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--r-hairline);
  border-radius: 8px;
  transition: background var(--r-dur) var(--r-ease);
}
.rd-goals-activity:first-child { border-top: none; }
.rd-goals-activity:hover { background: var(--r-canvas-raised); }
.rd-goals-activity-label {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--r-ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rd-goals-activity-bar {
  flex: none;
  width: 90px;
  height: 6px;
  border-radius: 4px;
  background: var(--r-well);
  overflow: hidden;
}
.rd-goals-activity-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--r-primary);
  transition: width var(--r-dur) var(--r-ease);
}
.rd-goals-activity-fill[data-tone="good"] { background: var(--r-primary-2); }
.rd-goals-activity-fill[data-tone="warn"] { background: var(--r-amber); }
.rd-goals-activity-count {
  flex: none;
  width: 54px;
  text-align: right;
  font-family: var(--r-font-mono);
  font-size: 12px;
  color: var(--r-body);
}

/* ---- honest empty state -------------------------------------------------- */
.rd-goals-empty {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .03em;
  color: var(--r-faint);
  text-align: center;
  padding: 18px 12px;
  margin-top: 12px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
}

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

@media (prefers-reduced-motion: reduce) {
  .rd-goals-card { animation: none; }
  .rd-goals-card:hover { transform: none; }
}

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 980px) {
  .rd-goals-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .rd-goals-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .rd-goals-kpis { grid-template-columns: 1fr; }
  .rd-goals-kpi-value { font-size: 20px; }
  .rd-goals-scorerow-goal { display: none; }
}
