/*
 * HH Hearing Test — Stylesheet
 *
 * Merged: Kiro's clean base + Antigravity's dark-mode + card fade-in animation.
 * All styles are scoped under .hh-test-wrap so nothing leaks to the rest of the site.
 */

/* ── CSS custom properties ─────────────────────────────────────────────── */
:root {
  --hh-primary:        #1565c0;
  --hh-primary-hover:  #0d47a1;
  --hh-primary-dark:   #90caf9;
  --hh-danger:         #b00020;
  --hh-warning:        #f57c00;
  --hh-success:        #2a7d4f;
  --hh-bg:             #ffffff;
  --hh-surface:        #f8f9fa;
  --hh-border:         #dee2e6;
  --hh-text:           #212121;
  --hh-text-muted:     #6c757d;
  --hh-radius:         8px;
  --hh-max-width:      720px;
  --hh-max-width-wide: 860px;
}

/* ── Page wrapper ──────────────────────────────────────────────────────── */
.hh-test-wrap {
  max-width: var(--hh-max-width-wide);
  margin: 0 auto;
  padding: 0 1rem 4rem;
  color: var(--hh-text);
  background: var(--hh-bg);
}

/* ── Progress bar (Antigravity) ────────────────────────────────────────── */
.hh-progress-bar {
  height: 4px;
  background: var(--hh-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 2rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.hh-progress-fill {
  height: 100%;
  background: var(--hh-primary);
  border-radius: 2px;
  transition: width 0.35s ease;
}

/* ── Card fade-in animation (Antigravity) ──────────────────────────────── */
@keyframes hhFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ──────────────────────────────────────────────────────────────── */
.hh-card {
  padding: 2rem 0;
  animation: hhFadeIn 0.35s ease-out;
}
.hh-card__inner {
  max-width: var(--hh-max-width);
}
.hh-card__inner--wide {
  max-width: var(--hh-max-width-wide);
}

/* ── Step indicator ────────────────────────────────────────────────────── */
.hh-progress-step {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--hh-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

/* ── Badge / alert ─────────────────────────────────────────────────────── */
.hh-badge {
  display: inline-block;
  background: var(--hh-surface);
  border: 1px solid var(--hh-border);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--hh-text-muted);
}
.hh-alert {
  display: inline-block;
  background: #fff3cd;
  border: 1px solid #ffc107;
  color: #664d03;
  border-radius: var(--hh-radius);
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

/* ── Typography ────────────────────────────────────────────────────────── */
:root {
  --hh-title-light: #1a73e8; /* original site primary color */
  --hh-title-dark: #8ab4f8; /* high‑contrast dark variant */
}

.hhtitle {
  color: var(--hh-title-light);
}

@media (prefers-color-scheme: dark) {
  .hhtitle {
    color: var(--hh-title-dark);
  }
}



/* Apply title colors to all headings in the test wrapper */
.hh-test-wrap h1, .hh-test-wrap h2 {
  color: var(--hh-title-light);
}
@media (prefers-color-scheme: dark) {
  .hh-test-wrap h1, .hh-test-wrap h2 {
    color: var(--hh-title-dark);
  }
}
.hh-lead    { font-size: 1.1rem; color: var(--hh-text-muted); margin: 0 0 1.5rem; }
.hh-sub     { color: var(--hh-text-muted); margin: 0 0 1.5rem; }
.hh-small   { font-size: 0.85rem; color: var(--hh-text-muted); }

/* ── Feature list (intro card) ─────────────────────────────────────────── */
.hh-features {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
}
.hh-features li {
  padding: 0.3rem 0;
  color: var(--hh-success);
  font-weight: 500;
}

/* ── Step icon ─────────────────────────────────────────────────────────── */
.hh-step-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

/* ── Ear badge ─────────────────────────────────────────────────────────── */
.hh-ear-badge {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}
.hh-ear-badge--left  { background: #e3f2fd; color: #0d47a1; }
.hh-ear-badge--right { background: #fce4ec; color: #880e4f; }

@media (prefers-color-scheme: dark) {
  .hh-ear-badge--left  { background: #0d2a4a; color: #90caf9; }
  .hh-ear-badge--right { background: #3e0a1a; color: #f48fb1; }
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.hh-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: var(--hh-radius);
  border: 2px solid transparent;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
  line-height: 1.4;
}
.hh-btn:disabled,
.hh-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}
.hh-btn--primary {
  background: var(--hh-primary);
  color: #fff;
}
.hh-btn--primary:hover:not(:disabled) { background: var(--hh-primary-hover); }
.hh-btn--outline {
  background: transparent;
  border-color: var(--hh-primary);
  color: var(--hh-primary);
}
.hh-btn--outline:hover:not(:disabled) { background: var(--hh-surface); }
.hh-btn--ghost {
  background: transparent;
  color: var(--hh-text-muted);
}
.hh-btn--ghost:hover:not(:disabled) { color: var(--hh-text); }
.hh-btn--large { padding: 0.9rem 2rem; font-size: 1.05rem; }
.hh-btn--small { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

/* ── Navigation row ────────────────────────────────────────────────────── */
.hh-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

/* ── Accordion / details ───────────────────────────────────────────────── */
.hh-accordion,
.hh-detail {
  border: 1px solid var(--hh-border);
  border-radius: var(--hh-radius);
  margin-top: 1.5rem;
  padding: 0.5rem 1rem;
}
.hh-accordion summary,
.hh-detail summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
  padding: 0.35rem 0;
}
.hh-accordion__body,
.hh-detail p {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--hh-text-muted);
  line-height: 1.6;
}

/* ── Red flag form ─────────────────────────────────────────────────────── */
.hh-q-fieldset {
  border: none;
  padding: 0;
  margin: 0 0 1rem;
}
.hh-q-fieldset legend {
  font-weight: 500;
  margin-bottom: 0.4rem;
}
.hh-radio-group {
  display: flex;
  gap: 1.5rem;
}
.hh-radio {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

/* ── Gate checkbox ─────────────────────────────────────────────────────── */
.hh-check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 1.25rem 0;
  cursor: pointer;
  line-height: 1.5;
}
.hh-check-label input[type="checkbox"] { margin-top: 0.15rem; flex-shrink: 0; }

/* ── Calibration button ────────────────────────────────────────────────── */
.hh-audio-btn { 
  margin: 1rem 0; 
}
/* Inactive State: Play Reference Tone */
.hh-audio-btn[aria-pressed="false"],
.hh-audio-btn:not([aria-pressed]) {
  background: transparent !important;
  border: 2px solid var(--hh-primary) !important;
  color: var(--hh-primary) !important;
}
.hh-audio-btn[aria-pressed="false"]:hover,
.hh-audio-btn:not([aria-pressed]):hover {
  background: var(--hh-surface) !important;
  color: var(--hh-primary) !important;
}
/* Active State: Stop Tone */
.hh-audio-btn[aria-pressed="true"] {
  background: var(--hh-danger) !important;
  border: 2px solid var(--hh-danger) !important;
  color: #ffffff !important;
}
.hh-audio-btn[aria-pressed="true"]:hover {
  background: var(--hh-danger) !important;
  color: #ffffff !important;
  opacity: 0.9;
}

/* ── Lead form ─────────────────────────────────────────────────────────── */
.hh-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 480px) {
  .hh-form-row { grid-template-columns: 1fr; }
}
.hh-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.hh-form-group label {
  font-weight: 600;
  font-size: 0.9rem;
}
.hh-form-group input[type="text"],
.hh-form-group input[type="email"] {
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--hh-border);
  border-radius: var(--hh-radius);
  font-size: 0.95rem;
  background: var(--hh-bg);
  color: var(--hh-text);
}
.hh-form-group input:focus {
  outline: 2px solid var(--hh-primary);
  outline-offset: 1px;
}
.hh-consent { margin-top: 0.75rem; }
.hh-form-error {
  color: var(--hh-danger);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ── Disclaimer ────────────────────────────────────────────────────────── */
.hh-disclaimer {
  font-size: 0.8rem;
  color: var(--hh-text-muted);
  border-left: 3px solid var(--hh-border);
  padding-left: 0.75rem;
  margin: 1.5rem 0;
  line-height: 1.5;
}
.hh-disclaimer-small {
  font-size: 0.78rem;
  color: var(--hh-text-muted);
  margin: 0.5rem 0 1rem;
  line-height: 1.4;
}

/* ── Tone grid ─────────────────────────────────────────────────────────── */
.hh-tone-grid { margin: 1rem 0; }
.hh-tone-row {
  display: grid;
  grid-template-columns: 72px auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--hh-border);
}
.hh-tone-row__label { font-variant-numeric: tabular-nums; font-size: 0.9rem; font-weight: 500; }
.hh-tone-row__value { font-variant-numeric: tabular-nums; font-size: 0.85rem; text-align: right; min-width: 50px; }
.hh-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.hh-slider-label-lo,
.hh-slider-label-hi {
  font-size: 0.72rem;
  color: var(--hh-text-muted);
  white-space: nowrap;
}
.hh-tone-slider { flex: 1; cursor: pointer; accent-color: var(--hh-primary); }

@media (max-width: 540px) {
  .hh-tone-row {
    grid-template-columns: 60px auto 1fr;
    grid-template-rows: auto auto;
  }
  .hh-tone-row__value { display: none; }
  .hh-slider-wrap { grid-column: 1 / -1; }
}

/* ── Audiogram ─────────────────────────────────────────────────────────── */
.hh-audiogram-wrap {
  margin: 2rem 0;
  border: 2px solid var(--hh-border);
  border-radius: var(--hh-radius);
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  padding: 1rem;
}

#hh-audiogram {
  display: block;
  width: 100%;
  height: auto;
  filter: contrast(1.2);
}

/* Larger axis labels for readability */
.hh-audiogram-axis-label {
  font-size: 1.2rem;
  font-weight: 600;
  fill: var(--hh-text);
}

/* Thicker grid lines */
.hh-audiogram-grid line {
  stroke-width: 2px;
  stroke: var(--hh-border);
}


/* ── Frequency explainers ──────────────────────────────────────────────── */
.hh-freq-explainers { margin: 1rem 0; }
.hh-freq-explainers .hh-detail + .hh-detail { margin-top: 0.5rem; }

/* ── Result summary ────────────────────────────────────────────────────── */
.hh-result-summary { margin: 0.5rem 0 1.5rem; }
.hh-summary-row {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 1rem;
}
.hh-sev-badge {
  display: inline-block;
  color: #fff;
  border-radius: 4px;
  padding: 0.2rem 0.6rem;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: capitalize;
}

/* ── Loading spinner ───────────────────────────────────────────────────── */
.hh-loading {
  color: var(--hh-text-muted);
  padding: 1rem 0;
  font-style: italic;
}

/* ── Recommendations: next steps ───────────────────────────────────────── */
.hh-steps-list { margin: 0.5rem 0 2rem; }
.hh-step-item {
  border: 1px solid var(--hh-border);
  border-radius: var(--hh-radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: var(--hh-surface);
}
.hh-step-item h3 { margin: 0 0 0.35rem; font-size: 1rem; }
.hh-step-item p  { margin: 0 0 0.75rem; font-size: 0.9rem; color: var(--hh-text-muted); }
.hh-rec-label { font-size: 1.05rem; margin-bottom: 1rem; }

/* ── Recommendations: product grid ────────────────────────────────────── */
.hh-products { margin: 1.5rem 0; }
.hh-products__heading { margin-bottom: 1rem; }
.hh-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.hh-product-card {
  border: 1px solid var(--hh-border);
  border-radius: var(--hh-radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: var(--hh-surface);
  position: relative;
}
.hh-product-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--hh-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
}
.hh-product-name  { font-weight: 600; font-size: 0.9rem; line-height: 1.3; }
.hh-product-price { font-size: 0.85rem; color: var(--hh-text-muted); }

/* ── Contact tile ──────────────────────────────────────────────────────── */
.hh-contact-tile {
  background: var(--hh-surface);
  border: 1px solid var(--hh-border);
  border-radius: var(--hh-radius);
  padding: 1rem 1.25rem;
  margin: 2rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.hh-contact-tile p { margin: 0; font-weight: 500; }
