/* =====================================================================
   Cover The Gaps — Study Tools · Pronunciation Assessment · PRODUCTION
   Self-contained: vendors the "Aurora" design tokens + minimal base it
   needs (so it does not depend on any other stylesheet), then the tool
   styles. Scoped under .pa-page so it cannot leak onto the rest of the
   site (base.html nav/footer keep their own styles).

   Mirrors the output of Azure Pronunciation Assessment / Speechace:
   overall + sub scores, CEFR/IELTS estimate, fluency metrics,
   word-by-word accuracy, phoneme drill-down, recognized transcript.
   ===================================================================== */

/* ---------- vendored Aurora tokens (subset used by this page) ---------- */
.pa-page, .pa-page * { box-sizing: border-box; }
.pa-page {
  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --surface:   #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f8;
  --border:    #e6e8ef;
  --border-2:  #d9dce6;
  --text:      #1a2030;
  --text-2:    #5b6577;
  --text-3:    #8b94a6;

  --primary:     #4f46e5;
  --primary-700: #4338ca;
  --primary-50:  #eef0fe;
  --primary-100: #e0e2fb;

  --sky:    #0e7490;  --sky-bg:  #e0f2f7;

  --good:   #0a8f53;  --good-bg: #e6f6ee;
  --fair:   #b4690e;  --fair-bg: #fbf0dd;
  --poor:   #d61f49;  --poor-bg: #fdeaee;
  --miss:   #8b94a6;  --miss-bg: #eef0f4;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-xl: 20px;
  --shadow-sm: 0 1px 2px rgba(20,28,48,.05), 0 1px 1px rgba(20,28,48,.04);
  --shadow:    0 2px 8px rgba(20,28,48,.06), 0 1px 2px rgba(20,28,48,.05);
  --shadow-md: 0 8px 28px rgba(20,28,48,.10), 0 2px 6px rgba(20,28,48,.06);
  --shadow-pop:0 18px 50px rgba(20,28,48,.22);
  --ease: cubic-bezier(.22,.61,.36,1);

  font-family: var(--font);
  color: var(--text);
}

/* buttons (vendored — only what this page uses) */
.pa-page .btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 15px; border-radius: 10px;
  border: 1px solid var(--border-2); background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 14px; font-weight: 650; cursor: pointer; white-space: nowrap;
  transition: .15s var(--ease);
}
.pa-page .btn:hover { background: var(--surface-3); }
.pa-page .btn:active { transform: translateY(1px); }
.pa-page .btn svg { width: 17px; height: 17px; }
.pa-page .btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(79,70,229,.35); }
.pa-page .btn--primary:hover { background: var(--primary-700); border-color: var(--primary-700); }

/* ---------- page shell ---------- */
.pa-page { max-width: 1180px; margin: 0 auto; padding: 30px 24px 96px; }

.pa-page .pa-head { margin-bottom: 22px; }
.pa-page .pa-head__eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-50);
  padding: 5px 11px; border-radius: 999px; margin-bottom: 12px;
}
.pa-page .pa-head__eyebrow svg { width: 14px; height: 14px; }
.pa-page .pa-head h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.025em; }
.pa-page .pa-head p { margin: 7px 0 0; color: var(--text-2); font-size: 15px; max-width: 64ch; }

/* ---------- two-column layout ---------- */
.pa-page .pa-grid {
  display: grid; grid-template-columns: 380px 1fr; gap: 22px; align-items: start;
}
@media (max-width: 900px){ .pa-page .pa-grid { grid-template-columns: 1fr; } }

.pa-page .card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
}
.pa-page .card__head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.pa-page .card__head svg { width: 18px; height: 18px; color: var(--primary); }
.pa-page .card__head h2 { margin: 0; font-size: 15px; font-weight: 750; letter-spacing: -.01em; }
.pa-page .card__head .card__hint { margin-left: auto; font-size: 12px; color: var(--text-3); font-weight: 600; }
.pa-page .card__body { padding: 18px; }

/* =====================================================================
   LEFT — Speak panel
   ===================================================================== */
.pa-page .pa-speak { position: sticky; top: 78px; }

.pa-page .field-label { font-size: 12.5px; font-weight: 750; color: var(--text-2); margin: 0 0 8px; }

