/* VoiceNotePlayer — WhatsApp-style voice note bubble + collapsible transcription */

.conversations-bubble.voice-note {
    display: block;
    width: 300px;
    max-width: 85%;
    padding: 8px 12px 8px 8px;
}

.voice-note__player {
    display: flex;
    align-items: center;
    gap: 10px;
}

.voice-note__avatar {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-alt, #f5f0fa);
    border: 1px solid var(--border, #ece4f3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--ink-muted);
}

.voice-note__mic {
    position: absolute;
    right: -5px;
    bottom: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent, #5b21b6);
}

.voice-note__play {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--ink-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 150ms ease, background-color 150ms ease;
}

.voice-note__play:hover {
    color: var(--ink);
    background: var(--surface-alt, #f5f0fa);
}

.voice-note.is-playing .voice-note__play {
    color: var(--accent, #5b21b6);
}

.voice-note__play:focus-visible,
.voice-note__wave:focus-visible,
.voice-note__toggle:focus-visible {
    outline: 2px solid var(--accent, #5b21b6);
    outline-offset: 2px;
}

.voice-note__play:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.voice-note__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 10px;
}

.voice-note__wave {
    position: relative;
    height: 26px;
    display: flex;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

.voice-note__bar {
    flex: 1;
    min-height: 3px;
    border-radius: 2px;
    background: var(--ink-muted);
    opacity: 0.4;
    transition: background-color 120ms linear, opacity 120ms linear;
}

.voice-note__bar.is-played {
    background: var(--accent, #5b21b6);
    opacity: 1;
}

.voice-note__knob {
    position: absolute;
    top: 50%;
    left: 0;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: var(--accent, #5b21b6);
    pointer-events: none;
}

.voice-note__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.voice-note__duration {
    font-family: var(--font-ui);
    font-size: 11px;
    color: var(--ink-muted);
    font-variant-numeric: tabular-nums;
}

.voice-note.is-error .voice-note__wave {
    opacity: 0.4;
    cursor: default;
}

.voice-note__toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 0 54px;
    padding: 2px 0;
    border: 0;
    background: transparent;
    font-family: var(--font-ui);
    font-size: 12px;
    color: var(--accent, #5b21b6);
    cursor: pointer;
}

.voice-note__toggle:hover .voice-note__toggle-label {
    text-decoration: underline;
}

/* expand/collapse: grid rows 0fr → 1fr animates to the content height without measuring it */
.voice-note__transcript {
    display: grid;
    grid-template-rows: 0fr;
    margin-left: 54px;
    opacity: 0;
    visibility: hidden;
    transition:
        grid-template-rows 260ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 200ms ease,
        visibility 0s linear 260ms;
}

.voice-note__transcript.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    visibility: visible;
    transition:
        grid-template-rows 260ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 220ms ease 60ms,
        visibility 0s linear 0s;
}

.voice-note__transcript-inner {
    min-height: 0;
    overflow: hidden;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--ink);
    line-height: 1.5;
    white-space: pre-wrap;
}

/* spacing lives inside the inner box so it collapses together with it */
.voice-note__transcript-inner::before {
    content: "";
    display: block;
    margin-top: 6px;
    margin-bottom: 6px;
    border-top: 1px solid var(--border, #ece4f3);
}

@media (prefers-reduced-motion: reduce) {
    .voice-note__bar,
    .voice-note__play,
    .voice-note__transcript,
    .voice-note__transcript.is-open {
        transition: none;
    }
}
