/*
 * "Translate live speech": the try-it area of the home page and the host page (js/speech-demo.js; owner, 2026-11-26).
 * Daylight rules (docs/design.md): neutral surfaces, ONE accent (the Start button and the live ring), no gradients.
 * The subtitle screen is a dark slab in both themes (it carries data-theme="dark", so the tokens inside it are the
 * dark ones): subtitles read as subtitles on a screen, and the eye goes to it at once.
 */

/* the home page's section, and the card it sits in */
.h4-try { padding: clamp(64px, 8vw, 112px) 0 0; }
.h4-try-card { max-width: 860px; margin: clamp(24px, 4vw, 40px) auto 0; padding: clamp(16px, 3vw, 28px); }

.sd { display: grid; gap: 16px; container-type: inline-size; --sd-level: 0; text-align: left; }

/* the language to read in, and the time left */
.sd-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sd-lang { display: grid; gap: 6px; flex: 1 1 220px; max-width: 360px; min-width: 0; margin: 0; }
.sd-lang-label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); }
.sd-select { width: 100%; min-height: 44px; }
.sd-timer {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--bg-card);
  color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums;
}
.sd-timer svg { width: 16px; height: 16px; }

/* the subtitle screen */
.sd-stage {
  position: relative; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
  min-height: 240px; padding: clamp(18px, 4cqi, 28px);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--bg-page); color: var(--text); overflow: hidden; text-align: center;
}
.sd-status { margin: 0; color: var(--text-muted); font-size: var(--fs-lg); line-height: 1.5; }
.sd-status:empty { display: none; }
.sd-lines { display: grid; gap: 8px; }
.sd-line {
  margin: 0; font-size: clamp(1.15rem, 3.2cqi + 0.5rem, 1.85rem); font-weight: 600; line-height: 1.3;
  color: var(--text-muted); overflow-wrap: anywhere; transition: color var(--dur) var(--ease-out);
}
.sd-line.is-new { color: var(--text); animation: sd-in var(--dur-slow, 0.3s) var(--ease-out); }
/* what was heard, in the speaker's own language */
.sd-said { margin: 0; padding-top: 12px; border-top: 1px solid var(--border); min-height: 2.6em; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.45; overflow-wrap: anywhere; }
.sd-said-lang { margin-right: 8px; font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-secondary); }
.sd-said-lang:empty { display: none; }
/* the red dot of a microphone that is on */
.sd[data-state="live"] .sd-stage::before {
  content: ""; position: absolute; top: 16px; right: 18px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--danger); animation: sd-pulse 1.4s var(--ease-in-out, ease-in-out) infinite;
}

/* the button, and the ring that follows the voice */
.sd-actions { display: flex; align-items: center; gap: 12px 18px; flex-wrap: wrap; }
.sd-btn { position: relative; min-width: 220px; min-height: 52px; gap: 10px; font-size: var(--fs-lg); }
.sd-btn svg { width: 20px; height: 20px; }
.sd-ring {
  position: absolute; inset: -5px; border: 2px solid var(--brand); border-radius: inherit; opacity: 0; pointer-events: none;
  transform: scale(calc(1 + var(--sd-level) * 0.07)); transition: transform 90ms linear, opacity var(--dur) var(--ease-out);
}
.sd[data-state="live"] .sd-ring { opacity: 0.6; }
.sd-note { flex: 1 1 240px; margin: 0; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.5; }

/* after the day's five minutes */
.sd-after { display: grid; gap: 8px; justify-items: start; padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-subtle); }
.sd-after[hidden] { display: none; }
.sd-after-title { margin: 0; font-weight: 700; color: var(--text); }
.sd-after-body { margin: 0 0 4px; color: var(--text-secondary); }

/* the host page: the test is a card before going live, and steps aside while a broadcast runs */
.sd-card:has(.sd[data-blocked="1"]) { display: none; }
.sd-card .sd { margin-top: 16px; }
.sd-card .sd-stage { min-height: 180px; }

/* phones: the button takes the row */
@container (max-width: 480px) {
  .sd-stage { min-height: 200px; }
  .sd-btn { width: 100%; }
  .sd-timer { margin-left: auto; }
}

@keyframes sd-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sd-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .sd-line.is-new, .sd[data-state="live"] .sd-stage::before { animation: none; }
  .sd-ring { transition: none; transform: none; }
}