.pa-page .phrase-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; }
.pa-page .chip {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 650; cursor: pointer;
  transition: .14s var(--ease); font-family: inherit;
}
.pa-page .chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }
.pa-page .chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.pa-page .ref-box {
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2);
  padding: 16px; margin-bottom: 8px;
}
.pa-page .ref-box .ref-text {
  font-size: 22px; font-weight: 700; line-height: 1.4; letter-spacing: -.01em; color: var(--text);
  text-wrap: pretty;
}
.pa-page .ref-box .ref-edit {
  width: 100%; border: 0; background: none; outline: none; resize: none;
  font-family: inherit; font-size: 22px; font-weight: 700; line-height: 1.4; color: var(--text);
}
.pa-page .ref-box .ref-listen {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 12px;
  font-size: 13px; font-weight: 650; color: var(--primary); cursor: pointer;
  background: none; border: 0; padding: 0; font-family: inherit;
}
.pa-page .ref-box .ref-listen svg { width: 15px; height: 15px; }

/* recorder */
.pa-page .recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 18px; }

.pa-page .mic-btn {
  width: 84px; height: 84px; border-radius: 50%; border: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; position: relative;
  background: linear-gradient(135deg, var(--primary), #7c74f3);
  box-shadow: 0 10px 26px rgba(79,70,229,.36); transition: transform .14s var(--ease), background .2s var(--ease);
}
.pa-page .mic-btn:hover { transform: translateY(-2px); }
.pa-page .mic-btn:active { transform: translateY(0); }
.pa-page .mic-btn svg { width: 34px; height: 34px; }
.pa-page .mic-btn.is-recording { background: linear-gradient(135deg, #ef4444, #dc2626); box-shadow: 0 10px 26px rgba(220,38,38,.4); }
.pa-page .mic-btn.is-analyzing { background: var(--surface-3); color: var(--text-2); box-shadow: none; cursor: default; }
.pa-page .mic-btn .pulse {
  position: absolute; inset: -6px; border-radius: 50%; border: 3px solid rgba(239,68,68,.5);
  animation: micpulse 1.4s var(--ease) infinite; pointer-events: none; opacity: 0;
}
.pa-page .mic-btn.is-recording .pulse { opacity: 1; }
@keyframes micpulse { 0% { transform: scale(.92); opacity:.7;} 70% { transform: scale(1.25); opacity:0;} 100% {opacity:0;} }
.pa-page .mic-btn .spinner { width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--border-2); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.pa-page .mic-caption { font-size: 13px; font-weight: 650; color: var(--text-2); text-align: center; min-height: 18px; }
.pa-page .mic-caption b { color: var(--text); }

/* live waveform */
.pa-page .wave-wrap { width: 100%; height: 60px; display: none; }
.pa-page .wave-wrap.is-on { display: block; }
.pa-page .wave-wrap canvas { width: 100%; height: 60px; display: block; }

.pa-page .rec-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 15px; color: var(--poor); display: none; align-items: center; gap: 7px; }
.pa-page .rec-timer.is-on { display: inline-flex; }
.pa-page .rec-timer .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--poor); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }

.pa-page .playback { width: 100%; margin-top: 4px; display: none; }
.pa-page .playback.is-on { display: block; }
.pa-page .playback audio { width: 100%; height: 38px; }

.pa-page .mic-tip {
  margin-top: 6px; font-size: 12px; color: var(--text-3); text-align: center; line-height: 1.5;
  display: flex; align-items: center; gap: 6px; justify-content: center;
}
.pa-page .mic-tip svg { width: 13px; height: 13px; flex: none; }

/* =====================================================================
   RIGHT — Results report
   ===================================================================== */
.pa-page .pa-results { display: flex; flex-direction: column; gap: 18px; }

/* empty / placeholder state */
.pa-page .pa-empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
  padding: 70px 28px;
}
.pa-page .pa-empty__icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center;
  background: var(--primary-50); color: var(--primary); margin-bottom: 6px;
}
.pa-page .pa-empty__icon svg { width: 30px; height: 30px; }
.pa-page .pa-empty h3 { margin: 0; font-size: 17px; font-weight: 750; }
.pa-page .pa-empty p { margin: 0; color: var(--text-2); font-size: 14px; max-width: 42ch; }

