/* Raven components. Plain CSS, no build step: this file is raven.css in the app (public/css/raven.css), loaded after tokens.css.
   Every colour, space, corner and shadow is a token. Motion lives here because tokens.json has no motion family. */
:root {
  --dur-1: 120ms;   /* hover, press, focus */
  --dur-2: 200ms;   /* a control changing state: switch, tab, menu opening */
  --dur-3: 420ms;   /* a chart drawing in, once, on first paint */
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --rv-sans: var(--font-sans, "Archivo", "Helvetica Neue", Arial, sans-serif);
  --rv-narrow: var(--font-narrow, "Archivo Narrow", "Arial Narrow", Arial, sans-serif);
  --rv-wordmark: var(--font-wordmark, "Marcellus", Georgia, serif);
}
.rv, .rv * { box-sizing: border-box; }
.rv { font: 400 14px/20px var(--rv-sans); color: var(--ink); -webkit-font-smoothing: antialiased; }
.rv :where(button, input, select, textarea) { font: inherit; color: inherit; }
.rv :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rv-num { font-variant-numeric: tabular-nums; }
.rv-muted { color: var(--ink-3); }
.rv-2 { color: var(--ink-2); }
.rv-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; min-width: 0; }
.rv-col { display: flex; flex-direction: column; gap: var(--space-2); min-width: 0; }
.rv-label { font: 600 11px/14px var(--rv-narrow); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }

/* ---------- panel: the one container. Hairline, no shadow. Do not nest. ---------- */
.rv-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-3); }
.rv-panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.rv-panel-head h3 { margin: 0; font: 600 15px/20px var(--rv-sans); }
.rv-panel-body { padding: var(--space-5); }

/* ---------- buttons ---------- */
.rv-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 36px; padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-2); background: transparent; font: 500 14px/20px var(--rv-sans); white-space: nowrap; cursor: pointer; text-decoration: none; transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out); }
.rv-btn svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rv-btn:active { transform: translateY(1px); }
.rv-btn--primary { background: var(--feather); color: var(--on-feather); }
.rv-btn--primary:hover, .rv-btn--primary.is-hover { background: var(--feather-hover); }
.rv-btn--secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.rv-btn--secondary:hover, .rv-btn--secondary.is-hover { background: var(--surface-sunken); border-color: var(--ink-2); }
.rv-btn--quiet { color: var(--gloss); padding: 0 var(--space-2); }
.rv-btn--quiet:hover, .rv-btn--quiet.is-hover { color: var(--gloss-hover); background: var(--gloss-tint); }
.rv-btn--stop { background: var(--stop-fill); color: var(--on-stop); }
.rv-btn--stop:hover, .rv-btn--stop.is-hover { filter: brightness(0.92); }
.rv-btn--sm { height: 28px; padding: 0 var(--space-3); font-size: 13px; }
.rv-btn.is-focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.rv-btn.is-pressed { transform: translateY(1px); }
.rv-btn[disabled], .rv-btn[aria-disabled="true"] { background: var(--surface-sunken); border-color: transparent; color: var(--ink-3); cursor: not-allowed; transform: none; filter: none; }
.rv-btn[aria-busy="true"] { cursor: progress; pointer-events: none; }
.rv-btn[aria-busy="true"]::before { content: ""; width: 12px; height: 12px; border-radius: var(--radius-round); border: 1.5px solid currentColor; border-right-color: transparent; animation: rv-spin 700ms linear infinite; }
@keyframes rv-spin { to { transform: rotate(360deg); } }

