/* ============================================================================
   ATLAS REDESIGN — Briefs screen styles (Morning + End-of-day AI briefs)  ·  Phase 2
   Branch: atlas-redesign-2026-06-29

   Prefix: .rd-briefs. 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). Brief body scrolls internally; outer frame never scrolls.
   ========================================================================== */

.rd-briefs {
  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;
  min-height: 0;
}

/* ---- header row ---------------------------------------------------------- */
.rd-brief-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.rd-brief-head-l {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rd-brief-eyebrow {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-clay);
}
.rd-brief-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-brief-head-r {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- segmented Morning / End of day toggle ------------------------------- */
.rd-brief-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--r-well);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-control);
  padding: 3px;
}
.rd-brief-seg {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--r-faint);
  font-family: var(--r-font-body);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1;
  padding: 7px 14px;
  border-radius: calc(var(--r-radius-control) - 3px);
  cursor: pointer;
  transition: color var(--r-dur) var(--r-ease),
              background var(--r-dur) var(--r-ease),
              box-shadow var(--r-dur) var(--r-ease);
}
.rd-brief-seg:hover { color: var(--r-body); }
.rd-brief-seg.is-active {
  background: var(--r-surface);
  color: var(--r-primary);
  font-weight: 600;
  box-shadow: var(--r-shadow-card);
}
.rd-brief-seg:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* ---- deliver actions (W465/W468: opt-in Email / PDF — bryan@-only, $0, no AI rewrite) ----
   Premium two-button pattern lifted from the v2.6 mockup: a primary solid + a ghost,
   38px tall, 10px radius. Lives in the card footer (not the header). Tokens only. */
.rd-brief-deliver { display: inline-flex; align-items: center; gap: 8px; }
.rd-brief-deliver-btn {
  display: inline-flex; align-items: center; gap: 7px;
  appearance: none; cursor: pointer;
  height: 38px; padding: 0 15px;
  font-family: var(--r-font-body); font-size: 13px; font-weight: 600; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-radius-control);
  transition: color var(--r-dur) var(--r-ease),
              border-color var(--r-dur) var(--r-ease),
              background var(--r-dur) var(--r-ease),
              box-shadow var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease),
              filter var(--r-dur) var(--r-ease);
}
.rd-brief-deliver-btn i { font-size: 15px; }
.rd-brief-deliver-btn:active { transform: translateY(.5px); }
.rd-brief-deliver-btn:focus-visible { outline: var(--r-focus); outline-offset: 2px; }
.rd-brief-deliver-btn[disabled] { opacity: .6; cursor: default; }
/* Email me = primary solid (evergreen / azure) */
.rd-brief-deliver-btn[data-act="email"] {
  background: var(--r-primary); color: var(--r-primary-ink); border-color: var(--r-primary);
  box-shadow: var(--r-shadow-card);
}
.rd-brief-deliver-btn[data-act="email"]:hover { filter: brightness(.95); }
/* PDF = ghost bordered */
.rd-brief-deliver-btn[data-act="pdf"] {
  background: var(--r-surface); color: var(--r-body); border-color: var(--r-border);
}
.rd-brief-deliver-btn[data-act="pdf"]:hover { color: var(--r-primary); border-color: var(--r-primary); }
/* result states override the per-act fills */
.rd-brief-deliver-btn.is-ok  { background: var(--r-mint-surface); color: var(--r-mint-ink); border-color: var(--r-mint-ink); filter: none; box-shadow: none; }
.rd-brief-deliver-btn.is-err { background: var(--r-surface); color: var(--r-alert); border-color: var(--r-alert); filter: none; box-shadow: none; }

/* ---- brief stack (holds both cards; one shown at a time) ----------------- */
.rd-brief-stack {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ---- brief card ---------------------------------------------------------- */
.rd-brief-card {
  width: 100%;
  max-width: 880px;
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 26px 30px;
  display: flex;
  flex-direction: column;
  /* the body scrolls internally; outer frame never scrolls */
  max-height: calc(100vh - 220px);
  overflow: auto;
}
.rd-brief-card[hidden] { display: none; }

/* card head row: chip + generated time */
.rd-brief-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

/* type chip (pill) */
.rd-brief-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-radius: var(--r-radius-pill);
  padding: 4px 11px;
}
.rd-brief-chip i { font-size: 13px; }
.rd-brief-chip-am {
  background: var(--r-mint-surface);
  color: var(--r-mint-ink);
}
.rd-brief-chip-pm {
  background: var(--r-chip-down-surface);
  color: var(--r-chip-down-ink);
}

