/* ===== Avaliador Auditivo — Acústica+ (experiência premium) ===== */
.hearing-test-page {
  --ht-primary: var(--primary, #0d7c8c);
  --ht-primary-dark: #0a626f;
  --ht-ink: var(--text, #14302f);
  --ht-muted: var(--muted, #5b7270);
  --ht-line: var(--border, #dfe9e8);
  --ht-surface: var(--card, #ffffff);
  --ht-ok: #2d8f4e; --ht-warn: #e8a93b; --ht-risk: #d94b3b; --ht-urgent: #dc2626;
  --ht-radius: 18px;
  max-width: 640px; margin: 0 auto; padding-bottom: 96px;
}

/* Animations -------------------------------------------------------- */
@keyframes ht-fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes ht-pulse { to { transform: scale(1.16); opacity: .65; } }
@keyframes ht-spin { to { transform: rotate(360deg); } }
@keyframes ht-ag-draw { to { stroke-dashoffset: 0; } }
@keyframes ht-pop { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }

/* Cards & hero ------------------------------------------------------ */
.ht-card, .ht-hero {
  background: var(--ht-surface); border: 1px solid var(--ht-line); border-radius: var(--ht-radius);
  padding: 26px 22px; box-shadow: 0 6px 24px rgba(13,124,140,.07); margin-bottom: 16px;
  animation: ht-fade-in .32s ease;
}
.ht-hero { background: linear-gradient(135deg, rgba(13,124,140,.08), rgba(13,124,140,.02)); text-align: center; }
.ht-hero h2 { font-size: 25px; margin: 6px 0 8px; color: var(--ht-ink); }
.ht-hero-sub { font-size: 15px; color: var(--ht-muted); margin: 0; line-height: 1.6; }
.ht-card h2 { font-size: 21px; margin: 0 0 12px; color: var(--ht-ink); outline: none; }
.ht-card h3 { font-size: 17px; margin: 0 0 8px; color: var(--ht-ink); }
.ht-card p { font-size: 15px; color: var(--ht-muted); line-height: 1.65; margin: 0 0 12px; }

.ht-phase-label { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--ht-primary); font-weight: 700; margin: 0 0 8px; }

/* Progress ---------------------------------------------------------- */
.ht-progress-bar { height: 6px; background: var(--ht-line); border-radius: 99px; margin-bottom: 22px; overflow: hidden; }
.ht-progress-fill { height: 100%; background: linear-gradient(90deg, var(--ht-primary), #28a7b8); border-radius: 99px; transition: width .4s cubic-bezier(.4,0,.2,1); }

/* Buttons ----------------------------------------------------------- */
.ht-primary-btn, .ht-secondary-btn, .ht-ghost-btn {
  display: block; width: 100%; min-height: 52px; padding: 14px 22px; border: none; border-radius: 14px;
  font-size: 16px; font-family: inherit; font-weight: 600; cursor: pointer; margin-top: 10px;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, opacity .15s;
}
.ht-primary-btn { background: var(--ht-primary); color: #fff; box-shadow: 0 4px 14px rgba(13,124,140,.28); }
.ht-primary-btn:hover { background: var(--ht-primary-dark); }
.ht-primary-btn:active { transform: translateY(1px); }
.ht-primary-btn:disabled { opacity: .5; cursor: default; box-shadow: none; }
.ht-secondary-btn { background: transparent; color: var(--ht-ink); border: 1.5px solid var(--ht-line); }
.ht-secondary-btn:hover { border-color: var(--ht-primary); background: rgba(13,124,140,.04); }
.ht-ghost-btn { background: transparent; color: var(--ht-primary); border: none; text-decoration: underline; font-size: 14px; min-height: 44px; }

/* Tier selection ---------------------------------------------------- */
.ht-tier-grid { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.ht-tier-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  padding: 20px; border: 2px solid var(--ht-line); border-radius: var(--ht-radius);
  background: var(--ht-surface); cursor: pointer; font-family: inherit;
  transition: transform .14s ease, border-color .14s ease, box-shadow .18s ease;
}
.ht-tier-card:hover { border-color: var(--ht-primary); transform: translateY(-2px); box-shadow: 0 10px 28px rgba(13,124,140,.14); }
.ht-tier-icon { font-size: 30px; line-height: 1; flex-shrink: 0; width: 56px; height: 56px; display: grid; place-items: center; background: rgba(13,124,140,.08); border-radius: 14px; }
.ht-tier-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.ht-tier-body strong { font-size: 18px; color: var(--ht-ink); }
.ht-tier-min { font-size: 12px; color: var(--ht-primary); font-weight: 700; }
.ht-tier-body small { font-size: 13px; color: var(--ht-muted); line-height: 1.45; }
.ht-tier-tag { font-size: 11px; color: var(--ht-muted); margin-top: 4px; padding: 3px 8px; background: rgba(0,0,0,.04); border-radius: 6px; align-self: flex-start; }
.ht-tier-arrow { font-size: 22px; color: var(--ht-primary); flex-shrink: 0; }

/* Step header / back ----------------------------------------------- */
.ht-step-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.ht-back-btn { background: none; border: none; color: var(--ht-primary); font-size: 15px; font-family: inherit; cursor: pointer; padding: 8px 4px; min-height: 44px; }
.ht-back-btn:hover { text-decoration: underline; }
.ht-step-title { font-size: 13px; color: var(--ht-muted); text-transform: uppercase; letter-spacing: .06em; }

/* Path buttons ------------------------------------------------------ */
.ht-path-buttons { display: flex; flex-direction: column; gap: 12px; margin: 16px 0; }
.ht-path-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 18px 20px; border: 2px solid var(--ht-line); border-radius: 14px; background: var(--ht-surface); cursor: pointer; font-family: inherit; text-align: left; transition: border-color .14s, background .14s, transform .12s; }
.ht-path-btn:hover { border-color: var(--ht-primary); background: rgba(13,124,140,.04); transform: translateY(-1px); }
.ht-path-btn strong { font-size: 17px; color: var(--ht-ink); }
.ht-path-btn small { font-size: 13px; color: var(--ht-muted); line-height: 1.5; }
.ht-path-badge { font-size: 11px; padding: 3px 9px; border-radius: 6px; background: rgba(13,124,140,.12); color: var(--ht-primary); font-weight: 700; margin-top: 2px; }

/* Intro note, info banner, disclaimer, AI notice -------------------- */
.ht-intro-note { color: var(--ht-muted); font-size: 14px; margin: 8px 0; }
.ht-info-banner { padding: 13px 16px; border-radius: 12px; background: rgba(13,124,140,.07); font-size: 13.5px; color: var(--ht-ink); line-height: 1.55; margin: 12px 0; display: flex; gap: 10px; align-items: flex-start; }
.ht-info-banner svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; fill: var(--ht-primary); }
.ht-disclaimer { margin-top: 16px; padding: 14px 16px; background: rgba(232,169,59,.1); border-radius: 12px; border-left: 4px solid var(--ht-warn); }
.ht-disclaimer p { margin: 0; font-size: 12.5px; color: var(--ht-muted); line-height: 1.6; }
.ht-disclaimer strong { color: #9a6a0b; }
.ht-ai-notice { margin-top: 12px; padding: 11px 14px; background: rgba(13,124,140,.06); border-radius: 12px; font-size: 12.5px; color: var(--ht-muted); display: flex; gap: 9px; align-items: flex-start; }
.ht-ai-notice svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; fill: var(--ht-primary); }

/* Consent / questionnaire ------------------------------------------ */
.ht-consent { margin: 18px 0; border: 1px solid var(--ht-line); border-radius: 12px; overflow: hidden; }
.ht-consent-error { border-color: var(--ht-risk); box-shadow: 0 0 0 3px rgba(217,75,59,.12); }
.ht-consent-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-bottom: 1px solid var(--ht-line); cursor: pointer; }
.ht-consent-item:last-child { border-bottom: none; }
.ht-consent-item input { margin-top: 2px; flex-shrink: 0; width: 20px; height: 20px; accent-color: var(--ht-primary); }
.ht-consent-item span { font-size: 14px; color: var(--ht-ink); line-height: 1.5; }

.ht-question-num { font-size: 12px; color: var(--ht-muted); margin-bottom: 4px; }
.ht-question-text { font-size: 18px; color: var(--ht-ink); margin: 0 0 16px; line-height: 1.45; }
.ht-scale { display: flex; gap: 8px; flex-wrap: wrap; }
.ht-scale-btn { flex: 1; min-width: 62px; min-height: 64px; padding: 10px 6px; border: 2px solid var(--ht-line); border-radius: 12px; background: var(--ht-surface); cursor: pointer; font-family: inherit; color: var(--ht-ink); transition: border-color .14s, background .14s, transform .1s; text-align: center; }
.ht-scale-btn:hover { border-color: var(--ht-primary); transform: translateY(-1px); }
.ht-scale-btn.selected { border-color: var(--ht-primary); background: rgba(13,124,140,.12); }
.ht-scale-btn strong { display: block; font-size: 13px; }
.ht-scale-btn small { display: block; font-size: 10.5px; color: var(--ht-muted); margin-top: 3px; }

/* Alerts ------------------------------------------------------------ */
.ht-alert-box { padding: 20px; border-radius: 14px; margin: 8px 0 16px; }
.ht-alert-urgent { background: #fef2f2; border: 2px solid #fca5a5; }
.ht-alert-urgent h2 { color: var(--ht-urgent); } .ht-alert-urgent p { color: #991b1b; }
.ht-alert-icon { font-size: 34px; margin-bottom: 6px; }

/* Pre-check & meters ----------------------------------------------- */
.ht-check-screen, .ht-tone-screen, .ht-din-screen { text-align: center; }
.ht-volume-meter { width: 100%; max-width: 320px; height: 38px; margin: 16px auto; background: var(--ht-line); border-radius: 99px; overflow: hidden; position: relative; }
.ht-volume-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ht-ok), var(--ht-warn) 65%, var(--ht-risk)); transition: width .12s; }
.ht-volume-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ht-ink); }
.ht-headphone-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 14px 26px; border: 2px solid var(--ht-line); border-radius: 14px; background: var(--ht-surface); cursor: pointer; font-family: inherit; font-size: 16px; color: var(--ht-ink); transition: border-color .14s; }
.ht-headphone-btn:hover { border-color: var(--ht-primary); }
.ht-headphone-btn svg { width: 24px; height: 24px; fill: var(--ht-primary); }