.pa-page .pa-results.is-hidden { display: none; }
.pa-page .pa-empty.is-hidden { display: none; }

/* ---- overall score band ---- */
.pa-page .score-band { display: grid; grid-template-columns: auto 1fr; gap: 26px; align-items: center; }
@media (max-width: 560px){ .pa-page .score-band { grid-template-columns: 1fr; justify-items: center; text-align: center; } }

.pa-page .ring { position: relative; width: 132px; height: 132px; flex: none; }
.pa-page .ring svg { transform: rotate(-90deg); display: block; }
.pa-page .ring__track { fill: none; stroke: var(--surface-3); }
.pa-page .ring__val { fill: none; stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.pa-page .ring__center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.pa-page .ring__center b { display: block; font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.pa-page .ring__center span { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-top: 3px; }

.pa-page .score-meta h2 { margin: 0 0 4px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.pa-page .score-meta .verdict { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.pa-page .score-meta .verdict.good { color: var(--good); }
.pa-page .score-meta .verdict.fair { color: var(--fair); }
.pa-page .score-meta .verdict.poor { color: var(--poor); }
.pa-page .score-meta p { margin: 8px 0 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; max-width: 46ch; }

/* ---- sub scores ---- */
.pa-page .subs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 22px; }
@media (max-width: 560px){ .pa-page .subs { grid-template-columns: repeat(2, 1fr); } }
.pa-page .sub {
  border: 1px solid var(--border); border-radius: var(--r); padding: 13px 13px 14px;
  background: var(--surface-2);
}
.pa-page .sub__top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.pa-page .sub__val { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.pa-page .sub__max { font-size: 12px; color: var(--text-3); font-weight: 700; }
.pa-page .sub__label { font-size: 12px; color: var(--text-2); font-weight: 700; margin-top: 6px; }
.pa-page .sub__bar { height: 6px; border-radius: 999px; background: var(--surface-3); margin-top: 9px; overflow: hidden; }
.pa-page .sub__fill { height: 100%; border-radius: 999px; width: 0; transition: width .9s var(--ease); }

/* ---- estimate band (Speechace-style) ---- */
.pa-page .estimate { display: flex; flex-wrap: wrap; gap: 12px; }
.pa-page .est {
  flex: 1 1 0; min-width: 130px; border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; background: var(--surface-2); position: relative; overflow: hidden;
}
.pa-page .est::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.pa-page .est__label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
.pa-page .est__val { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.pa-page .est__note { font-size: 12px; color: var(--text-2); font-weight: 600; margin-top: 2px; }

/* ---- fluency metrics ---- */
.pa-page .metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; }
@media (max-width: 560px){ .pa-page .metrics { grid-template-columns: repeat(2, 1fr); } }
.pa-page .metric { padding: 4px 14px; border-left: 1px solid var(--border); }
.pa-page .metric:first-child { border-left: 0; padding-left: 0; }
.pa-page .metric__val { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.pa-page .metric__val small { font-size: 13px; font-weight: 700; color: var(--text-3); }
.pa-page .metric__label { font-size: 12px; color: var(--text-2); font-weight: 650; margin-top: 3px; display: flex; align-items: center; gap: 5px; }
.pa-page .metric__label svg { width: 13px; height: 13px; color: var(--text-3); }

/* ---- word-by-word ---- */
.pa-page .legend { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 14px; }
.pa-page .legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
.pa-page .legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.pa-page .legend i.good { background: var(--good); }
.pa-page .legend i.fair { background: var(--fair); }
.pa-page .legend i.poor { background: var(--poor); }
.pa-page .legend i.miss { background: var(--miss); }

.pa-page .words { display: flex; flex-wrap: wrap; gap: 8px 9px; }
.pa-page .word {
  position: relative; border: 0; cursor: pointer; font-family: inherit;
  padding: 7px 11px 9px; border-radius: 10px; background: var(--surface-2);
  font-size: 19px; font-weight: 700; letter-spacing: -.01em; color: var(--text);
  border-bottom: 3px solid var(--border-2); transition: .14s var(--ease);
}
.pa-page .word:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.pa-page .word .word__score {
  display: block; font-size: 11px; font-weight: 800; margin-top: 2px; letter-spacing: 0;
}
.pa-page .word.good { background: var(--good-bg); border-bottom-color: var(--good); color: #0a5c38; }
.pa-page .word.good .word__score { color: var(--good); }
.pa-page .word.fair { background: var(--fair-bg); border-bottom-color: var(--fair); color: #7a4708; }
.pa-page .word.fair .word__score { color: var(--fair); }
.pa-page .word.poor { background: var(--poor-bg); border-bottom-color: var(--poor); color: #a01436; }
.pa-page .word.poor .word__score { color: var(--poor); }
.pa-page .word.miss { background: var(--miss-bg); border-bottom-color: var(--miss); color: var(--text-3); text-decoration: line-through; }
.pa-page .word.miss .word__score { color: var(--miss); }
.pa-page .word.is-open { box-shadow: 0 0 0 2px var(--primary); }

/* phoneme drill-down */
.pa-page .phon-panel {
  margin-top: 14px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface-2); padding: 0; overflow: hidden; display: none;
}
.pa-page .phon-panel.is-on { display: block; }
.pa-page .phon-panel__head {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.pa-page .phon-panel__word { font-size: 17px; font-weight: 800; letter-spacing: -.01em; }
.pa-page .phon-panel__err {
  font-size: 11.5px; font-weight: 750; padding: 3px 9px; border-radius: 999px;
}
.pa-page .phon-panel__err.none { background: var(--good-bg); color: var(--good); }
.pa-page .phon-panel__err.bad { background: var(--poor-bg); color: var(--poor); }
.pa-page .phon-panel__close { margin-left: auto; background: none; border: 0; color: var(--text-3); cursor: pointer; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 7px; }
.pa-page .phon-panel__close:hover { background: var(--surface-3); color: var(--text); }
.pa-page .phon-panel__close svg { width: 16px; height: 16px; }
.pa-page .phon-row { display: flex; flex-wrap: wrap; gap: 9px; padding: 15px; }
.pa-page .phon {
  min-width: 52px; text-align: center; border: 1px solid var(--border);
  border-radius: 9px; background: var(--surface); padding: 9px 10px;
}
.pa-page .phon__ipa { font-size: 17px; font-weight: 700; }
.pa-page .phon__score { font-size: 12px; font-weight: 800; margin-top: 3px; }
.pa-page .phon.good { border-color: var(--good); } .pa-page .phon.good .phon__score { color: var(--good); }
.pa-page .phon.fair { border-color: var(--fair); } .pa-page .phon.fair .phon__score { color: var(--fair); }
.pa-page .phon.poor { border-color: var(--poor); background: var(--poor-bg); } .pa-page .phon.poor .phon__score { color: var(--poor); }
.pa-page .phon-note { padding: 0 15px 15px; font-size: 12.5px; color: var(--text-2); display: flex; gap: 7px; align-items: flex-start; }
.pa-page .phon-note svg { width: 14px; height: 14px; color: var(--fair); flex: none; margin-top: 1px; }

/* ---- recognized transcript ---- */
.pa-page .transcript { font-size: 16px; line-height: 1.8; color: var(--text); }
.pa-page .transcript .t-ok { }
.pa-page .transcript .t-ins {
  background: var(--fair-bg); color: var(--fair); border-radius: 6px; padding: 1px 7px;
  font-weight: 700; text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 3px;
}
.pa-page .transcript .t-miss {
  color: var(--miss); text-decoration: line-through; opacity: .8;
}
.pa-page .t-foot { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 10px; }
.pa-page .t-tag {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650;
  padding: 5px 11px; border-radius: 999px; background: var(--surface-3); color: var(--text-2);
}
.pa-page .t-tag svg { width: 13px; height: 13px; }
.pa-page .t-tag.ins { background: var(--fair-bg); color: var(--fair); }
.pa-page .t-tag.miss { background: var(--miss-bg); color: var(--text-3); }

/* card foot actions */
.pa-page .pa-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.pa-page .demo-note {
  display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--text-2);
  background: var(--sky-bg); border: 1px solid #bfe3ee; border-radius: var(--r);
  padding: 11px 14px; line-height: 1.45;
}
.pa-page .demo-note svg { width: 16px; height: 16px; color: var(--sky); flex: none; }
