/* 34-utilities.css — small modifier classes that replace inline style="" in JS templates and index.html.
   Loaded last so a modifier wins over the component rule it adjusts. Colours come only from 00-tokens.css. */

/* ── Text colour ── */
.u-c-text { color: var(--c-text); }
.u-c-muted { color: var(--c-text-muted); }
/* faint text often sits on striped / sunken rows, so it uses the muted token (AA on both surfaces) */
.u-c-faint { color: var(--c-text-muted); }
.u-c-primary { color: var(--c-primary); }
.u-c-on-primary { color: var(--c-on-primary); }
.u-c-danger { color: var(--c-danger); }
.u-c-success { color: var(--c-success); }
.u-c-warning { color: var(--c-warning); }

/* ── Backgrounds ── */
.u-bg-surface { background: var(--c-surface); }
.u-bg-sunken { background: var(--c-surface-2); }
.u-bg-none { background: transparent; }
.u-bg-text { background: var(--c-text); }
.u-bg-primary { background: var(--c-primary); }
.u-bg-primary-soft { background: var(--c-primary-soft); }
.u-bg-success { background: var(--c-success); }
.u-bg-success-soft { background: var(--c-success-soft); }
.u-bg-danger { background: var(--c-danger); }
.u-bg-danger-soft { background: var(--c-danger-soft); }
.u-bg-warning-soft { background: var(--c-warning-soft); }

/* ── Borders (1px; -t / -b / -ie = one side; 2 = 2px; tone suffix = tinted) ── */
.u-bd { border: 1px solid var(--c-border); }
.u-bd-strong { border: 1px solid var(--c-border-strong); }
.u-bd-primary { border: 1px solid var(--c-primary-line); }
.u-bd-primary { border: 1px solid color-mix(in srgb, var(--c-primary) 30%, transparent); }
.u-bd-success { border: 1px solid var(--c-success-line); }
.u-bd-success { border: 1px solid color-mix(in srgb, var(--c-success) 35%, transparent); }
.u-bd-danger { border: 1px solid var(--c-danger-line); }
.u-bd-danger { border: 1px solid color-mix(in srgb, var(--c-danger) 35%, transparent); }
.u-bd-warning { border: 1px solid var(--c-warning-line); }
.u-bd-warning { border: 1px solid color-mix(in srgb, var(--c-warning) 35%, transparent); }
.u-bd-t { border-top: 1px solid var(--c-border); }
.u-bd-b { border-bottom: 1px solid var(--c-border); }
.u-bd-b2 { border-bottom: 2px solid var(--c-border); }
.u-bd-ie { border-inline-end: 1px solid var(--c-border); }
.u-bd-b-primary { border-bottom: 1px solid var(--c-primary-line); }
.u-bd-b-primary { border-bottom: 1px solid color-mix(in srgb, var(--c-primary) 30%, transparent); }
.u-bd-b-success { border-bottom: 1px solid var(--c-success-line); }
.u-bd-b-success { border-bottom: 1px solid color-mix(in srgb, var(--c-success) 35%, transparent); }
.u-bd-t2-primary { border-top: 2px solid var(--c-primary-line); }
.u-bd-t2-primary { border-top: 2px solid color-mix(in srgb, var(--c-primary) 40%, transparent); }
.u-bd-b2-primary { border-bottom: 2px solid var(--c-primary-line); }
.u-bd-b2-primary { border-bottom: 2px solid color-mix(in srgb, var(--c-primary) 40%, transparent); }
.u-bdc-primary { border-color: var(--c-primary-line); }
.u-bdc-primary { border-color: color-mix(in srgb, var(--c-primary) 30%, transparent); }
.u-bdc-success { border-color: var(--c-success-line); }
.u-bdc-success { border-color: color-mix(in srgb, var(--c-success) 35%, transparent); }
.u-bdc-danger { border-color: var(--c-danger-line); }
.u-bdc-danger { border-color: color-mix(in srgb, var(--c-danger) 35%, transparent); }

/* ── Tones: data-driven colour (account type, budget class, status) picked by name, never by hex.
   u-tone-<name> sets --tone/--tone-soft; u-c-tone / u-bg-tone / u-bg-tone-soft / u-bd-tone read them. ── */
