/* ════════════════════════════════════════════════════════════════
   interrogation.css — Stili modal Interrogazione Vocale.
   Design system Studovo: cream #faf8f1, ink #1a1a1a, terracotta #8a3a1f,
   forest #2d5a3d. Font: Fraunces, Iowan Old Style, Bricolage Grotesque,
   JetBrains Mono.

   Da includere in app.html:
     <link rel="stylesheet" href="interrogation.css">

   v1.0 — 2026-05
   ════════════════════════════════════════════════════════════════ */

/* ─── Overlay + box ─────────────────────────────────────────────── */

.interrogation-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.72);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.interrogation-modal-overlay[hidden] { display: none; }

.interrogation-modal-box {
  background: #faf8f1;
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  padding: 36px 40px 32px;
  border: 1px solid #d4cab4;
}

/* ─── Close button ───────────────────────────────────────────────── */

.im-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid #d4cab4;
  background: #faf8f1;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #5a4a38;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.im-close:hover {
  background: #f3eedc;
  color: #1a1a1a;
  border-color: #8a3a1f;
}

/* ─── Eyebrow + titles ───────────────────────────────────────────── */

.im-eyebrow {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8a3a1f;
  margin-bottom: 10px;
}

.im-title {
  font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  color: #1a1a1a;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.im-desc {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 14px;
  color: #3c3228;
  line-height: 1.55;
  margin: 0 0 24px;
}

/* ─── Sections ───────────────────────────────────────────────────── */

.im-section {
  margin-bottom: 22px;
}

.im-label {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a4a38;
  margin-bottom: 10px;
}

/* ─── Level cards ────────────────────────────────────────────────── */

.im-level-stack {
  display: grid;
  gap: 10px;
}

.im-level-card {
  display: block;
  padding: 14px 16px;
  border: 1.5px solid #d4cab4;
  border-radius: 8px;
  background: #faf8f1;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  position: relative;
}
.im-level-card:hover {
  border-color: #b5a890;
  background: #f3eedc;
}
.im-level-card.is-selected {
  border-color: #8a3a1f;
  background: rgba(138, 58, 31, 0.05);
  box-shadow: 0 0 0 1px #8a3a1f;
}
.im-level-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.im-level-h {
  font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  font-weight: 500;
  font-size: 17px;
  color: #1a1a1a;
  margin-bottom: 3px;
}
.im-level-card.is-selected .im-level-h { color: #8a3a1f; }

.im-level-d {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 12.5px;
  color: #5a4a38;
  font-style: italic;
  line-height: 1.4;
}

/* ─── Mic dropdown + test ────────────────────────────────────────── */

.im-mic-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.im-mic-select {
  flex: 1 1 auto;
  padding: 10px 12px;
  border: 1px solid #d4cab4;
  border-radius: 6px;
  background: #faf8f1;
  color: #1a1a1a;
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
  min-width: 0;
}
.im-mic-select:focus {
  border-color: #8a3a1f;
  box-shadow: 0 0 0 2px rgba(138, 58, 31, 0.10);
}
.im-mic-select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.im-mic-test-btn {
  flex: 0 0 auto;
  padding: 0 16px;
  background: transparent;
  color: #5a4a38;
  border: 1px solid #d4cab4;
  border-radius: 6px;
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.im-mic-test-btn:hover {
  background: #f3eedc;
  color: #1a1a1a;
  border-color: #8a3a1f;
}

.im-mic-test-meter {
  margin-top: 8px;
  height: 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 3px;
  overflow: hidden;
}
.im-mic-test-meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(to right, #2d5a3d, #8a3a1f);
  transition: width 0.1s ease-out;
}

.im-mic-warn {
  margin-top: 6px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 12px;
  color: #C84B23;
  line-height: 1.4;
}

/* ─── Warn row (sopra il bottone START) ──────────────────────────── */

.im-warn-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  background: rgba(200, 75, 35, 0.07);
  border: 1px solid rgba(200, 75, 35, 0.25);
  border-radius: 6px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 12.5px;
  color: #5a4a38;
  line-height: 1.5;
}
.im-warn-icon {
  flex: 0 0 auto;
  color: #C84B23;
  font-size: 14px;
  line-height: 1.4;
}

/* ─── CTA + footer ───────────────────────────────────────────────── */

.im-cta {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  background: #1a1a1a;
  color: #faf8f1;
  border: none;
  border-radius: 6px;
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}
.im-cta:hover { background: #8a3a1f; }
.im-cta:disabled, .im-cta.is-loading {
  background: #5a4a38;
  cursor: not-allowed;
  opacity: 0.7;
}
.im-cta.is-loading::after {
  content: ' ⟳';
  display: inline-block;
  animation: im-spin 0.7s linear infinite;
}
.im-cta-arrow {
  font-family: 'Iowan Old Style', Georgia, serif;
  font-size: 16px;
}

.im-footer {
  margin-top: 14px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 12px;
  font-style: italic;
  color: #6e6855;
  text-align: center;
  line-height: 1.4;
}

@keyframes im-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════════
   STEP LIVE
   ═══════════════════════════════════════════════════════════════════ */

.im-live-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.im-live-title {
  font-family: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  font-weight: 500;
  font-size: 15px;
  color: #1a1a1a;
  flex: 1 1 auto;
  margin-right: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.im-live-timer {
  flex: 0 0 auto;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 18px;
  font-weight: 500;
  color: #8a3a1f;
  font-feature-settings: 'tnum' 1;
  letter-spacing: 0.05em;
}

/* ─── Cerchio centrale pulsante ──────────────────────────────────── */

.im-live-circle-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 0 24px;
}

.im-live-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at center, #faf8f1, #f3eedc);
  border: 2px solid #d4cab4;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.3s, background 0.3s;
}

.im-live-circle-inner {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #b5a890;
  transition: background 0.3s, transform 0.3s;
}

.im-live-circle[data-state="idle"] .im-live-circle-inner {
  background: #d4cab4;
}

.im-live-circle[data-state="connecting"] {
  border-color: #b5a890;
}
.im-live-circle[data-state="connecting"] .im-live-circle-inner {
  background: #b5a890;
  animation: im-spin 1.2s linear infinite;
  border-radius: 30%;
}

.im-live-circle[data-state="listening"] {
  border-color: #2d5a3d;
  background: radial-gradient(circle at center, rgba(45, 90, 61, 0.08), rgba(45, 90, 61, 0.02));
}
.im-live-circle[data-state="listening"] .im-live-circle-inner {
  background: #2d5a3d;
  animation: im-pulse-listen 1.2s ease-in-out infinite;
}

.im-live-circle[data-state="thinking"] {
  border-color: #8a3a1f;
  background: radial-gradient(circle at center, rgba(138, 58, 31, 0.06), rgba(138, 58, 31, 0.02));
}
.im-live-circle[data-state="thinking"] .im-live-circle-inner {
  background: #8a3a1f;
  animation: im-pulse-think 1.6s ease-in-out infinite;
}

.im-live-circle[data-state="speaking"] {
  border-color: #8a3a1f;
  background: radial-gradient(circle at center, rgba(138, 58, 31, 0.10), rgba(138, 58, 31, 0.02));
  animation: im-circle-glow 1.4s ease-in-out infinite;
}
.im-live-circle[data-state="speaking"] .im-live-circle-inner {
  background: #8a3a1f;
  animation: im-pulse-speak 1.4s ease-in-out infinite;
}

@keyframes im-pulse-listen {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.18); opacity: 0.85; }
}
@keyframes im-pulse-think {
  0%, 100% { transform: scale(0.85); opacity: 0.5; }
  50% { transform: scale(1.0); opacity: 0.8; }
}
@keyframes im-pulse-speak {
  0%, 100% { transform: scale(1.0); }
  50% { transform: scale(1.35); }
}
@keyframes im-circle-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(138, 58, 31, 0.25); }
  50% { box-shadow: 0 0 0 18px rgba(138, 58, 31, 0); }
}