/* generated-at timestamp */
.rd-brief-time {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .03em;
  color: var(--r-faint);
  white-space: nowrap;
}
/* date hierarchy: a brief still showing from a prior day reads differently
   than one generated this morning — same data, just a real-signal color cue. */
.rd-brief-time[data-stale="1"] { color: var(--r-amber); }

/* greeting headline */
.rd-brief-greet {
  font-family: var(--r-font-display);
  font-size: 23px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--r-ink);
  margin: 0 0 15px;
}

/* summary paragraphs — editorial reading rhythm: a measured line length reads
   like a brief, not a stretched-out gray column. */
.rd-brief-summary {
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.rd-brief-para {
  font-family: var(--r-font-body);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--r-body);
  max-width: 66ch;
  margin: 0;
}
/* the lede reads first and slightly louder, same as an editorial opening line */
.rd-brief-para:first-child {
  font-size: 15.5px;
  color: var(--r-ink);
}
/* editorial emphasis inside prose (money / percent / "N of M") */
.rd-brief-em {
  font-weight: 700;
  color: var(--r-ink);
  font-variant-numeric: tabular-nums;
}

/* ---- KPI metric ledger (the real gpr-briefs "Label: value" block) ---------
   Two-column ruled ledger: mono uppercase label, display-serif value. Turns the
   loose gray metric dump into a boardroom-grade block. KpiCard type vocabulary. */
.rd-brief-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 44px;
  margin: 2px 0 2px;
}
.rd-brief-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid var(--r-hairline);
}
/* drop the rule under the final row (last item, and its left-column partner) */
.rd-brief-metric:last-child,
.rd-brief-metric:nth-last-child(2):nth-child(odd) {
  border-bottom: none;
}
.rd-brief-metric-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--r-font-mono);
  font-size: 10.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--r-faint);
}
.rd-brief-metric-value {
  flex: none;
  font-family: var(--r-font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -.01em;
  line-height: 1.1;
  color: var(--r-ink);
  font-variant-numeric: tabular-nums;
}
/* hierarchy: the ledger's first line is the brief's lead figure — let it lead */
.rd-brief-metric:first-child .rd-brief-metric-value {
  font-size: 21px;
  color: var(--r-primary);
}
@media (max-width: 640px) {
  .rd-brief-metrics { grid-template-columns: 1fr; column-gap: 0; }
  .rd-brief-metric:nth-last-child(2):nth-child(odd) { border-bottom: 1px solid var(--r-hairline); }
}

/* ---- actions / loose-ends ------------------------------------------------ */
.rd-brief-actions-label {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-faint);
  margin: 28px 0 10px;
}
.rd-brief-actions {
  display: flex;
  flex-direction: column;
}
.rd-brief-action {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 8px;
  margin: 0 -8px;                 /* hover tint bleeds past content, text stays aligned */
  border-top: 1px solid var(--r-hairline);
  transition: background var(--r-dur) var(--r-ease);
}
.rd-brief-action:first-child { border-top: none; }
.rd-brief-action:hover,
.rd-brief-action:focus-within { background: var(--r-surface-2); }
.rd-brief-action:hover .rd-brief-check { border-color: var(--r-primary); }
.rd-brief-action:hover .rd-brief-action-title,
.rd-brief-action:focus-within .rd-brief-action-title { color: var(--r-primary); }

/* go-caret: surfaces on hover/focus to confirm the row drills into Tasks */
.rd-brief-action-go {
  flex: 0 0 auto;
  align-self: center;
  font-size: 13px;
  color: var(--r-faint);
  opacity: 0;
  transform: translateX(-3px);
  transition: opacity var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease),
              color var(--r-dur) var(--r-ease);
}
.rd-brief-action:hover .rd-brief-action-go,
.rd-brief-action-body:focus-visible ~ .rd-brief-action-go {
  opacity: 1;
  transform: none;
  color: var(--r-primary);
}

/* round checkbox */
.rd-brief-check {
  appearance: none;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 1px;
  border: 1.5px solid var(--r-border);
  border-radius: 50%;
  background: var(--r-surface);
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color var(--r-dur) var(--r-ease),
              background var(--r-dur) var(--r-ease),
              color var(--r-dur) var(--r-ease);
}
.rd-brief-check i { font-size: 13px; font-weight: 700; line-height: 1; }
.rd-brief-check:hover { border-color: var(--r-primary); }
.rd-brief-check[aria-checked="true"] {
  background: var(--r-primary);
  border-color: var(--r-primary);
  color: var(--r-primary-ink);
}
.rd-brief-check:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

