/* Timzo's voice assistant: the microphone in the shell and the panel js/voice/voice.js draws. On every page, so every
   rule is scoped under .tz-voice-* or .vx-*. Colours come from the shell's tokens, so it follows light and dark and the
   module you're in. */

/* ---------- The microphone ---------- */

.tz-voice-mic {
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    background: var(--tz-accent);
    box-shadow: var(--tz-shadow-accent, 0 10px 24px -10px rgba(30, 27, 38, 0.5));
    transition: transform var(--tz-transition, 160ms ease), background var(--tz-transition, 160ms ease);
}

.tz-voice-mic:hover {
    background: var(--tz-accent-strong, var(--tz-accent));
}

.tz-voice-mic:focus-visible {
    outline: 3px solid var(--tz-accent-soft);
    outline-offset: 3px;
}

/* Without a package the button stays, but quietly: an offer, not a call to action. */
.tz-voice-mic[data-vx-state="upsell"] {
    color: var(--tz-ink-2);
    background: var(--tz-surface-2);
    box-shadow: none;
    border: 1px solid var(--tz-line);
}

.tz-voice-mic.is-listening {
    animation: tz-voice-pulse 1.4s ease-in-out infinite;
}

@keyframes tz-voice-pulse {
    0%, 100% { box-shadow: 0 0 0 0 var(--tz-accent-soft); }
    50% { box-shadow: 0 0 0 10px transparent; }
}

.tz-voice-mic--fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1390;
    width: 56px;
    height: 56px;
}

/* Cook's dock sits at the bottom right while a recipe is on the go; the microphone steps aside for it. */
body:has(> #ck-dock:not([hidden])) .tz-voice-mic--fab {
    right: 392px;
}

.tz-voice-mic--bar {
    display: none;
}

@media (max-width: 900px) {
    .tz-voice-mic--fab {
        display: none;
    }

    .tz-voice-mic--bar {
        display: inline-grid;
        width: 40px;
        height: 40px;
        margin-left: auto;
    }
}

@media print {
    .tz-voice-mic,
    .vx-panel {
        display: none !important;
    }
}

/* ---------- The panel ---------- */

.vx-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    z-index: 1500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(400px, calc(100vw - 32px));
    max-height: min(72vh, 640px);
    overflow-y: auto;
    padding: 14px 16px 16px;
    border-radius: var(--tz-radius-lg, 18px);
    background: var(--tz-surface-1);
    color: var(--tz-ink-1);
    border: 1px solid var(--tz-line);
    border-top: 4px solid var(--tz-accent);
    box-shadow: var(--tz-shadow-2, 0 18px 40px -16px rgba(30, 27, 38, 0.45));
    font-family: var(--tz-font, system-ui, sans-serif);
}

.vx-panel[hidden] {
    display: none;
}

@media (max-width: 900px) {
    .vx-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: calc(var(--tz-tabbar-height, 72px) + 8px + env(safe-area-inset-bottom, 0px));
    }
}

.vx-panel__head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.vx-panel__title {
    font-size: 0.95rem;
}

.vx-panel__settings {
    margin-left: auto;
    font-size: 0.82rem;
    color: var(--tz-ink-2);
}

.vx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: var(--tz-radius-pill, 999px);
    border: 1px solid var(--tz-line-strong, var(--tz-line));
    background: var(--tz-surface-1);
    color: var(--tz-ink-1);
    font: inherit;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.vx-btn:hover {
    background: var(--tz-surface-2);
}

.vx-btn--primary {
    border-color: transparent;
    background: var(--tz-accent);
    color: #fff;
}

.vx-btn--primary:hover {
    background: var(--tz-accent-strong, var(--tz-accent));
}

.vx-btn--link {
    border-color: transparent;
    color: var(--tz-accent-strong, var(--tz-accent));
}

.vx-btn--close {
    min-height: 32px;
    width: 32px;
    padding: 0;
    border: 0;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--tz-ink-2);
}

.vx-actions,
.vx-step__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vx-actions {
    justify-content: flex-end;
}

.vx-note {
    padding: 10px 12px;
    border-radius: var(--tz-radius, 12px);
    background: var(--tz-surface-2);
    color: var(--tz-ink-1);
    font-size: 0.92rem;
    line-height: 1.45;
}