.u-tone-primary { --tone: var(--c-primary);  --tone-soft: var(--c-primary-soft); }
.u-tone-move    { --tone: var(--money-move); --tone-soft: var(--money-move-soft); }
.u-tone-success { --tone: var(--c-success);  --tone-soft: var(--c-success-soft); }
.u-tone-danger  { --tone: var(--c-danger);   --tone-soft: var(--c-danger-soft); }
.u-tone-warning { --tone: var(--c-warning);  --tone-soft: var(--c-warning-soft); }
.u-tone-new     { --tone: var(--st-new);     --tone-soft: var(--st-new-soft); }
.u-tone-neutral { --tone: var(--st-neutral); --tone-soft: var(--st-neutral-soft); }
.u-tone-text    { --tone: var(--c-text);     --tone-soft: var(--c-surface-2); }
.u-tone-muted   { --tone: var(--c-border-strong); --tone-soft: var(--c-surface-2); }
.u-c-tone { color: var(--tone, var(--c-text)); }
.u-bg-tone { background: var(--tone, var(--c-primary)); }
.u-bg-tone-soft { background: var(--tone-soft, var(--c-surface-2)); }
.u-bd-tone { border: 1px solid var(--c-border-strong); }
.u-bd-tone { border: 1px solid color-mix(in srgb, var(--tone, var(--c-border-strong)) 30%, transparent); }
.u-bd-b-tone { border-bottom: 1px solid var(--c-border-strong); }
.u-bd-b-tone { border-bottom: 1px solid color-mix(in srgb, var(--tone, var(--c-border-strong)) 30%, transparent); }
/* Toggle pill (wallet pills in the add form): outlined in its tone, filled when chosen (.is-on). */
.u-pill-tone { margin: 0; padding: 5px 9px; font-size: .8rem; border: 1px solid var(--tone); color: var(--tone); background: var(--c-surface); transition: background var(--mo-base) var(--ease), color var(--mo-base) var(--ease); }
.u-pill-tone.is-on { background: var(--tone); color: var(--c-on-primary); }

/* ── Small layout helpers ── */
.u-me-6 { margin-inline-end: 6px; }
.u-me-8 { margin-inline-end: 8px; }
.u-fw-700 { font-weight: 700; }
.u-dim { opacity: .7; }
.u-el-3 { box-shadow: var(--el-3); }
.u-field { width: 100%; padding: 10px; border-radius: var(--radius-sm); }

/* ── Full-screen overlay for hand-built dialogs (AI congestion) ── */
.u-overlay { position: fixed; inset: 0; background: var(--c-overlay); z-index: 100200; display: flex; justify-content: center; align-items: center; padding: 24px; }

/* ── Top banners (recovery, cloud load failed, Drive re-auth): solid token colour, no gradient ── */
.u-banner { position: fixed; top: 0; inset-inline: 0; z-index: 100200; color: var(--c-on-primary); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--el-2); }
.u-banner--warning { background: var(--c-warning); }
.u-banner--danger { background: var(--c-danger); }
.u-banner__icon { font-size: 1.3rem; }
.u-banner__body { flex: 1; min-width: 0; line-height: 1.4; }
.u-banner__title { display: block; font-size: .95rem; }
.u-banner__text { opacity: .95; }
.u-banner__action { border: none; padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 800; font-family: inherit; cursor: pointer; white-space: nowrap; background: var(--c-surface); }
.u-banner--warning .u-banner__action { color: var(--c-warning); }
.u-banner--danger .u-banner__action { color: var(--c-danger); }
.u-banner__close { border: none; width: 32px; height: 32px; border-radius: var(--radius-pill); cursor: pointer; font-size: 1rem; background: rgba(255,255,255,.2); color: var(--c-on-primary); }

/* ── Sync orb (core/sync-status.js) ── */
/* A status only: taps go through to what is under it (the inbox «تحديث» button sits there).
   A small glass capsule in the top end corner: a ring around a cloud. Syncing: the ring's arc turns. Waiting for the
   next try: the ring fills over the wait, so the arc is the time left. Offline: amber, dashed, still. Done: the ring
   closes green and a check pops in. The label slides open when the state changes and folds back after a moment, so
   the orb covers nothing for long. The folded label stays in the tree for screen readers. */
