/* ============================================================
   RESERVD shared components — Phase 6 "Daylight"
   Rendered by js/components.js. Tokens: css/tokens.css.
   ============================================================ */

/* screen-reader only */
.r-sr{position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0}

/* tone → colour (status only) */
.r-tone-safe{--tone:var(--safe); --tone-soft:var(--safe-soft)}
.r-tone-attention{--tone:var(--attention); --tone-soft:var(--attention-soft)}
.r-tone-risk{--tone:var(--risk); --tone-soft:var(--risk-soft)}
.r-tone-info{--tone:var(--info); --tone-soft:var(--info-soft)}
.r-tone-steel{--tone:var(--accent); --tone-soft:var(--accent-soft)}
.r-dot{display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--tone, var(--info)); flex-shrink:0}

/* ---------- sync status ---------- */
.r-sync{display:inline-flex; align-items:center; gap:8px; font-size:var(--fs-sm); color:var(--ink-muted); white-space:nowrap; line-height:1.2}
.r-sync .r-dot{width:7px; height:7px; box-shadow:0 0 0 3px var(--tone-soft)}
.r-sync.r-tone-attention .r-sync-text, .r-sync.r-tone-risk .r-sync-text{color:var(--tone); font-weight:600}
.r-sync.compact{font-size:var(--fs-xs); gap:7px; padding:6px 10px 6px 9px; border-radius:var(--r-pill); background:var(--surface-2)}

/* ---------- chip (sentence case — meaning comes from tone + text, never colour alone) ---------- */
.r-chip{display:inline-flex; align-items:center; gap:6px; font-size:var(--fs-label); font-weight:600; letter-spacing:0; line-height:1.3;
  color:var(--tone, var(--info)); background:var(--tone-soft, var(--info-soft)); padding:3px 10px 3px 8px; border-radius:var(--r-pill); white-space:nowrap; vertical-align:middle}
.r-chip .r-dot{width:6px; height:6px}

/* ---------- confidence meter ---------- */
.r-conf{display:flex; align-items:center; flex-wrap:wrap; gap:6px 10px; margin:2px 0 6px}
.r-conf-meter{display:inline-flex; gap:3px}
.r-conf-bar{width:16px; height:6px; border-radius:3px; background:var(--surface-3)}
.r-conf-bar.on{background:var(--tone)}
.r-conf-label{font-size:var(--fs-label); font-weight:600; color:var(--tone)}
.r-conf-why{margin:0; flex-basis:100%}
.r-conf-reason{color:var(--ink-faint)}

/* ---------- disclosure ("Why?", "What does this mean?") ---------- */
.r-disclosure{margin:0}
.r-disclosure > summary{display:inline-flex; align-items:center; gap:4px; min-height:36px; padding-right:4px; font-size:var(--fs-xs); font-weight:600; color:var(--accent); cursor:pointer; list-style:none; border-radius:var(--r-xs)}
.r-disclosure > summary::-webkit-details-marker{display:none}
.r-disclosure > summary::after{content:""; width:6px; height:6px; border-right:1.5px solid currentColor; border-bottom:1.5px solid currentColor; transform:rotate(45deg) translateY(-2px); margin-left:4px; transition:transform .15s ease}
.r-disclosure[open] > summary::after{transform:rotate(225deg) translateY(-1px)}
.r-disclosure > summary:hover{color:var(--accent-hover)}
.r-disclosure > summary:focus-visible{outline:none; box-shadow:var(--focus-ring)}
.r-disclosure-body{font-size:var(--fs-sm); color:var(--ink-muted); line-height:1.6; padding:6px 0 4px; max-width:64ch}
.r-disclosure[open] > .r-disclosure-body{animation:r-reveal .18s var(--ease)}
@keyframes r-reveal{from{opacity:0; transform:translateY(-2px)} to{opacity:1; transform:none}}

/* ---------- figure ---------- */
.r-figure{min-width:0}
.r-figure-label{display:flex; align-items:center; gap:8px; font-size:var(--fs-sm); font-weight:500; color:var(--ink-muted)}
.r-figure-amount{font-weight:600; letter-spacing:-.025em; color:var(--ink); line-height:1.1; margin-top:6px; font-variant-numeric:tabular-nums}
.r-figure.size-xl .r-figure-amount{font-size:var(--fs-display)}
.r-figure.size-l .r-figure-amount{font-size:var(--fs-figure-l)}
.r-figure.size-m .r-figure-amount{font-size:var(--fs-figure-m)}
.r-figure-caption{font-size:var(--fs-sm); color:var(--ink-muted); margin-top:6px; line-height:1.45}

/* ---------- attention row ---------- */
.r-attn{display:flex; align-items:center; gap:14px; padding:14px 16px; background:var(--surface); border-radius:var(--r-md); border:1px solid var(--line)}
.r-attn + .r-attn{margin-top:8px}
.r-attn-body{flex:1; min-width:0}
.r-attn-title{font-size:var(--fs-body); font-weight:600; color:var(--ink)}
.r-attn-text{font-size:var(--fs-sm); color:var(--ink-muted); margin-top:2px; line-height:1.5}

/* ---------- card (one level only) ---------- */
.r-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:22px 24px; box-shadow:var(--shadow-sm)}
.r-card .r-card{background:none; border:none; box-shadow:none; padding:0}   /* guard: never a card inside a card */