.vx-note--error {
    background: color-mix(in srgb, var(--tz-rose, #C2523C) 14%, var(--tz-surface-1));
}

.vx-status {
    color: var(--tz-ink-2);
    font-size: 0.88rem;
    text-align: center;
}

.vx-hint {
    color: var(--tz-ink-3);
    font-size: 0.78rem;
    text-align: center;
}

.vx-heard {
    margin: 0;
    font-size: 1.02rem;
    line-height: 1.45;
    color: var(--tz-ink-1);
}

.vx-heard__interim {
    color: var(--tz-ink-3);
}

.vx-sentence {
    margin: 0;
    padding-left: 10px;
    border-left: 3px solid var(--tz-accent-soft);
    color: var(--tz-ink-2);
    font-size: 0.92rem;
}

/* ---------- Listening: a big stop button inside a ring that shrinks while it's quiet ---------- */

.vx-listening {
    display: grid;
    place-items: center;
    padding: 6px 0;
}

.vx-listen {
    position: relative;
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    border: 0;
    border-radius: 50%;
    background: var(--tz-accent);
    color: #fff;
    cursor: pointer;
    animation: tz-voice-pulse 1.4s ease-in-out infinite;
}

.vx-listen__mic {
    width: 34px;
    height: 34px;
}

.vx-ring {
    position: absolute;
    inset: -8px;
    width: calc(100% + 16px);
    height: calc(100% + 16px);
    transform: rotate(-90deg);
    pointer-events: none;
}

.vx-ring circle {
    fill: none;
    stroke: var(--tz-accent-soft);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 182.2;
    stroke-dashoffset: 0;
    opacity: 0;
}

.vx-ring.is-running circle {
    opacity: 1;
    animation: vx-ring var(--vx-silence, 1500ms) linear forwards;
}

@keyframes vx-ring {
    from { stroke-dashoffset: 0; }
    to { stroke-dashoffset: 182.2; }
}

@media (prefers-reduced-motion: reduce) {
    .tz-voice-mic.is-listening,
    .vx-listen {
        animation: none;
    }
}

.vx-spinner {
    justify-self: center;
    align-self: center;
    width: 28px;
    height: 28px;
    margin: 6px auto;
    border-radius: 50%;
    border: 3px solid var(--tz-line);
    border-top-color: var(--tz-accent);
    animation: vx-spin 0.9s linear infinite;
}

@keyframes vx-spin {
    to { transform: rotate(360deg); }
}

/* ---------- What will be done ---------- */

.vx-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.vx-step {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--tz-radius, 12px);
    border: 1px solid var(--tz-line);
    background: var(--tz-surface-1);
}

.vx-step--pending,
.vx-step--failed {
    border-color: var(--tz-accent-soft);
    background: var(--tz-accent-wash, var(--tz-surface-2));
}

.vx-step--dropped {
    opacity: 0.6;
}

.vx-step--empty {
    color: var(--tz-ink-2);
}

.vx-step__head {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.vx-step__summary {
    flex: 1;
    font-weight: 600;
    font-size: 0.94rem;
}

.vx-step__detail,
.vx-step__busy {
    color: var(--tz-ink-2);
    font-size: 0.84rem;
}

.vx-step__problem {
    color: var(--tz-ink-1);
    font-size: 0.86rem;
}

.vx-chip {
    flex: none;
    padding: 2px 8px;
    border-radius: var(--tz-radius-pill, 999px);
    background: var(--tz-surface-2);
    color: var(--tz-ink-2);
    font-size: 0.74rem;
    font-weight: 600;
}

.vx-chip--done,
.vx-chip--client {
    background: color-mix(in srgb, var(--tz-teal, #2E8B7A) 18%, var(--tz-surface-1));
    color: var(--tz-ink-1);
}

.vx-chip--pending {
    background: var(--tz-accent);
    color: #fff;
}

.vx-chip--failed {
    background: color-mix(in srgb, var(--tz-rose, #C2523C) 20%, var(--tz-surface-1));
    color: var(--tz-ink-1);
}

.vx-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.vx-field {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.vx-field:first-child {
    grid-column: 1 / -1;
}

.vx-field__label {
    color: var(--tz-ink-2);
    font-size: 0.76rem;
}

.vx-field input,
.vx-field select {
    min-height: 38px;
    padding: 0 10px;
    border-radius: var(--tz-radius-sm, 8px);
    border: 1px solid var(--tz-line-strong, var(--tz-line));
    background: var(--tz-surface-1);
    color: var(--tz-ink-1);
    font: inherit;
    font-size: 0.92rem;
}

.vx-choice {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: 0;
}

.vx-choice legend {
    margin-bottom: 4px;
    color: var(--tz-ink-2);
    font-size: 0.82rem;
}

.vx-choice__item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--tz-radius-sm, 8px);
    border: 1px solid var(--tz-line);
    background: var(--tz-surface-1);
    cursor: pointer;
}

.vx-choice__item small {
    color: var(--tz-ink-3);
}

/* ---------- The settings page ---------- */

.tz-voice-learned {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 0 var(--tz-space-4);
    padding: 0;
    list-style: none;
}

.tz-voice-learned li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--tz-radius-sm, 8px);
    background: var(--tz-surface-2);
    font-size: 0.9rem;
}

.tz-voice-learned__main {
    flex: 1;
    min-width: 0;
}

.tz-voice-learned__sub {
    display: block;
    color: var(--tz-ink-2);
    font-size: 0.8rem;
}

.tz-voice-rate {
    font-family: var(--tz-font-numeric, inherit);
    font-variant-numeric: tabular-nums;
}