.rd-brief-action-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-radius: 7px;
}
/* the body is its own drill-down target (→ Tasks); the checkbox is a sibling
   control, so this never nests two interactive widgets */
.rd-brief-action-body[data-brief-open] { cursor: pointer; }
.rd-brief-action-body[data-brief-open]:focus-visible {
  outline: var(--r-focus);
  outline-offset: 2px;
}
.rd-brief-action-title {
  font-family: var(--r-font-body);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--r-ink);
  transition: color var(--r-dur) var(--r-ease);
}
.rd-brief-action-sub {
  font-family: var(--r-font-body);
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--r-muted);
  transition: color var(--r-dur) var(--r-ease);
}
.rd-brief-action.is-done .rd-brief-action-title {
  text-decoration: line-through;
  color: var(--r-faint);
}
.rd-brief-action.is-done .rd-brief-action-sub {
  color: var(--r-faint);
}

/* ---- card footer: sync note (left) + deliver bar (right) ----------------- */
.rd-brief-cardfoot {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--r-hairline);
}
.rd-brief-cardfoot .rd-brief-deliver { margin-left: auto; }

/* footer sync note (icon + text) — mockup's arrows-clockwise line */
.rd-brief-foot {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--r-font-body);
  font-size: 12px;
  line-height: 1.5;
  color: var(--r-muted);
  margin: 0;
  max-width: 52ch;
}
.rd-brief-foot i {
  font-size: 14px;
  color: var(--r-primary);
  flex: none;
}

/* ---- empty state inside a card ------------------------------------------- */
.rd-brief-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 34px 16px;
}
.rd-brief-empty i {
  font-size: 30px;
  color: var(--r-faint);
}
.rd-brief-empty-title {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  color: var(--r-body);
  margin: 2px 0 0;
}
.rd-brief-empty-note {
  font-family: var(--r-font-body);
  font-size: var(--r-fs-body);
  color: var(--r-muted);
  margin: 0;
}
/* kind-specific tone — the reason a card is empty is real (read off the fetch
   envelope), so it earns a distinct icon + tone rather than one gray box for
   "loading", "never connected", "fetch failed" and "genuinely nothing yet". */
.rd-brief-empty[data-kind="error"] i { color: var(--r-clay); }
.rd-brief-empty[data-kind="error"] .rd-brief-empty-title { color: var(--r-clay-2); }
.rd-brief-empty[data-kind="connect"] i { color: var(--r-muted); }

/* ---- entrance ------------------------------------------------------------ */
/* the visible card rises in — and re-rises when you flip Morning ⇄ End of day */
@keyframes rd-brief-rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: none; }
}
.rd-brief-card:not([hidden]):not([data-empty]) {
  animation: rd-brief-rise .34s var(--r-ease) both;
}
/* action rows stagger in just behind the card (subtle, capped at 6 steps) */
@keyframes rd-brief-action-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.rd-brief-card:not([hidden]):not([data-empty]) .rd-brief-action {
  animation: rd-brief-action-rise .3s var(--r-ease) both;
}
.rd-brief-action:nth-child(1) { animation-delay: 60ms; }
.rd-brief-action:nth-child(2) { animation-delay: 90ms; }
.rd-brief-action:nth-child(3) { animation-delay: 120ms; }
.rd-brief-action:nth-child(4) { animation-delay: 150ms; }
.rd-brief-action:nth-child(5) { animation-delay: 180ms; }
.rd-brief-action:nth-child(n+6) { animation-delay: 210ms; }
@media (prefers-reduced-motion: reduce) {
  .rd-brief-card { animation: none; }
  .rd-brief-action { transition: none; animation: none; }
  .rd-brief-action-go,
  .rd-brief-action-title { transition: none; }
}
html[data-rmotion="reduced"] .rd-brief-card { animation: none; }
html[data-rmotion="reduced"] .rd-brief-action { transition: none; animation: none; }
html[data-rmotion="reduced"] .rd-brief-action-go,
html[data-rmotion="reduced"] .rd-brief-action-title { transition: none; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 720px) {
  .rd-brief-card { padding: 20px 18px; max-height: calc(100vh - 180px); }
  .rd-brief-greet { font-size: 20px; }
}
@media (max-width: 480px) {
  .rd-brief-card { padding: 16px 14px; }
  .rd-brief-card-head { flex-wrap: wrap; row-gap: 6px; }
  .rd-brief-actions-label { margin: 18px 0 6px; }
  .rd-brief-cardfoot .rd-brief-deliver { margin-left: 0; width: 100%; }
  .rd-brief-deliver-btn { flex: 1 1 auto; justify-content: center; }
}
