/* Replaceable voice presentation layer. Business behavior lives outside this file. */
[data-voice-component] {
    --voice-accent: var(--game-accent, var(--shell-accent));
    --voice-danger: #e05864;
    --voice-line: color-mix(in srgb, var(--voice-accent) 34%, transparent);
    --voice-panel: color-mix(in srgb, var(--shell-surface-2) 94%, transparent);
    --voice-glow: color-mix(in srgb, var(--voice-accent) 18%, transparent);
}

[data-voice-component="composer"] .chat-compose-row {
    grid-template-columns: repeat(3, minmax(48px, 1fr)) auto;
    gap: 6px;
    padding: 7px;
    border: 1px solid var(--voice-line);
    border-radius: 14px;
    background: linear-gradient(135deg, var(--voice-panel), color-mix(in srgb, var(--shell-surface) 88%, var(--voice-accent) 12%));
    box-shadow: inset 0 1px rgb(255 255 255 / 5%), 0 10px 26px rgb(0 0 0 / 9%);
}

[data-voice-component="composer"] {
    container-type: inline-size;
}

[data-voice-component="composer"] .chat-compose-row > input {
    grid-column: 1 / -1;
    min-height: 42px;
    padding: 0 10px 7px;
    border: 0;
    border-bottom: 1px solid color-mix(in srgb, var(--voice-line) 62%, transparent);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

[data-voice-component="composer"] .chat-compose-row > input:focus {
    outline: 0;
}

.voice-action-icon {
    display: grid;
    width: 18px;
    height: 18px;
    place-items: center;
    flex: 0 0 auto;
}

.voice-action-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[data-voice-component="composer"] .speech-synthesize-button,
[data-voice-component="composer"] .voice-record-button,
[data-voice-component="composer"] .voice-transcribe-button {
    display: inline-flex;
    width: auto;
    min-width: 0;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: var(--shell-muted);
    background: transparent;
    box-shadow: none;
    white-space: nowrap;
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

[data-voice-component="composer"] .chat-compose-row > button[type="submit"] {
    grid-column: 4;
    min-width: 72px;
    min-height: 38px;
    padding-inline: 14px;
    border: 1px solid color-mix(in srgb, var(--voice-accent) 76%, white 8%);
    border-radius: 9px;
    background: var(--voice-accent);
    box-shadow: 0 7px 18px color-mix(in srgb, var(--voice-accent) 18%, transparent);
    font-weight: 900;
}

[data-voice-component="composer"] .chat-compose-row > button[type="submit"]:hover:not(:disabled) {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

[data-voice-component="composer"] .voice-record-button {
    color: var(--voice-accent);
}

[data-voice-component="composer"] .voice-transcribe-button {
    color: color-mix(in srgb, var(--voice-accent) 72%, #76d8ff 28%);
}

[data-voice-component="composer"] .speech-synthesize-button:hover:not(:disabled),
[data-voice-component="composer"] .voice-record-button:hover:not(:disabled),
[data-voice-component="composer"] .voice-transcribe-button:hover:not(:disabled) {
    border-color: var(--voice-line);
    color: var(--voice-accent);
    background: var(--voice-glow);
    transform: translateY(-1px);
}

[data-voice-component="composer"] :is(.speech-synthesize-button, .voice-record-button, .voice-transcribe-button):focus-visible,
[data-voice-component="live-room"] button:focus-visible {
    outline: 2px solid var(--voice-accent);
    outline-offset: 2px;
}

[data-voice-component="composer"].is-recording .voice-record-button {
    color: #fff;
    border-color: color-mix(in srgb, var(--voice-danger) 80%, #fff 20%);
    background: var(--voice-danger);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--voice-danger) 18%, transparent), 0 0 26px color-mix(in srgb, var(--voice-danger) 26%, transparent);
}

[data-voice-component="composer"][data-voice-mode="dictation"].is-recording .voice-transcribe-button {
    color: #09232a;
    border-color: color-mix(in srgb, var(--voice-accent) 70%, #8de8ff 30%);
    background: color-mix(in srgb, var(--voice-accent) 72%, #8de8ff 28%);
    box-shadow: 0 0 0 4px var(--voice-glow), 0 0 24px var(--voice-glow);
}

[data-voice-component="composer"][data-voice-mode="dictation"].is-recording .voice-record-button {
    color: var(--shell-muted);
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

[data-voice-component="composer"].is-synthesizing .speech-synthesize-button .voice-action-icon {
    animation: voice-speaker-breathe 900ms ease-in-out infinite alternate;
}

[data-voice-component="composer"] .speech-compose-status:not([hidden]) {
    display: flex;
    min-height: 26px;
    align-items: center;
    padding: 4px 9px;
    border-left: 2px solid var(--voice-accent);
    color: var(--shell-muted);
    background: var(--voice-glow);
}

[data-voice-component="composer"]:has(.voice-draft:not([hidden])) .chat-compose-row {
    display: none;
}

[data-voice-component="composer"] .voice-draft {
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    min-height: 58px;
    gap: 7px;
    padding: 8px;
    align-items: center;
    border-color: color-mix(in srgb, var(--voice-danger) 32%, var(--voice-line));
    border-radius: 14px;
    background:
        repeating-linear-gradient(90deg, transparent 0 20px, rgb(255 255 255 / 2%) 20px 21px),
        linear-gradient(120deg, var(--voice-panel), color-mix(in srgb, var(--shell-surface) 91%, var(--voice-danger) 9%));
    box-shadow: inset 3px 0 var(--voice-danger), 0 8px 24px rgb(0 0 0 / 8%);
}

[data-voice-component="composer"] .voice-draft .recording-pulse {
    display: none;
}

.voice-signal-meter {
    display: inline-flex;
    height: 22px;
    align-items: center;
    gap: 2px;
}

.voice-signal-meter i {
    width: 2px;
    height: 6px;
    border-radius: 2px;
    background: var(--voice-danger);
    animation: voice-meter 680ms ease-in-out infinite alternate;
}

.voice-signal-meter i:nth-child(2), .voice-signal-meter i:nth-child(5) { animation-delay: -360ms; }
.voice-signal-meter i:nth-child(3) { animation-delay: -120ms; }
.voice-signal-meter i:nth-child(4) { animation-delay: -520ms; }
.voice-signal-meter i:nth-child(6) { animation-delay: -240ms; }

[data-voice-component="composer"] .voice-draft time {
    min-width: 44px;
    color: var(--voice-danger);
    font: 800 13px/1 ui-monospace, SFMono-Regular, Consolas, monospace;
    letter-spacing: .04em;
}

[data-voice-component="composer"] .voice-draft [data-voice-cancel] {
    min-height: 38px;
    padding-inline: 10px;
    color: var(--shell-muted);
    border-color: var(--voice-line);
    background: transparent;
}

[data-voice-component="composer"] .voice-draft [data-voice-send] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding-inline: 11px;
    color: color-mix(in srgb, var(--shell-bg) 92%, #000);
    border-color: var(--voice-accent);
    background: var(--voice-accent);
}

[data-voice-component="composer"][data-voice-mode="dictation"] .voice-draft {
    border-color: var(--voice-line);
    background:
        repeating-linear-gradient(90deg, transparent 0 20px, rgb(255 255 255 / 2%) 20px 21px),
        linear-gradient(120deg, var(--voice-panel), color-mix(in srgb, var(--shell-surface) 90%, var(--voice-accent) 10%));
    box-shadow: inset 3px 0 var(--voice-accent), 0 8px 24px rgb(0 0 0 / 8%);
}

[data-voice-component="composer"][data-voice-mode="dictation"] :is(.voice-signal-meter i) {
    background: var(--voice-accent);
}

[data-voice-component="composer"][data-voice-mode="dictation"] .voice-draft time {
    color: var(--voice-accent);
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft {
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    border-color: var(--voice-line);
    background:
        radial-gradient(circle at 8% 50%, var(--voice-glow), transparent 38%),
        var(--voice-panel);
    box-shadow: inset 3px 0 var(--voice-accent), 0 8px 24px rgb(0 0 0 / 8%);
}

[data-voice-component="composer"][data-voice-state="speech-ready"] :is(.voice-signal-meter, .recording-pulse) {
    display: none;
}

.voice-draft-preview {
    width: 100%;
    min-width: 0;
    height: 34px;
    color-scheme: dark;
}

.voice-draft-preview[hidden] {
    display: none;
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft-preview {
    grid-column: 1 / -1;
    grid-row: 1;
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft time {
    grid-column: 1;
    grid-row: 2;
    color: var(--voice-accent);
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft [data-voice-status] {
    grid-column: 2;
    grid-row: 2;
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft [data-voice-cancel] {
    grid-column: 3;
    grid-row: 2;
}

[data-voice-component="composer"][data-voice-state="speech-ready"] .voice-draft [data-voice-send] {
    grid-column: 4;
    grid-row: 2;
}

.voice-message-player {
    display: flex;
    width: min(100%, 260px);
    margin-top: 7px;
    background: none;
}

.own-message .voice-message-player {
    justify-content: flex-end;
}

.voice-message-bubble {
    position: relative;
    display: flex;
    width: min(100%, var(--voice-bubble-width, 132px));
    min-width: 104px;
    min-height: 44px;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    border: 1px solid color-mix(in srgb, var(--voice-accent) 38%, var(--voice-line));
    border-radius: 15px 15px 15px 5px;
    color: var(--shell-text);
    background: linear-gradient(135deg, color-mix(in srgb, var(--voice-accent) 16%, var(--voice-panel)), var(--voice-panel));
    box-shadow: 0 5px 16px rgb(0 0 0 / 8%), inset 0 1px rgb(255 255 255 / 8%);
    cursor: pointer;
    transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.own-message .voice-message-bubble { border-radius: 15px 15px 5px 15px; }
.voice-message-bubble:hover { transform: translateY(-1px); border-color: var(--voice-accent); box-shadow: 0 8px 20px rgb(0 0 0 / 12%); }
.voice-message-bubble:focus-visible { outline: 2px solid var(--voice-accent); outline-offset: 3px; }
.voice-message-bubble time { margin-left: auto; color: var(--shell-muted); font: 800 11px/1 ui-monospace, monospace; }
.voice-message-audio { display: none !important; }

.voice-bubble-signal {
    display: inline-flex;
    width: 22px;
    height: 22px;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    color: var(--voice-accent);
}

.voice-bubble-signal i {
    width: 3px;
    border-radius: 999px;
    background: currentColor;
    transform-origin: center;
}

.voice-bubble-signal i:nth-child(1) { height: 7px; opacity: .56; }
.voice-bubble-signal i:nth-child(2) { height: 13px; opacity: .78; }
.voice-bubble-signal i:nth-child(3) { height: 19px; }
.voice-message-player.is-playing .voice-bubble-signal i { animation: voice-bubble-speak 720ms ease-in-out infinite alternate; }
.voice-message-player.is-playing .voice-bubble-signal i:nth-child(2) { animation-delay: -240ms; }
.voice-message-player.is-playing .voice-bubble-signal i:nth-child(3) { animation-delay: -480ms; }
.voice-message-player.is-error .voice-message-bubble { border-color: #c85a68; }

@keyframes voice-bubble-speak {
    from { transform: scaleY(.45); opacity: .5; }
    to { transform: scaleY(1); opacity: 1; }
}

.voice-transcript {
    position: relative;
    padding: 8px 10px 8px 28px;
    border: 1px dashed color-mix(in srgb, var(--voice-accent) 24%, transparent);
    background: color-mix(in srgb, var(--shell-surface-2) 76%, transparent);
}

.voice-transcript::before {
    position: absolute;
    top: 8px;
    left: 10px;
    color: var(--voice-accent);
    content: 'Aa';
    font: 800 9px/1.4 ui-monospace, monospace;
}

[data-voice-component="live-room"] {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 82px;
    gap: 12px;
    overflow: hidden;
    padding: 12px;
    border-color: var(--voice-line);
    border-radius: 16px;
    background:
        linear-gradient(90deg, transparent 49%, color-mix(in srgb, var(--voice-accent) 8%, transparent) 50%, transparent 51%) 0 0 / 24px 100%,
        radial-gradient(circle at 8% 50%, var(--voice-glow), transparent 42%),
        var(--voice-panel);
    box-shadow: inset 0 1px rgb(255 255 255 / 6%), 0 14px 32px rgb(0 0 0 / 12%);
}

[data-voice-component="live-room"] > div:first-child {
    grid-template-columns: 42px minmax(0, 1fr);
    grid-template-rows: auto auto auto;
    column-gap: 10px;
}

.live-voice-beacon {
    display: grid;
    grid-row: 1 / 4;
    width: 42px;
    height: 42px;
    place-items: center;
    align-self: center;
    border: 1px solid var(--voice-line);
    border-radius: 50%;
    color: var(--voice-accent);
    background: var(--voice-glow);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--voice-accent) 6%, transparent);
}

.live-voice-beacon span { display: grid; width: 21px; height: 21px; place-items: center; }
.live-voice-beacon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; }
[data-voice-component="live-room"] strong { font-size: 12px; letter-spacing: .08em; }
[data-voice-component="live-room"] [data-live-status] { font-size: 12px; }
[data-voice-component="live-room"] [data-live-speakers] { opacity: .72; letter-spacing: .02em; }

[data-voice-component="live-room"] .live-voice-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    border-color: var(--voice-line);
    color: var(--voice-accent);
    background: var(--voice-glow);
}

[data-voice-component="live-room"] [hidden] {
    display: none !important;
}

[data-voice-component="live-room"][data-state="connected"] .live-voice-beacon {
    color: #b9ffe9;
    border-color: #57d9ae;
    background: rgb(87 217 174 / 18%);
    animation: voice-live-beacon 1.8s ease-in-out infinite;
}

.room-live-voice-notice {
    position: relative;
    overflow: hidden;
    border-left: 3px solid var(--shell-accent);
    background: linear-gradient(90deg, color-mix(in srgb, var(--shell-accent) 12%, var(--shell-surface-2)), var(--shell-surface-2));
}

.room-live-voice-notice::after {
    color: color-mix(in srgb, var(--shell-accent) 32%, transparent);
    content: ')))';
    font: 800 18px/1 ui-monospace, monospace;
    letter-spacing: -5px;
}

@keyframes voice-meter { from { height: 5px; opacity: .52; } to { height: 20px; opacity: 1; } }
@keyframes voice-speaker-breathe { to { transform: scale(1.13); } }
@keyframes voice-live-beacon { 50% { box-shadow: 0 0 0 9px rgb(87 217 174 / 0%); } }

@media (max-width: 620px) {
    [data-voice-component="live-room"] { grid-template-columns: 1fr; }
}

@container (max-width: 380px) {
    [data-voice-component="composer"] .chat-compose-row { grid-template-columns: repeat(3, minmax(44px, 1fr)) auto; }
    [data-voice-component="composer"] :is(.speech-synthesize-button, .voice-record-button, .voice-transcribe-button) { min-width: 0; padding-inline: 7px; }
    [data-voice-component="composer"] .voice-action-label { font-size: 11px; }
    [data-voice-component="composer"] .chat-compose-row > button[type="submit"] { min-width: 66px; padding-inline: 11px; }
    [data-voice-component="composer"] .voice-draft { grid-template-columns: auto auto minmax(0, 1fr) auto auto; }
    [data-voice-component="composer"] .voice-draft [data-voice-status] { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    .voice-signal-meter i,
    [data-voice-component="composer"].is-synthesizing .voice-action-icon,
    [data-voice-component="live-room"][data-state="connected"] .live-voice-beacon { animation: none; }
    .voice-signal-meter i:nth-child(2n) { height: 14px; }
}
