/* Hero motion — versi ringkas.
   Satu loop 12s, tiga babak:
   1) Dokter mengetik SATU baris (Subjective) lalu BERHENTI di 24%. Setelah itu
      teksnya menetap — tidak ada ketikan menyambung, tidak ada teks yang mundur.
   2) Dikte AI (mikrofon menyala) mengisi Objective, Assessment, Plan sekaligus —
      MUNCUL, bukan diketik, supaya kontrasnya terbaca.
   3) Satu kode ICD-10 muncul; status "Pratinjau" -> "Tersimpan".
   62%-95% adalah jeda diam yang disengaja: hasil akhir dibiarkan terbaca utuh
   sebelum loop mengulang. Reset terjadi lewat pudar di 95-97%, dan lebar ketikan
   dikembalikan ke nol saat elemennya sudah tak terlihat.
   Atur durasi: --hm-dur di .hm. Waktu tiap babak: persentase di @keyframes. */
.hm { --hm-dur: 12s; container-type: inline-size; width: 100%; max-width: 38rem; margin-inline: auto; }
.hm-frame { position: relative; aspect-ratio: 1.28; font-size: clamp(13px, 4.1cqw, 20px); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; color: var(--text); }

.hm-body { flex: 1; min-height: 0; padding: 1.15em 1.3em 1.1em; display: flex; flex-direction: column; gap: .9em; }

/* identitas pasien + status, satu baris */
.hm-pt { flex: none; display: flex; align-items: center; gap: .65em; }
.hm-av { flex: none; width: 2.4em; height: 2.4em; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: .78em; }
.hm-pt > div { min-width: 0; line-height: 1.3; }
.hm-pt b { display: block; font-size: .9em; font-weight: 600; }
.hm-pt small { font-size: .74em; color: var(--text-2); }
.hm-tag { margin-left: auto; flex: none; font-size: .68em; font-weight: 600; color: #B45309; background: #FFFBEB; padding: .26em .8em; border-radius: 999px; white-space: nowrap; }

/* chip status: satu posisi, dua label bergantian */
.hm-chip { flex: none; display: grid; place-items: center; font-size: .68em; font-weight: 600; }
.hm-chip > span { grid-area: 1 / 1; white-space: nowrap; padding: .26em .8em; border-radius: 999px; }
.hm-chip .st-a { background: var(--primary-soft); color: var(--text-2); }
.hm-chip .st-b { background: #F0FDF4; color: #15803D; }

/* SOAP: empat baris seragam, tanpa kotak */
.hm-soap { flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; }
.hm-row { position: relative; display: grid; grid-template-columns: 2.3em 1fr; gap: .9em; align-items: center; padding: .28em .45em; border-radius: .7em; }
.hm-rl { position: absolute; inset: 0; border-radius: .7em; background: var(--primary-soft); opacity: 0; pointer-events: none; }
.hm-k { position: relative; z-index: 1; width: 2.3em; height: 2.3em; display: grid; place-items: center; font-size: .86em; font-weight: 800; color: var(--primary); background: var(--surface); border: 1px solid var(--border); border-radius: .6em; }
.hm-f { position: relative; z-index: 1; min-width: 0; }
.hm-f > small { display: block; font-size: .7em; font-weight: 600; color: var(--text-2); line-height: 1.35; }
.hm-txt { display: grid; font-size: 1em; font-weight: 600; margin-top: .1em; min-height: 1.35em; letter-spacing: -.005em; }
.hm-txt > * { grid-area: 1 / 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hm-txt .idle { color: #B6C2CF; font-weight: 500; }
.hm-tw { display: inline-block; white-space: nowrap; overflow: hidden; vertical-align: bottom; max-width: 0; border-right: 2px solid transparent; }

/* kode ICD-10, menempel pada baris Assessment */
.hm-ai { display: inline; margin-left: .45em; font-size: .78em; font-weight: 700; vertical-align: .06em; opacity: 0; }
.hm-ai b { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; color: var(--primary); background: var(--primary-soft); padding: .14em .55em; border-radius: 999px; }

/* kaki: mikrofon + label, tanpa tombol */
.hm-foot { flex: none; display: flex; align-items: center; gap: .55em; }
.hm-mic { position: relative; flex: none; width: 2.2em; height: 2.2em; border-radius: 50%; display: grid; place-items: center; animation: hm-mic var(--hm-dur) ease-in-out infinite; }
.hm-mic svg { width: 1.05em; height: 1.05em; }
.hm-mic::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--primary); opacity: 0; animation: hm-micpulse var(--hm-dur) cubic-bezier(.2, .8, .3, 1) infinite; }
.hm-wt { font-size: .82em; font-weight: 600; color: var(--text-2); }
.hm-wave { display: flex; align-items: center; gap: .2em; height: 1.5em; }
.hm-wave i { width: .17em; height: .45em; border-radius: 999px; background: var(--primary); opacity: 0; transform-origin: center; animation: hm-wave var(--hm-dur) linear infinite, hm-osc calc(var(--hm-dur) / 16) ease-in-out infinite var(--d, 0s); }

/* ---------- timeline (1% = 0.12s dari 12s) ---------- */

/* S: satu-satunya ketikan. Selesai 24%, menetap sampai 95%. */
.hm-s { animation: hm-type-s var(--hm-dur) steps(19, end) infinite; }
@keyframes hm-type-s {
  0%, 4% { max-width: 0; opacity: 1; border-right-color: transparent; }
  5% { border-right-color: var(--primary); }
  23.6% { border-right-color: var(--primary); }
  24%, 95% { max-width: 100%; opacity: 1; border-right-color: transparent; }
  97%, 100% { max-width: 100%; opacity: 0; border-right-color: transparent; }
}

/* O, A, P: muncul seketika saat dikte */
.hm-o { animation: hm-app-o var(--hm-dur) cubic-bezier(.2, .8, .3, 1) infinite; }
.hm-a { animation: hm-app-a var(--hm-dur) cubic-bezier(.2, .8, .3, 1) infinite; }
.hm-p { animation: hm-app-p var(--hm-dur) cubic-bezier(.2, .8, .3, 1) infinite; }
@keyframes hm-app-o { 0%, 37.5% { opacity: 0; transform: translateY(.28em); } 39.5%, 95% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; transform: none; } }
@keyframes hm-app-a { 0%, 44.5% { opacity: 0; transform: translateY(.28em); } 46.5%, 95% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; transform: none; } }
@keyframes hm-app-p { 0%, 51.5% { opacity: 0; transform: translateY(.28em); } 53.5%, 95% { opacity: 1; transform: none; } 97%, 100% { opacity: 0; transform: none; } }

