/* mrktpro dashboard: speaking a question to the chat, and the "Ask AI" button on a phone (docs/chat-voice.md). Only the page's own tokens and logical properties, so it follows the language's
   direction and the theme. Loaded after app.css. */

/* ── The microphone, the language switch and the line above the box ─────────────────────────────── */

/* The foot is one column that may be narrower than its widest row (a box with a microphone, a language and Send is wider than a 360 px screen's box without shrinking its text area). */
.chat-foot { grid-template-columns: minmax(0, 1fr); }
.chat-box { align-items: center; }
.chat-box .chat-input { align-self: stretch; }
.chat-mic { position: relative; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 12px; }
@media (hover: hover) { .chat-mic:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); } }
.chat-mic:focus-visible, .chat-lang:focus-visible, .chat-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-mic:disabled { opacity: 0.5; }
/* Listening: filled with the accent and a ring that breathes (still, for a person who asks for less movement). */
.chat-mic.on, .chat-mic.on:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chat-mic.on svg { fill: currentColor; }
.chat-mic.on::after { content: ""; position: absolute; inset: -4px; border-radius: 16px; border: 2px solid var(--accent); opacity: 0; animation: chat-ring 1.4s ease-out infinite; pointer-events: none; }
@keyframes chat-ring { 0% { opacity: 0.7; transform: scale(0.94); } 100% { opacity: 0; transform: scale(1.18); } }
.chat-lang { position: relative; flex: none; min-width: 36px; height: 36px; padding: 0 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.chat-lang::after { content: ""; position: absolute; inset: -4px; }
@media (hover: hover) { .chat-lang:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); } }
.chat-lang:disabled { opacity: 0.5; cursor: default; }

.chat-voice-bar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--accent); border-radius: 12px; background: var(--accent-bg); color: var(--text); font-size: 14px; }
.chat-voice-bar.ask { display: grid; gap: 8px; border-color: var(--line); background: var(--panel-2); }
.chat-voice-bar .row { display: flex; gap: 8px; }
.chat-voice-text { flex: 1; min-width: 0; margin: 0; line-height: 1.4; }
.chat-voice-clock { font-variant-numeric: tabular-nums; color: var(--muted); }
.chat-voice-pulse { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--neg); animation: chat-pulse 1.1s ease-in-out infinite; }
@keyframes chat-pulse { 0%, 100% { transform: scale(0.8); opacity: 0.6; } 50% { transform: scale(1.15); opacity: 1; } }
.chat-voice-disclose, .chat-voice-note, .chat-voice-problem { margin: 0; line-height: 1.4; }
.chat-voice-changed { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); color: var(--muted); line-height: 1.4; }
.chat-voice-changed span { min-width: 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .chat-mic.on::after { animation: none; opacity: 0.5; transform: none; }
  .chat-voice-pulse { animation: none; }
}

/* ── The sheet on a phone: the whole visible screen, above the keyboard ───────────────────────────── */

@media (max-width: 899px) {
  body.chat-open .chat { inset-block-start: var(--chat-vvt, 0px); inset-block-end: auto; height: var(--chat-vvh, 100dvh); }
  /* A keyboard is up: the sheet is the visible part of the window; the safe area at the bottom is under the keyboard, not under the box. */
  body.kbd-open .chat-foot { padding-block-end: 10px; }
  .chat-box .chat-input { min-height: 44px; }

  /* The way in: a labelled button above the tab bar, on the side the thumb reaches (the end of the line: right in English, left in Hebrew). */
  body:not(.signed-out) { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 72px); }
  .chat-fab {
    position: fixed;
    inset-inline-end: 16px;
    inset-block-end: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
    z-index: 21;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--tap);
    padding: 0 16px;
    border: 0;
    border-radius: var(--radius-pill);
    background: var(--accent);
    color: var(--accent-text);
    font: inherit;
    font-size: var(--fs-body);
    font-weight: 600;
    box-shadow: var(--shadow);
    cursor: pointer;
  }
  .chat-fab[hidden] { display: none; }
  .chat-fab svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  /* Pages that have their own bar at the bottom (Settings' save bar, a review's actions): the button rides above it. */
  body:has(.set-bar, .he-bar, .th-bar) .chat-fab { inset-block-end: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 84px); }
  /* A message at the bottom (signing in, a saved note) is not covered. */
  body:has(.signin-toast, .set-toast:not(:empty)) .chat-fab { inset-block-end: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 76px + 56px); }
  body.chat-open .chat-fab, body.kbd-open .chat-fab, body.signed-out .chat-fab, body:has(dialog[open]) .chat-fab { display: none; }

  .chat-fab-hint {
    position: fixed;
    inset-inline: 16px;
    inset-block-end: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px + var(--tap) + 10px);
    z-index: 21;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 360px;
    margin-inline-start: auto;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: var(--fs-body);
    line-height: 1.4;
  }
  .chat-fab-hint span { flex: 1; min-width: 0; }
  .chat-fab-hint .btn { flex: none; }
  body:has(.set-bar, .he-bar, .th-bar) .chat-fab-hint { inset-block-end: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 84px + var(--tap) + 10px); }
  body.chat-open .chat-fab-hint, body.kbd-open .chat-fab-hint, body.signed-out .chat-fab-hint, body:has(dialog[open]) .chat-fab-hint { display: none; }
}
@media (min-width: 900px) {
  .chat-fab, .chat-fab-hint { display: none; }
}
@media print { .chat-fab, .chat-fab-hint { display: none !important; } }