.im-live-status {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #5a4a38;
  white-space: nowrap;
}

/* ─── Trascritto live ────────────────────────────────────────────── */

.im-live-transcript {
  margin-top: 24px;
  max-height: 220px;
  overflow-y: auto;
  padding: 4px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 14px;
}

.im-trn {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 12px;
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 13px;
  line-height: 1.5;
}

.im-trn-who {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 9.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6e6855;
  font-weight: 500;
}

.im-trn-text {
  color: #1a1a1a;
}

.im-trn-user .im-trn-who { color: #2d5a3d; }
.im-trn-agent .im-trn-who { color: #8a3a1f; }
.im-trn-error .im-trn-text { color: #C84B23; font-style: italic; }
.im-trn-partial .im-trn-text { color: #5a4a38; font-style: italic; }

/* ─── Stop button ────────────────────────────────────────────────── */

.im-stop-btn {
  width: 100%;
  margin-top: 18px;
  padding: 12px 20px;
  background: transparent;
  color: #C84B23;
  border: 1px solid #C84B23;
  border-radius: 6px;
  font-family: 'Bricolage Grotesque', 'Inter', system-ui, sans-serif;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.im-stop-btn:hover {
  background: #C84B23;
  color: #faf8f1;
}

/* ═══════════════════════════════════════════════════════════════════
   STEP RESULT
   ═══════════════════════════════════════════════════════════════════ */

.im-result-meta {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: #6e6855;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.im-result-meta strong {
  color: #1a1a1a;
  font-weight: 600;
}

.im-result-section {
  margin-bottom: 22px;
}

.im-result-evaluation {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 15px;
  line-height: 1.6;
  color: #1a1a1a;
  padding: 16px 18px;
  background: #f3eedc;
  border-left: 3px solid #8a3a1f;
  border-radius: 4px;
  font-style: italic;
}

.im-result-transcript {
  max-height: 280px;
  overflow-y: auto;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 6px;
}

.im-result-empty {
  font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
  font-size: 13px;
  color: #6e6855;
  font-style: italic;
  text-align: center;
  padding: 16px;
}

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 540px) {
  .interrogation-modal-overlay { padding: 12px; }
  .interrogation-modal-box {
    padding: 28px 22px 24px;
    max-height: 95vh;
  }
  .im-title { font-size: 22px; }
  .im-live-circle {
    width: 140px;
    height: 140px;
  }
  .im-live-circle-inner {
    width: 64px;
    height: 64px;
  }
  .im-mic-row { flex-direction: column; }
  .im-mic-test-btn { width: 100%; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .im-live-circle,
  .im-live-circle-inner {
    animation: none !important;
  }
  .im-live-circle[data-state="speaking"] {
    box-shadow: 0 0 0 8px rgba(138, 58, 31, 0.15);
  }
}

/* ─── Bottone "Interrogazione Vocale" nel done-state (panel) ────── */

.dl-btn.dl-interrogation svg { color: #2d5a3d; }
.dl-btn.dl-interrogation.is-pending {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}
.dl-btn.dl-interrogation.is-pending svg {
  animation: im-spin 1.6s linear infinite;
}
.dl-btn.dl-interrogation.is-error {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.dl-btn.dl-interrogation.is-error .dl-meta { color: #C84B23; }
.dl-btn.dl-interrogation.is-used {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}
.dl-btn.dl-interrogation.is-used .dl-meta { color: #6e6855; font-style: italic; }