/* placeholder "Belum diisi": hilang saat kolom diisi, kembali saat reset */
.hm-idle-s { animation: hm-idle-s var(--hm-dur) linear infinite; }
.hm-idle-o { animation: hm-idle-o var(--hm-dur) linear infinite; }
.hm-idle-a { animation: hm-idle-a var(--hm-dur) linear infinite; }
.hm-idle-p { animation: hm-idle-p var(--hm-dur) linear infinite; }
@keyframes hm-idle-s { 0%, 4% { opacity: 1; } 5.5%, 96% { opacity: 0; } 98.5%, 100% { opacity: 1; } }
@keyframes hm-idle-o { 0%, 37% { opacity: 1; } 38.5%, 96% { opacity: 0; } 98.5%, 100% { opacity: 1; } }
@keyframes hm-idle-a { 0%, 44% { opacity: 1; } 45.5%, 96% { opacity: 0; } 98.5%, 100% { opacity: 1; } }
@keyframes hm-idle-p { 0%, 51% { opacity: 1; } 52.5%, 96% { opacity: 0; } 98.5%, 100% { opacity: 1; } }

/* sorot baris yang sedang diisi */
.hm-rl-s { animation: hm-rl-s var(--hm-dur) linear infinite; }
.hm-rl-o { animation: hm-rl-o var(--hm-dur) linear infinite; }
.hm-rl-a { animation: hm-rl-a var(--hm-dur) linear infinite; }
.hm-rl-p { animation: hm-rl-p var(--hm-dur) linear infinite; }
@keyframes hm-rl-s { 0%, 4% { opacity: 0; } 5.5%, 22% { opacity: 1; } 25%, 100% { opacity: 0; } }
@keyframes hm-rl-o { 0%, 37.5% { opacity: 0; } 39%, 45% { opacity: 1; } 48%, 100% { opacity: 0; } }
@keyframes hm-rl-a { 0%, 44.5% { opacity: 0; } 46%, 52% { opacity: 1; } 55%, 100% { opacity: 0; } }
@keyframes hm-rl-p { 0%, 51.5% { opacity: 0; } 53%, 59% { opacity: 1; } 62%, 100% { opacity: 0; } }

/* kode ICD-10: muncul setelah Assessment terisi, bertahan sampai reset */
.hm-ai { animation: hm-ai var(--hm-dur) linear infinite; }
@keyframes hm-ai { 0%, 48% { opacity: 0; } 50%, 93% { opacity: 1; } 96%, 100% { opacity: 0; } }

/* mikrofon menyala hanya selama dikte */
@keyframes hm-mic {
  0%, 33% { background: var(--primary-soft); color: var(--primary); }
  35%, 58% { background: var(--primary); color: #fff; }
  60%, 100% { background: var(--primary-soft); color: var(--primary); }
}
@keyframes hm-micpulse {
  0%, 34.5% { opacity: 0; transform: scale(.85); }
  35.5% { opacity: .45; transform: scale(1); }
  38% { opacity: 0; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(.85); }
}
@keyframes hm-wave {
  0%, 34.5% { opacity: 0; }
  36%, 57% { opacity: 1; }
  59%, 100% { opacity: 0; }
}
@keyframes hm-osc {
  0%, 100% { transform: scaleY(.3); }
  50% { transform: scaleY(1); }
}

/* status: "Pratinjau" -> "Tersimpan" di 62% */
.hm-chip .st-a { animation: hm-st-a var(--hm-dur) linear infinite; }
.hm-chip .st-b { animation: hm-st-b var(--hm-dur) linear infinite; }
@keyframes hm-st-a { 0%, 60% { opacity: 1; } 62%, 95% { opacity: 0; } 97.5%, 100% { opacity: 1; } }
@keyframes hm-st-b { 0%, 60% { opacity: 0; } 62%, 95% { opacity: 1; } 97.5%, 100% { opacity: 0; } }

@media (max-width: 640px) {
  .hm-frame { aspect-ratio: 1.1; font-size: clamp(13px, 4.4cqw, 17px); }
  .hm-body { padding: 1em 1.05em .95em; }
  .hm-wave { display: none; }
  .hm-tag { display: none; }
}

/* versi statis: tampilkan hasil akhir, tanpa gerak */
@media (prefers-reduced-motion: reduce) {
  .hm *, .hm *::before, .hm *::after { animation: none !important; }
  .hm-tw { max-width: 100%; }
  .hm-txt .idle { opacity: 0; }
  .hm-o, .hm-a, .hm-p, .hm-ai { opacity: 1; }
  .hm-chip .st-b { opacity: 1; }
  .hm-chip .st-a { opacity: 0; }
  .hm-wave, .hm-mic::after { opacity: 0 !important; }
  .hm-mic { background: var(--primary-soft); color: var(--primary); }
}