.u-sync {
    position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); inset-inline-end: 12px; z-index: 100100; pointer-events: none;
    display: flex; align-items: center; height: 38px; padding: 3px; border-radius: var(--radius-pill);
    background: rgba(255,255,255,.8); -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4);
    box-shadow: 0 0 0 1px rgba(15,23,42,.08), var(--el-2); color: var(--c-text); cursor: default;
    --u-sync-ring: var(--c-primary); --u-sync-track: var(--c-primary-soft);
    transition: opacity .3s var(--ease-out), transform .3s var(--ease-out);
}
.u-sync--in { animation: u-sync-in 460ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes u-sync-in { from { opacity: 0; transform: translateY(-16px) scale(.8); } }
.u-sync--out { opacity: 0; transform: translateY(-10px) scale(.9); }
.u-sync__orb { position: relative; flex: none; width: 32px; height: 32px; display: grid; place-items: center; }
.u-sync__ring { position: absolute; inset: 0; width: 32px; height: 32px; transform: rotate(-90deg); }
.u-sync__ring circle { fill: none; stroke-width: 2.5; }
.u-sync__track { stroke: var(--u-sync-track); transition: stroke .3s; }
/* r=14 → circumference ≈ 88: dashoffset 88 is empty, 0 is a closed ring. */
.u-sync__arc { stroke: var(--u-sync-ring); stroke-linecap: round; stroke-dasharray: 88; stroke-dashoffset: 64; transition: stroke-dashoffset .35s var(--ease-out), stroke .3s; }
.u-sync__icon { position: relative; font-size: 12px; line-height: 1; color: var(--u-sync-ring); transition: color .3s; }
.u-sync__label {
    max-width: 0; opacity: 0; overflow: hidden; white-space: nowrap; padding: 0;
    font-size: var(--fs-xs); font-weight: 700; line-height: 1; transform: translateX(6px);
    transition: max-width .45s var(--ease-out), opacity .3s var(--ease-out), padding .45s var(--ease-out), transform .45s var(--ease-out);
}
.u-sync--open .u-sync__label { max-width: 260px; opacity: 1; padding-inline: 6px 11px; transform: none; }
/* Syncing: a quarter arc turning */
.u-sync--syncing .u-sync__ring { animation: u-sync-turn 1.1s linear infinite; }
@keyframes u-sync-turn { to { transform: rotate(270deg); } }
/* Waiting for the next try: the ring fills over --u-sync-wait (set per wait by sync-status.js) */
.u-sync--waiting .u-sync__arc { transition: stroke-dashoffset var(--u-sync-wait, 4s) linear, stroke .3s; stroke-dashoffset: 0; }
/* Offline: amber, dashed, still */
.u-sync--offline { --u-sync-ring: var(--c-warning); --u-sync-track: var(--c-warning-soft); }
.u-sync--offline .u-sync__arc { stroke-dasharray: 3 4.5; stroke-dashoffset: 0; }
/* Done: the ring closes green, the check pops */
.u-sync--ok { --u-sync-ring: var(--c-success); --u-sync-track: var(--c-success-soft); }
.u-sync--ok .u-sync__arc { stroke-dashoffset: 0; }
.u-sync--ok .u-sync__icon { animation: u-sync-pop 420ms cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes u-sync-pop { from { transform: scale(.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .u-sync, .u-sync__arc, .u-sync__label, .u-sync--waiting .u-sync__arc { transition: none; }
    .u-sync--in, .u-sync--syncing .u-sync__ring, .u-sync--ok .u-sync__icon { animation: none; }
}

/* ── Layout / spacing / type helpers (replace repeated inline style="" in templates) ── */
.u-flex { display: flex; }
.u-block { display: block; }
.u-items-center { align-items: center; }
.u-between { justify-content: space-between; }
.u-col { flex-direction: column; }
.u-flex-1 { flex: 1; }
.u-minw-0 { min-width: 0; }
.u-gap-2 { gap: var(--sp-2); }
.u-gap-3 { gap: var(--sp-3); }
.u-tc { text-align: center; }
.u-ltr { direction: ltr; }
.u-nowrap { white-space: nowrap; }
.u-lh-body { line-height: var(--lh-body); }
.u-fw-600 { font-weight: 600; }
.u-fs-xs { font-size: var(--fs-xs); }
.u-fs-sm { font-size: var(--fs-sm); }
.u-fs-md { font-size: var(--fs-md); }
.u-fs-lg { font-size: var(--fs-lg); }
.u-r-md { border-radius: var(--radius-md); }
.u-m-0 { margin: 0; }
.u-mt-3 { margin-top: var(--sp-3); }
.u-mb-1 { margin-bottom: var(--sp-1); }
.u-mb-2 { margin-bottom: var(--sp-2); }
.u-mb-3 { margin-bottom: var(--sp-3); }
.u-mb-4 { margin-bottom: var(--sp-4); }
.u-p-3 { padding: var(--sp-3); }
.u-p-4 { padding: var(--sp-4); }
.u-p-5 { padding: var(--sp-5); }
