/* ==========================================================================
   work-meter.css — the "still working" meter (public/js/workMeter.js)

   A countdown ring against an estimate, a small scene for the kind of work,
   and a power tip. Floats at the bottom of the window, or sits inline in the
   AI review modal, a Synthesis chat bubble or the Export bar. Colours come
   from the theme tokens, so every theme gets it for free. 2026-10-08.
   ========================================================================== */

.wm {
    --wm-accent: var(--color-primary, #3B82F6);
    --wm-muted: var(--color-text-tertiary, #8a94a6);
    --wm-done: var(--color-success, #22c55e);
    display: flex;
    align-items: center;
    gap: 14px;
    color: var(--color-text-primary, #e6e8eb);
    font-size: 13px;
    line-height: 1.4;
}

/* ── Floating: a card at the bottom centre, clear of the toasts ───────── */
.wm-dock {
    position: fixed;
    left: 50%;
    bottom: 72px;
    transform: translateX(-50%);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}
.wm-floating {
    position: relative;
    pointer-events: auto;
    width: min(400px, calc(100vw - 32px));
    padding: 14px 16px;
    background: var(--color-bg-elevated, #1f2329);
    border: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
    border-radius: 14px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
    animation: wm-in 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.wm-floating.wm-leaving { animation: wm-out 240ms ease forwards; }

/* ── Inline: inside a host, which hides its own old indicator ─────────── */
.wm-hosting > :not(.wm) { display: none !important; }
.wm-inline { padding: 12px 4px; width: 100%; }
.wm-inline.wm-size-compact { padding: 6px 0; gap: 10px; }

/* ── The ring ──────────────────────────────────────────────────────────── */
.wm-ring {
    position: relative;
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
}
.wm-size-compact .wm-ring { width: 44px; height: 44px; }
.wm-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.wm-track { fill: none; stroke: var(--color-border, rgba(255, 255, 255, 0.12)); stroke-width: 5; }
.wm-arc {
    fill: none;
    stroke: var(--wm-accent);
    stroke-width: 5;
    stroke-linecap: round;
    transform-origin: 32px 32px;
}
.wm-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-variant-numeric: tabular-nums;
}
.wm-time { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.wm-time-sub { font-size: 10px; color: var(--color-text-secondary, #a8b0bb); margin-top: -1px; }
.wm-size-compact .wm-time { font-size: 12px; }
.wm-size-compact .wm-time-sub { font-size: 9px; }

/* Past the estimate: the ring never sits at zero; a short arc orbits. */
.wm-overtime .wm-arc {
    stroke-dasharray: 34 130;
    stroke-dashoffset: 0;
    animation: wm-orbit 1.4s linear infinite;
}

/* Finished: the ring closes in the success colour. */
.wm-done .wm-arc { stroke: var(--wm-done); stroke-dasharray: none; transition: stroke 160ms ease; }
.wm-done .wm-time { color: var(--wm-done); font-size: 22px; }

/* ── The words and the scene ───────────────────────────────────────────── */
.wm-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.wm-title { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.wm-size-compact .wm-title { font-size: 13px; }
.wm-scene { display: block; width: 100%; height: 64px; }
.wm-size-compact .wm-scene { height: 34px; }
.wm-caption { color: var(--color-text-secondary, #a8b0bb); font-size: 12px; }
.wm-tip {
    font-size: 12px;
    color: var(--color-text-secondary, #a8b0bb);
    border-top: 1px solid var(--color-border, rgba(255, 255, 255, 0.12));
    padding-top: 6px;
    min-height: 3.2em;
}
.wm-tip-label { color: var(--wm-accent); font-weight: 600; }

/* ── Make smaller: just the ring, out of the way ──────────────────────── */
.wm-min {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-secondary, #a8b0bb);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
.wm-min:hover, .wm-min:focus-visible { background: var(--color-bg-hover, rgba(255, 255, 255, 0.08)); color: var(--color-text-primary, #e6e8eb); }
.wm-mini { width: auto; padding: 8px 40px 8px 10px; }
.wm-mini .wm-ring { width: 44px; height: 44px; }
.wm-mini .wm-time { font-size: 12px; }
.wm-mini .wm-scene, .wm-mini .wm-tip, .wm-mini .wm-caption { display: none; }
.wm-mini .wm-title { font-size: 13px; max-width: 220px; }

/* Screen-reader text: announced on start and finish, never every second. */
.wm-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* The Export bar's host sits above the button. */
.export-progress-host:empty { display: none; }
.export-progress-host { margin-bottom: 8px; }

@keyframes wm-orbit { to { transform: rotate(360deg); } }
@keyframes wm-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes wm-out { to { opacity: 0; transform: translateY(6px); } }

@media (max-width: 560px) {
    .wm-dock { bottom: 16px; }
    .wm-floating .wm-tip { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .wm-floating, .wm-floating.wm-leaving { animation: none; }
    .wm-overtime .wm-arc { animation: none; stroke-dasharray: 6 6; }
}