/* ---------- fields ---------- */
.rv-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rv-field > label { font: 500 13px/18px var(--rv-sans); color: var(--ink); }
.rv-input, .rv-select, .rv-textarea { width: 100%; min-height: 36px; padding: 7px var(--space-3); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-2); color: var(--ink); transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out); }
.rv-input::placeholder, .rv-textarea::placeholder { color: var(--ink-3); }
.rv-input:hover, .rv-select:hover, .rv-textarea:hover { border-color: var(--ink-2); }
.rv-input:focus, .rv-select:focus, .rv-textarea:focus, .rv-input.is-focus { outline: none; border-color: var(--gloss); box-shadow: 0 0 0 2px var(--gloss-tint); }
.rv-input[aria-invalid="true"] { border-color: var(--stop); }
.rv-input[disabled], .rv-select[disabled] { background: var(--surface-sunken); border-color: var(--line); color: var(--ink-3); cursor: not-allowed; }
.rv-help { font: 400 13px/18px var(--rv-sans); color: var(--ink-3); }
.rv-error { font: 400 13px/18px var(--rv-sans); color: var(--stop); }
.rv-count { font: 400 12px/16px var(--rv-sans); color: var(--ink-3); font-variant-numeric: tabular-nums; margin-left: auto; }
.rv-check { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.rv-check input { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-1); background: var(--surface); display: grid; place-content: center; transition: background-color var(--dur-1) var(--ease-out); }
.rv-check input:checked { background: var(--feather); border-color: var(--feather); }
.rv-check input:checked::after { content: ""; width: 8px; height: 4px; border-left: 1.5px solid var(--on-feather); border-bottom: 1.5px solid var(--on-feather); transform: translateY(-1px) rotate(-45deg); }
.rv-switch { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.rv-switch input { appearance: none; width: 32px; height: 18px; margin: 0; border-radius: var(--radius-round); background: var(--line-strong); position: relative; transition: background-color var(--dur-2) var(--ease-in-out); }
.rv-switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: var(--radius-round); background: var(--surface); transition: transform var(--dur-2) var(--ease-in-out); }
.rv-switch input:checked { background: var(--gloss); }
.rv-switch input:checked::after { transform: translateX(14px); }
.rv-switch input[disabled] { opacity: 0.55; cursor: not-allowed; }
.rv-seg { display: inline-flex; align-self: flex-start; border: 1px solid var(--line-strong); border-radius: var(--radius-2); overflow: hidden; background: var(--surface); }
.rv-seg button { height: 34px; padding: 0 var(--space-4); border: 0; background: transparent; font: 500 14px/20px var(--rv-sans); color: var(--ink-2); cursor: pointer; transition: background-color var(--dur-2) var(--ease-in-out), color var(--dur-2) var(--ease-in-out); }
.rv-seg button + button { border-left: 1px solid var(--line-strong); }
.rv-seg button[aria-pressed="true"] { background: var(--feather); color: var(--on-feather); }
.rv-seg button[disabled] { cursor: not-allowed; }

/* ---------- status: a dot and a word. Never a pill, never colour alone. ---------- */
.rv-status { display: inline-flex; align-items: center; gap: 6px; font: 500 13px/18px var(--rv-sans); color: var(--ink); white-space: nowrap; }
.rv-status::before { content: ""; width: 8px; height: 8px; border-radius: var(--radius-round); background: var(--ink-3); flex: none; }
.rv-status--clear::before { background: var(--clear); }
.rv-status--watch::before { background: var(--watch); }
.rv-status--stop::before { background: var(--stop); }
.rv-status--shadow::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-2); }
.rv-status--draft::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--ink-3); border-radius: var(--radius-1); }
.rv-status--sending::before { background: var(--gloss); animation: rv-pulse 1.6s var(--ease-in-out) infinite; }
@keyframes rv-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--gloss-tint); } 50% { box-shadow: 0 0 0 4px var(--gloss-tint); } }

/* ---------- notices: tinted ground, icon, words. No coloured edge. ---------- */
.rv-notice { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); border-radius: var(--radius-2); background: var(--gloss-tint); color: var(--ink); }
.rv-notice svg { width: 18px; height: 18px; flex: none; margin-top: 1px; fill: none; stroke: var(--gloss); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.rv-notice strong { font-weight: 600; }
.rv-notice p { margin: 0; }
.rv-notice .rv-btn { margin-left: auto; flex: none; }
.rv-notice--clear { background: var(--clear-tint); } .rv-notice--clear svg { stroke: var(--clear); }
.rv-notice--watch { background: var(--watch-tint); } .rv-notice--watch svg { stroke: var(--watch); }
.rv-notice--stop { background: var(--stop-tint); } .rv-notice--stop svg { stroke: var(--stop); }
.rv-toast { display: inline-flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); background: var(--feather); color: var(--on-feather); border-radius: var(--radius-2); box-shadow: var(--shadow-menu); font: 500 14px/20px var(--rv-sans); animation: rv-rise var(--dur-2) var(--ease-out) both; }
@keyframes rv-rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- figures: numbers in a row divided by hairlines, not a card each ---------- */
.rv-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-3); }
.rv-figure { padding: var(--space-4) var(--space-5); border-left: 1px solid var(--line); min-width: 0; }
.rv-figure:first-child { border-left: 0; }
.rv-figure .rv-label { display: block; margin-bottom: 6px; }
.rv-figure-value { font: 600 34px/36px var(--rv-narrow); font-variant-numeric: tabular-nums; color: var(--ink); }
.rv-figure--m .rv-figure-value { font-size: 22px; line-height: 26px; }
.rv-figure-note { margin-top: 6px; font: 400 12px/16px var(--rv-sans); color: var(--ink-3); }
.rv-delta { font: 500 12px/16px var(--rv-sans); font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.rv-delta--up::before { content: "\2191\00a0"; } .rv-delta--down::before { content: "\2193\00a0"; }
.rv-delta--good { color: var(--clear); } .rv-delta--bad { color: var(--stop); }

/* ---------- table ---------- */
.rv-table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-3); }
.rv-table { width: 100%; border-collapse: collapse; font: 400 13px/18px var(--rv-sans); font-variant-numeric: tabular-nums; }
.rv-table th { text-align: left; padding: 10px var(--space-4); background: var(--surface-sunken); font: 600 11px/14px var(--rv-narrow); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }
.rv-table td { padding: 12px var(--space-4); border-top: 1px solid var(--line); color: var(--ink-2); vertical-align: middle; }
.rv-table td.rv-name { color: var(--ink); font: 600 14px/20px var(--rv-sans); min-width: 200px; }
.rv-table td.rv-name small { display: block; font: 400 12px/16px var(--rv-sans); color: var(--ink-3); }
.rv-table .rv-r { text-align: right; }
.rv-table tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.rv-table tbody tr:hover { background: var(--canvas); }
.rv-table tbody tr[aria-selected="true"] { background: var(--gloss-tint); }
.rv-inbar { display: inline-block; height: 4px; border-radius: var(--radius-1); background: var(--series-1); vertical-align: middle; margin-right: var(--space-2); }