/* ---------- empty / skeleton ---------- */
.r-empty{text-align:center; padding:40px 20px; color:var(--ink-muted)}
.r-empty-ic{width:44px; height:44px; margin:0 auto 14px; border-radius:12px; background:var(--accent-soft); color:var(--accent); display:flex; align-items:center; justify-content:center}
.r-empty-title{font-size:var(--fs-body); font-weight:600; color:var(--ink)}
.r-empty-body{font-size:var(--fs-sm); margin:6px auto 0; max-width:42ch; line-height:1.55}
.r-empty .btn{width:auto; margin:18px auto 0; display:inline-flex}
.r-skel{display:flex; flex-direction:column; gap:10px}
.r-skel span{display:block; height:12px; border-radius:6px; background:linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size:200% 100%; animation:r-shimmer 1.4s ease-in-out infinite}
@keyframes r-shimmer{0%{background-position:100% 0}100%{background-position:-100% 0}}

/* ---------- toast ---------- */
.r-toast-host{position:fixed; left:50%; transform:translateX(-50%); bottom:calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); z-index:80; display:flex; flex-direction:column; gap:8px; align-items:center; pointer-events:none; width:max-content; max-width:calc(100vw - 32px)}
@media (min-width:900px){ .r-toast-host{bottom:28px} }
.r-toast{pointer-events:auto; display:flex; align-items:center; gap:10px; background:var(--ink); color:#fff; font-size:var(--fs-sm); font-weight:500; padding:12px 18px 12px 14px; border-radius:var(--r-md); box-shadow:var(--shadow-lg); transition:opacity .2s ease, transform .2s ease}
.r-toast::before{content:""; width:8px; height:8px; border-radius:50%; background:var(--tone, var(--brand)); flex-shrink:0}
.r-toast.r-tone-safe::before{background:#4CC38A}
.r-toast.r-tone-attention::before{background:#F2B544}
.r-toast.r-tone-risk::before{background:#F27A6D}
.r-toast.out{opacity:0; transform:translateY(6px)}

/* ---------- Cash Line ---------- */
.r-cashline{margin:0}
.r-cl-track{position:relative; display:flex; gap:2px; height:12px; border-radius:var(--r-pill); overflow:hidden; background:var(--surface-3)}
.r-cl-seg{display:block; height:100%; min-width:0}
.r-cl-seg.k-protected{background:var(--cl-protected)}
.r-cl-seg.k-operating{background:var(--cl-operating)}
.r-cl-seg.k-retained{background:var(--cl-retained)}
.r-cl-seg.k-allocated{background:var(--cl-allocated)}
.r-cl-seg.k-held{background:repeating-linear-gradient(135deg, var(--cl-held-b) 0 4px, var(--cl-held-a) 4px 8px)}
.r-cl-seg.k-safe{background:var(--safe-fill)}
.r-cl-seg.k-unallocated{background:var(--cl-unallocated)}
.r-cl-seg.is-uncertain{background-image:repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 3px, transparent 3px 7px)}
.r-cl-cashmark{position:absolute; top:-4px; bottom:-4px; width:2px; background:var(--risk); border-radius:1px}
.r-cashline.has-shortfall .r-cl-track{overflow:visible}
.r-cl-note{font-size:var(--fs-xs); color:var(--ink-muted); margin-top:10px; line-height:1.5}
.r-cl-note.r-tone-risk{color:var(--risk); font-weight:500}
.r-cl-legend{list-style:none; margin:14px 0 0; padding:0; display:grid; grid-template-columns:repeat(auto-fill, minmax(190px, 1fr)); gap:8px 20px}
.r-cl-legend li{display:flex; align-items:center; gap:8px; font-size:var(--fs-sm); color:var(--ink-muted); min-width:0}
.r-cl-legend li.is-zero{opacity:.6}
.r-cl-key{width:10px; height:10px; border-radius:3px; flex-shrink:0}
.r-cl-legend .k-protected .r-cl-key{background:var(--cl-protected)}
.r-cl-legend .k-operating .r-cl-key{background:var(--cl-operating)}
.r-cl-legend .k-retained .r-cl-key{background:var(--cl-retained)}
.r-cl-legend .k-allocated .r-cl-key{background:var(--cl-allocated)}
.r-cl-legend .k-held .r-cl-key{background:repeating-linear-gradient(135deg, var(--cl-held-b) 0 2px, var(--cl-held-a) 2px 4px); box-shadow:inset 0 0 0 1px var(--cl-held-b)}
.r-cl-legend .k-safe .r-cl-key{background:var(--safe-fill)}
.r-cl-legend .k-unallocated .r-cl-key{background:var(--cl-unallocated); box-shadow:inset 0 0 0 1px var(--line-strong)}
.r-cl-lbl{flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap}
.r-cl-lbl em{font-style:normal; font-size:var(--fs-label); font-weight:600; color:var(--attention)}
.r-cl-amt{color:var(--ink); font-weight:600}
.r-cashline.is-empty .r-cl-note{margin-top:8px}

/* screen-reader-only text (labels and state descriptions that sighted users get from layout) */
.sr-only{position:absolute !important; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0 0 0 0); clip-path:inset(50%); white-space:nowrap; border:0}