/* Tone / calibration screens --------------------------------------- */
.ht-freq-label { font-size: 30px; font-weight: 800; color: var(--ht-primary); margin: 4px 0 4px; }
.ht-ear-label { font-size: 17px; color: var(--ht-ink); margin: 0 0 14px; }
.ht-tone-visual { width: 92px; height: 92px; margin: 0 auto 18px; border-radius: 50%; background: rgba(13,124,140,.08); display: grid; place-items: center; transition: background .2s; }
.ht-tone-visual span { width: 16px; height: 16px; border-radius: 50%; background: var(--ht-muted); transition: background .2s; }
.ht-tone-visual.playing { background: rgba(13,124,140,.18); }
.ht-tone-visual.playing span { background: var(--ht-primary); animation: ht-pulse .55s ease-in-out infinite alternate; }
.ht-tone-prompt, .ht-din-prompt { font-size: 17px; color: var(--ht-ink); margin: 0 0 16px; min-height: 24px; }
.ht-tone-buttons { display: flex; gap: 12px; justify-content: center; }
.ht-tone-yes, .ht-tone-no { flex: 1; max-width: 170px; min-height: 60px; padding: 16px; border: none; border-radius: 14px; font-size: 17px; font-weight: 700; font-family: inherit; cursor: pointer; color: #fff; transition: transform .1s, opacity .15s; }
.ht-tone-yes { background: var(--ht-ok); } .ht-tone-no { background: var(--ht-risk); }
.ht-tone-yes:active, .ht-tone-no:active { transform: translateY(1px); }
.ht-replay-btn { margin-top: 16px; background: none; border: none; color: var(--ht-muted); font-size: 14px; cursor: pointer; font-family: inherit; min-height: 44px; }
.ht-replay-btn:hover { color: var(--ht-primary); }

/* Digits-in-noise --------------------------------------------------- */
.ht-din-selected { display: flex; gap: 10px; justify-content: center; margin-bottom: 18px; min-height: 48px; flex-wrap: wrap; }
.ht-din-digit-chip { display: inline-grid; place-items: center; min-width: 44px; height: 48px; padding: 0 8px; border-radius: 12px; background: rgba(13,124,140,.12); color: var(--ht-primary); font-weight: 800; font-size: 20px; animation: ht-pop .25s ease; }
.ht-din-digit-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; max-width: 380px; margin: 0 auto 18px; }
.ht-din-digit-btn { aspect-ratio: 1; min-height: 56px; border: 2px solid var(--ht-line); border-radius: 14px; background: var(--ht-surface); font-size: 24px; font-weight: 700; cursor: pointer; font-family: inherit; color: var(--ht-ink); transition: border-color .12s, background .12s, transform .1s; }
.ht-din-digit-btn:hover { border-color: var(--ht-primary); }
.ht-din-digit-btn:active { transform: scale(.94); background: rgba(13,124,140,.1); }
.ht-din-actions { display: flex; gap: 12px; align-items: center; justify-content: center; }
.ht-din-actions .ht-secondary-btn, .ht-din-actions .ht-primary-btn { margin-top: 0; width: auto; padding: 12px 26px; }
.ht-voice-mode { margin: 16px 0; }
.ht-voice-btn { display: inline-flex; align-items: center; gap: 10px; min-height: 56px; padding: 14px 28px; border: 2px solid var(--ht-primary); border-radius: 99px; background: var(--ht-surface); cursor: pointer; font-family: inherit; font-size: 16px; color: var(--ht-primary); transition: background .15s; }
.ht-voice-btn.listening { background: var(--ht-primary); color: #fff; animation: ht-pulse 1s infinite alternate; }
.ht-voice-btn svg { width: 22px; height: 22px; fill: currentColor; }
.ht-voice-result { margin-top: 12px; padding: 12px 16px; border-radius: 12px; background: rgba(0,0,0,.03); font-size: 15px; color: var(--ht-ink); min-height: 20px; }

/* Results ----------------------------------------------------------- */
.ht-results { text-align: center; }
.ht-grade-badge { display: inline-block; padding: 6px 16px; border-radius: 99px; font-size: 13px; font-weight: 800; margin: 0 0 14px; }
.ht-grade-A { background: #dcfce7; color: #166534; } .ht-grade-B { background: #dbeafe; color: #1e40af; }
.ht-grade-C { background: #fef3c7; color: #92400e; } .ht-grade-D { background: #fce7f3; color: #9f1239; }
.ht-overall { text-align: left; padding: 16px 18px; border-radius: 14px; background: rgba(13,124,140,.06); margin: 8px 0 18px; }
.ht-overall strong { display: block; font-size: 15px; margin-bottom: 6px; }
.ht-overall p { margin: 0; font-size: 14.5px; color: var(--ht-ink); line-height: 1.6; }
.ht-overall.ht-status-urgent { background: #fef2f2; } .ht-overall.ht-status-risk { background: #fff5f4; }
.ht-results-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
@media (min-width: 480px) { .ht-results-grid { grid-template-columns: 1fr 1fr 1fr; } }
.ht-result-box { padding: 14px 10px; border-radius: 12px; background: rgba(0,0,0,.03); text-align: center; border: 1px solid transparent; }
.ht-result-box small { display: block; font-size: 11px; color: var(--ht-muted); margin-bottom: 5px; }
.ht-result-box strong { display: block; font-size: 15px; }
.ht-result-box .ht-result-sub { display: block; font-size: 10.5px; color: var(--ht-muted); margin-top: 3px; }
.ht-limitations { margin: 16px 0; padding: 14px 16px; background: rgba(0,0,0,.02); border-radius: 12px; text-align: left; }
.ht-limitations small { font-size: 12px; color: var(--ht-muted); display: block; margin-bottom: 6px; font-weight: 700; }
.ht-limitations ul { margin: 0; padding-left: 18px; }
.ht-limitations li { font-size: 12px; color: var(--ht-muted); line-height: 1.6; margin-bottom: 2px; }
.ht-results-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }

/* Audiogram --------------------------------------------------------- */
.ht-audiogram { margin: 18px auto; max-width: 420px; }
.ht-audiogram-svg { width: 100%; height: auto; background: var(--ht-surface); border: 1px solid var(--ht-line); border-radius: 12px; }
.ht-ag-grid { stroke: var(--ht-line); stroke-width: 1; }
.ht-ag-axis { font-size: 10px; fill: var(--ht-muted); }
.ht-ag-line { fill: none; stroke-width: 2.5; stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: ht-ag-draw 1.1s ease forwards; }
.ht-ag-mark { animation: ht-pop .4s ease backwards; }
.ht-ag-right { stroke: var(--ht-risk); } .ht-ag-right.ht-ag-o { fill: none; stroke: var(--ht-risk); stroke-width: 2.5; }
.ht-ag-left { stroke: var(--ht-primary); } .ht-ag-mark.ht-ag-left { stroke: var(--ht-primary); stroke-width: 2.5; }
.ht-ag-legend { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.ht-ag-leg { font-size: 12px; font-weight: 700; }
.ht-ag-leg.ht-ag-right { color: var(--ht-risk); } .ht-ag-leg.ht-ag-left { color: var(--ht-primary); }
.ht-ag-legend small { font-size: 10.5px; color: var(--ht-muted); width: 100%; text-align: center; }

/* Lead form --------------------------------------------------------- */
.ht-lead-form { text-align: left; }
.ht-lead-form .field-label { display: block; margin-bottom: 14px; }
.ht-lead-form .field-label span { display: block; font-size: 14px; margin-bottom: 5px; color: var(--ht-ink); }
.ht-lead-form .field-label em { color: var(--ht-risk); font-style: normal; }
.ht-lead-form .field-label input { width: 100%; min-height: 50px; padding: 12px 14px; border: 1.5px solid var(--ht-line); border-radius: 12px; font-size: 16px; font-family: inherit; outline: none; box-sizing: border-box; }
.ht-lead-form .field-label input:focus { border-color: var(--ht-primary); box-shadow: 0 0 0 3px rgba(13,124,140,.12); }
.ht-lead-success { text-align: center; padding: 24px 12px; }
.ht-lead-success strong { display: block; font-size: 19px; color: var(--ht-ok); margin-bottom: 8px; }
.ht-lead-success p { margin: 0 0 12px; font-size: 14px; color: var(--ht-muted); }

/* Guided voice panel ------------------------------------------------ */
.ht-guided-panel { position: fixed; bottom: 0; left: 0; right: 0; z-index: 9000; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--ht-surface); border-top: 1px solid var(--ht-line); box-shadow: 0 -2px 16px rgba(0,0,0,.1); }
@media (max-width: 900px) { .ht-guided-panel { bottom: var(--mobile-nav-h, 60px); } }
.ht-guided-info { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ht-guided-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--ht-ok); flex-shrink: 0; animation: ht-pulse 1.4s ease-in-out infinite alternate; }
#ht-guided-status { font-size: 13.5px; color: var(--ht-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ht-guided-end { white-space: nowrap; min-height: 44px; padding: 8px 18px; border: 1.5px solid var(--ht-line); border-radius: 99px; background: var(--ht-surface); color: var(--ht-ink); font-size: 13px; cursor: pointer; font-family: inherit; }
.ht-guided-end:hover { border-color: var(--ht-primary); }

/* Spinner ----------------------------------------------------------- */
.ht-spinner { width: 30px; height: 30px; border: 3px solid var(--ht-line); border-top-color: var(--ht-primary); border-radius: 50%; animation: ht-spin .7s linear infinite; margin: 0 auto 12px; }

/* Accessibility ----------------------------------------------------- */
.ht-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hearing-test-page button:focus-visible,
.hearing-test-page input:focus-visible,
.hearing-test-page .ht-tier-card:focus-visible,
.hearing-test-page .ht-path-btn:focus-visible,
.hearing-test-page .ht-consent-item:focus-within {
  outline: 3px solid var(--ht-primary); outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .hearing-test-page *, .ht-guided-panel * { animation: none !important; transition: none !important; }
  .ht-ag-line { stroke-dashoffset: 0; }
}
@media (prefers-contrast: more) {
  .hearing-test-page { --ht-muted: #2c3a39; --ht-line: #94a3a1; }
  .ht-card, .ht-hero, .ht-tier-card, .ht-path-btn { border-width: 2px; }
}