/* ---------- charts ---------- */
.rv-chart { position: relative; }
.rv-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.rv-chart text { font: 400 12px/1 var(--rv-sans); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.rv-chart .rv-grid { stroke: var(--grid); stroke-width: 1; }
.rv-chart .rv-base { stroke: var(--line-strong); stroke-width: 1; }
.rv-chart .rv-s1 { fill: var(--series-1); } .rv-chart .rv-s2 { fill: var(--series-2); } .rv-chart .rv-s3 { fill: var(--series-3); }
.rv-chart .rv-l1 { stroke: var(--series-1); } .rv-chart .rv-l2 { stroke: var(--series-2); } .rv-chart .rv-l3 { stroke: var(--series-3); }
.rv-chart .rv-lprev { stroke: var(--series-prev); stroke-dasharray: 2 4; }
.rv-chart .rv-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.rv-chart .rv-dot { stroke: var(--surface); stroke-width: 2; }
.rv-chart .rv-pause { stroke: var(--stop); stroke-width: 1; stroke-dasharray: 4 4; }
.rv-chart .rv-pause-label { fill: var(--stop); font-weight: 500; }
.rv-chart .rv-direct { fill: var(--ink); font-weight: 500; }
.rv-chart .rv-cross { stroke: var(--line-strong); stroke-width: 1; }
.rv-chart .rv-hit { fill: transparent; }
.rv-chart .rv-bar { transition: opacity var(--dur-1) var(--ease-out); }
.rv-chart.is-hovering .rv-bar:not(.is-on) { opacity: 0.45; }
.rv-chart.is-new .rv-bar { transform-box: fill-box; transform-origin: bottom; animation: rv-grow var(--dur-3) var(--ease-out) both; }
.rv-chart.is-new .rv-line { stroke-dasharray: var(--len, 2000); stroke-dashoffset: var(--len, 2000); animation: rv-draw 700ms var(--ease-out) forwards; }
.rv-chart.is-new .rv-lprev { animation: none; stroke-dasharray: 2 4; stroke-dashoffset: 0; }
@keyframes rv-grow { from { transform: scaleY(0); } }
@keyframes rv-draw { to { stroke-dashoffset: 0; } }
.rv-legend { display: flex; flex-wrap: wrap; gap: var(--space-4); font: 400 13px/18px var(--rv-sans); color: var(--ink-2); margin-bottom: var(--space-3); }
.rv-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rv-legend i { width: 10px; height: 10px; border-radius: var(--radius-1); display: inline-block; }
i.rv-k1 { background: var(--series-1); } i.rv-k2 { background: var(--series-2); } i.rv-k3 { background: var(--series-3); }
.rv-legend i.rv-kprev, .rv-tip i.rv-kprev { height: 0; border-top: 2px dotted var(--series-prev); width: 14px; border-radius: 0; }
.rv-legend i.rv-kpause, .rv-tip i.rv-kpause { height: 0; border-top: 1px dashed var(--stop); width: 14px; border-radius: 0; }
.rv-tip { position: absolute; z-index: 2; pointer-events: none; min-width: 140px; padding: var(--space-2) var(--space-3); background: var(--surface-raised); border: 1px solid var(--line); border-radius: var(--radius-2); box-shadow: var(--shadow-menu); font: 400 12px/16px var(--rv-sans); color: var(--ink-2); font-variant-numeric: tabular-nums; opacity: 0; transition: opacity var(--dur-1) var(--ease-out); }
.rv-tip.is-open { opacity: 1; }
.rv-tip b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.rv-tip div { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.rv-tip div span { display: inline-flex; align-items: center; gap: 6px; }
.rv-tip i { width: 8px; height: 8px; border-radius: var(--radius-1); display: inline-block; }
.rv-tip em { font-style: normal; color: var(--ink); font-weight: 500; }
.rv-chart-table { margin-top: var(--space-3); }

/* ---------- meter: a sorting frame. One cell per day, step or batch. ---------- */
.rv-meter { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(6px, 1fr); gap: 2px; height: 28px; }
.rv-meter i { border-radius: var(--radius-1); background: var(--surface-sunken); }
.rv-meter i.is-done { background: var(--feather); }
.rv-meter i.is-now { background: var(--gloss); animation: rv-pulse 1.6s var(--ease-in-out) infinite; }
.rv-meter-foot { display: flex; justify-content: space-between; gap: var(--space-4); margin-top: var(--space-2); font: 400 12px/16px var(--rv-sans); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rv-track { height: 6px; border-radius: var(--radius-1); background: var(--surface-sunken); overflow: hidden; }
.rv-track i { display: block; height: 100%; border-radius: var(--radius-1); background: var(--feather); transition: width var(--dur-3) var(--ease-out); }

/* ---------- funnel: where a send went, to one scale ---------- */
.rv-funnel { display: grid; grid-template-columns: max-content 1fr max-content; gap: 10px var(--space-4); align-items: center; font: 400 13px/18px var(--rv-sans); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rv-funnel b { color: var(--ink); font-weight: 600; text-align: right; }
.rv-funnel .rv-fbar { height: 12px; border-radius: var(--radius-1); background: var(--series-1); min-width: 2px; }
.rv-funnel small { color: var(--ink-3); font-size: 12px; margin-left: 6px; }

/* ---------- states ---------- */
.rv-empty { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-3); padding: var(--space-8) var(--space-6); max-width: 440px; }
.rv-empty h4 { margin: 0; font: 600 18px/24px var(--rv-sans); }
.rv-empty p { margin: 0; color: var(--ink-2); }
.rv-skel { display: block; height: 12px; border-radius: var(--radius-1); background: var(--surface-sunken); position: relative; overflow: hidden; }
.rv-skel::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, var(--surface), transparent); opacity: 0.6; transform: translateX(-100%); animation: rv-sweep 1.4s var(--ease-in-out) infinite; }
@keyframes rv-sweep { to { transform: translateX(100%); } }

/* ---------- postmark: the mark of something that has gone ---------- */
.rv-postmark { display: inline-block; width: 92px; height: 92px; color: var(--ink-2); }
.rv-postmark svg { width: 100%; height: 100%; display: block; overflow: visible; }
.rv-postmark circle, .rv-postmark line { fill: none; stroke: currentColor; }
.rv-postmark text { fill: currentColor; font: 600 8.5px/1 var(--rv-narrow); letter-spacing: 0.12em; }
.rv-postmark .rv-pm-date { font-size: 13px; letter-spacing: 0.04em; }
.rv-postmark--stop { color: var(--stop); }
.rv-postmark.is-new { animation: rv-stamp 260ms var(--ease-out) both; }
@keyframes rv-stamp { from { opacity: 0; transform: scale(1.25) rotate(-9deg); } to { opacity: 1; transform: scale(1) rotate(-6deg); } }
.rv-postmark { transform: rotate(-6deg); }

/* ---------- send mode and the stop control ---------- */
.rv-mode { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; }
.rv-stopbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); flex-wrap: wrap; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-3); }
.rv-stopbar p { margin: 0; color: var(--ink-2); max-width: 46ch; }
.rv-stopbar.is-stopped { background: var(--stop-tint); border-color: transparent; }

/* ---------- wordmark ---------- */
.rv-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.rv-brand svg { width: 30px; height: 28px; fill: currentColor; flex: none; }
.rv-brand span { font: 400 28px/32px var(--rv-wordmark); letter-spacing: 0.01em; }

@media (prefers-reduced-motion: reduce) {
  .rv *, .rv *::before, .rv *::after { animation: none !important; transition: none !important; }
  .rv-chart.is-new .rv-line { stroke-dasharray: none; stroke-dashoffset: 0; }
}
