/*
 * The dictation pill — "Aurora" (js/ui/dictation/dictationPill.js, plan tmp/plan-dictation-pill.md; direction chosen
 * by the owner from tmp/dictation-pill-directions.html). One look for every box that takes dictation.
 *
 * The gradient is built from the THEME's accent (blended toward its recording red), so every theme gets its own
 * pill. The outer .dictation-pill only carries the per-frame placement transform; every animation runs on .dp-body
 * (and the halo / sheen / drop layers). Only opacity and transform animate. Reduced motion: a still pill.
 */
.dictation-pill {
    --dp-a: var(--accent);
    --dp-b: color-mix(in srgb, var(--accent) 55%, var(--recording));
    --dp-ink: #fff;
    --dp-spring: cubic-bezier(.34, 1.56, .64, 1);
    position: fixed;
    top: 0;
    left: 0;
    z-index: var(--z-dropdown);
    max-width: min(420px, calc(100vw - 24px));
    pointer-events: auto;
    will-change: transform;
    font-family: var(--font-main);
    font-size: 13px;
    line-height: 1.3;
}

/* The pill itself. Starts small and below, at the mic button (transform-origin set by JS), and springs up. */
.dictation-pill .dp-body {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 4px 6px 4px 14px;
    border-radius: var(--radius-full);
    background: var(--dp-a);
    background: linear-gradient(135deg, var(--dp-a), var(--dp-b));
    color: var(--dp-ink);
    box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 38%, transparent), var(--shadow-sm);
    opacity: 0;
    transform: translateY(16px) scale(.6);
}
.dictation-pill.is-shown .dp-body { animation: dp-in .42s var(--dp-spring) both; }
.dictation-pill .dp-body.dp-settle { animation: dp-settle .5s var(--dp-spring) both; }
/* After the settle rule on purpose: leaving must win over a settle still on the element. */
.dictation-pill.is-leaving .dp-body { animation: dp-out .24s ease-in both; }
@keyframes dp-in { from { opacity: 0; transform: translateY(16px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes dp-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(10px) scale(.85); } }
@keyframes dp-settle { 0% { opacity: 1; transform: none; } 40% { opacity: 1; transform: scale(1.06); } 100% { opacity: 1; transform: none; } }

/* The glow behind the pill: scale and opacity follow the voice (JS). The blur is static — never animated. */
.dictation-pill .dp-halo {
    position: absolute;
    inset: -10px;
    border-radius: var(--radius-full);
    background: radial-gradient(closest-side, color-mix(in srgb, var(--dp-b) 60%, transparent), transparent);
    filter: blur(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}
.dictation-pill.is-leaving .dp-halo,
.dictation-pill:not([data-state="listening"]) .dp-halo { opacity: 0 !important; }

/* Bars: the microphone level, scaled by JS. */
.dictation-pill .dp-bars { display: none; align-items: center; gap: 3px; height: 22px; flex: none; }
.dictation-pill .dp-bars i {
    display: block;
    width: 3px;
    height: 22px;
    border-radius: 3px;
    background: currentColor;
    transform: scaleY(.15);
    transform-origin: center;
}
.dictation-pill[data-state="listening"] .dp-bars { display: flex; }

/* The sweep while tidying: a band of light crossing the pill. */
.dictation-pill .dp-sheen {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    pointer-events: none;
    display: none;
}
.dictation-pill .dp-sheen::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: translateX(-120%);
    animation: dp-sweep 1.1s ease-in-out infinite;
}
.dictation-pill[data-state="tidying"] .dp-sheen,
.dictation-pill[data-state="slow"] .dp-sheen { display: block; }
@keyframes dp-sweep { to { transform: translateX(320%); } }

.dictation-pill .dp-check { display: none; font-size: 12px; flex: none; }
.dictation-pill[data-state="done"] .dp-check { display: inline-block; animation: dp-pop .4s var(--dp-spring) both; }
@keyframes dp-pop { from { opacity: 0; transform: scale(0) rotate(-45deg); } to { opacity: 1; transform: none; } }

/* The latest words, one line — the oldest are cut off on the left; each new word rises in. */
.dictation-pill .dp-words {
    display: none;
    min-width: 0;
    flex: 1 1 auto;
    max-width: 260px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    direction: rtl;
    text-align: left;
    opacity: .9;
}
.dictation-pill .dp-line { direction: ltr; unicode-bidi: isolate; }
.dictation-pill .dp-line:empty::before { content: 'Listening'; opacity: .8; }
.dictation-pill .dp-words .dp-new { display: inline-block; animation: dp-word .32s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes dp-word { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.dictation-pill[data-state="listening"] .dp-words { display: block; }

.dictation-pill .dp-label { position: relative; white-space: nowrap; font-weight: 500; }
.dictation-pill[data-state="listening"] .dp-label { display: none; }
.dictation-pill .dp-actions { display: none; gap: 2px; flex: none; }
/* A notice's message gives way to its choices: one line, cut with an ellipsis, the buttons always visible. */
.dictation-pill[data-state="notice"] .dp-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dictation-pill[data-state="notice"] .dp-actions { display: inline-flex; }
.dictation-pill .dp-action { font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }

.dictation-pill button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    min-width: 28px;
    height: 28px;
    margin: 0;
    padding: 0 8px;
    border: 0;
    border-radius: var(--radius-full);
    background: transparent;
    color: inherit;
    font: inherit;
    cursor: pointer;
    opacity: .85;
    transition: opacity var(--transition-fast);
}
.dictation-pill button:hover { opacity: 1; }
.dictation-pill button:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; opacity: 1; }
.dictation-pill button[hidden] { display: none; }
.dictation-pill .dp-undo { font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
.dictation-pill .dp-cancel { padding: 0; width: 28px; }

.dictation-pill .dp-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* The tidied sentence falling from the pill into the box (placed by JS; --dp-drop-y is the distance). */
.dp-drop {
    position: fixed;
    z-index: var(--z-dropdown);
    max-width: min(420px, calc(100vw - 24px));
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--text-primary);
    pointer-events: none;
    animation: dp-drop .55s cubic-bezier(.5, 0, .2, 1) forwards;
}
@keyframes dp-drop {
    from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
    to { opacity: 0; transform: translateX(-50%) translateY(var(--dp-drop-y, 48px)) scale(.9); }
}

/* Phones: touch targets of at least 44 px for Cancel and Undo. */
@media (max-width: 768px) {
    .dictation-pill .dp-body { min-height: 44px; }
    .dictation-pill button { min-width: 44px; height: 44px; }
    .dictation-pill .dp-cancel { width: 44px; }
}

@media (prefers-reduced-motion: reduce) {
    .dictation-pill .dp-body,
    .dictation-pill.is-shown .dp-body,
    .dictation-pill .dp-body.dp-settle { animation: none; opacity: 1; transform: none; }
    .dictation-pill .dp-halo { display: none; }
    .dictation-pill .dp-sheen::after { animation: none; transform: translateX(80%); }
    .dictation-pill .dp-bars i { transform: scaleY(.5); }
    .dictation-pill .dp-words .dp-new,
    .dictation-pill[data-state="done"] .dp-check { animation: none; }
    .dp-drop { display: none; }
}
