/* How to screen record on Mac: Shift-Command-5 walkthrough animation.
   State lives in data-s on the figure (0 keys, 1 toolbar, 2 recording, 3 thumbnail, 4 saved file).
   Without JS (or with reduced motion) the figure stays on state 4, the final picture. */
.ha { margin: 24px 0 8px; }
.ha-card { position: relative; background: var(--card); border-radius: 30px; padding: 18px 18px 14px; box-shadow: 0 6px 0 rgba(11,36,64,.08), 0 26px 60px rgba(11,36,64,.11); display: grid; gap: 14px; }
.ha-stage { position: relative; }
.ha-screen { position: relative; width: min(100%, 480px); margin: 0 auto; aspect-ratio: 16 / 10; border: 3px solid var(--navy); border-radius: 14px; background: #DCEBFA; overflow: hidden; box-shadow: 0 5px 0 var(--navy); }
.ha-pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: left top; }

/* Menu bar: generic shapes, no logos */
.ha-menubar { position: absolute; left: 0; right: 0; top: 0; height: 18px; display: flex; align-items: center; justify-content: space-between; padding: 0 8px; background: rgba(255,255,255,.82); border-bottom: 1px solid rgba(11,36,64,.18); z-index: 3; }
.ha-mb-l, .ha-mb-r { display: flex; align-items: center; gap: 6px; }
.ha-mb-l i, .ha-mb-r i { display: block; height: 5px; border-radius: 3px; background: rgba(11,36,64,.5); }
.ha-mb-l i:nth-child(1) { width: 26px; background: rgba(11,36,64,.8); }
.ha-mb-l i:nth-child(2) { width: 18px; }
.ha-mb-l i:nth-child(3) { width: 22px; }
.ha-mb-r i { width: 9px; height: 7px; border-radius: 2px; }
.ha-mb-r i.ha-clock { width: 24px; height: 5px; border-radius: 3px; }
.ha-stop { display: flex; align-items: center; gap: 5px; height: 14px; padding: 0 6px 0 3px; border-radius: 8px; background: var(--navy); color: #fff; font: 700 10px/1 ui-monospace, "SF Mono", Menlo, monospace; transition: transform .3s cubic-bezier(.3,1.5,.5,1), opacity .25s; transform-origin: right center; }
.ha-stop b { display: block; width: 8px; height: 8px; border-radius: 2px; background: var(--rec); box-shadow: 0 0 0 2px #fff; }
.ha-stop span { min-width: 22px; }
.ha-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 0 2px #fff; }

/* Keys */
.ha-keys { position: absolute; left: 50%; top: 50%; z-index: 5; display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px 14px; background: #fff; border: 3px solid var(--navy); border-radius: 20px; box-shadow: 0 5px 0 var(--navy), 0 14px 30px rgba(11,36,64,.25); transform: translate(-50%, -50%); transition: opacity .3s ease, transform .35s cubic-bezier(.3,1.4,.5,1); }
.ha-key { display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-width: 50px; height: 52px; padding: 6px 8px 5px; border: 3px solid var(--navy); border-radius: 11px; background: #fff; box-shadow: 0 4px 0 var(--navy); color: var(--navy); transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease; }
.ha-key em { font: 700 20px/1 var(--display); font-style: normal; }
.ha-key small { font: 700 9px/1 var(--display); text-transform: lowercase; letter-spacing: .02em; }
.ha-key-5 { justify-content: center; }
.ha-key-5 small { display: none; }
.ha-key-5 em { font-size: 24px; }
.ha-key.is-down { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); background: var(--sun); }

/* Capture toolbar */
.ha-bar { position: absolute; left: 50%; bottom: 9px; z-index: 4; display: flex; align-items: center; gap: 3px; padding: 5px 6px; background: rgba(255,255,255,.94); border: 2.5px solid var(--navy); border-radius: 13px; box-shadow: 0 3px 0 var(--navy); transform: translateX(-50%); transition: transform .4s cubic-bezier(.3,1.2,.5,1), opacity .3s ease; }
.ha-bar i { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: var(--navy); }
.ha-bar i.is-on { background: rgba(11,36,64,.12); }
.ha-bar svg { width: 15px; height: 15px; }
.ha-bar s { display: block; width: 1.5px; height: 16px; margin: 0 3px; background: rgba(11,36,64,.25); text-decoration: none; }
.ha-rec { margin-left: 3px; padding: 5px 11px; border-radius: 999px; background: var(--rec); border: 2px solid var(--navy); color: #fff; font: 800 12px/1 var(--display); transition: transform .15s ease; }
.ha-rec.is-press { transform: scale(.9); }

/* Selection rectangle */
.ha-sel { position: absolute; z-index: 2; left: 17%; right: 17%; top: 17%; bottom: 29%; border: 2.5px dashed #fff; outline: 1.5px solid rgba(11,36,64,.55); outline-offset: 0; border-radius: 3px; box-shadow: 0 0 0 600px rgba(11,36,64,.22); transition: opacity .3s ease, transform .4s cubic-bezier(.3,1.2,.5,1); transform-origin: center; }

/* Thumbnail (bottom-right) and the saved file (desktop, top-right) */
.ha-thumb { position: absolute; z-index: 4; right: 9px; bottom: 9px; width: 24%; aspect-ratio: 16 / 10; border: 2.5px solid #fff; border-radius: 8px; overflow: hidden; background: #DCEBFA; box-shadow: 0 0 0 2px var(--navy), 0 6px 14px rgba(11,36,64,.35); transition: transform .7s cubic-bezier(.5,0,.2,1), opacity .5s ease; }
.ha-thumb img { width: 100%; height: 100%; object-fit: cover; object-position: left top; display: block; }
.ha-file { position: absolute; z-index: 2; right: 10px; top: 26px; width: 84px; display: flex; flex-direction: column; align-items: center; gap: 3px; transition: opacity .4s ease, transform .5s cubic-bezier(.3,1.6,.5,1); }
.ha-fileico { position: relative; width: 30px; height: 38px; border: 2.5px solid var(--navy); border-radius: 5px; background: #fff; box-shadow: 0 3px 0 rgba(11,36,64,.4); }
.ha-fileico::before { content: ""; position: absolute; right: -2.5px; top: -2.5px; width: 10px; height: 10px; background: var(--bg); border-left: 2.5px solid var(--navy); border-bottom: 2.5px solid var(--navy); border-radius: 0 0 0 4px; }
.ha-fileico svg { position: absolute; left: 50%; top: 56%; width: 13px; height: 13px; color: var(--rec); transform: translate(-45%, -50%); }
.ha-filelabel { padding: 2px 5px; border-radius: 5px; background: var(--navy); color: #fff; font: 600 9.5px/1.2 var(--sans, system-ui), sans-serif; text-align: center; }

/* State -> what is visible. Default (no JS) = state 4. */
.ha-keys { opacity: 0; transform: translate(-50%, -50%) scale(.9); }
.ha-bar { opacity: 0; transform: translateX(-50%) translateY(160%); }
.ha-sel { opacity: 0; transform: scale(.94); }
.ha-stop, .ha-dot { opacity: 0; }
.ha-stop { transform: scale(.6); }
.ha-thumb { opacity: 0; transform: translateX(150%); }
.ha-file { opacity: 1; transform: none; }
.ha-thumb { transform: translate(var(--tx, 0px), var(--ty, 0px)) scale(.3); }

.ha[data-s="0"] .ha-keys { opacity: 1; transform: translate(-50%, -50%); }
.ha[data-s="1"] .ha-bar { opacity: 1; transform: translateX(-50%); }
.ha[data-s="1"] .ha-sel, .ha[data-s="2"] .ha-sel { opacity: 1; transform: none; }
.ha[data-s="2"] .ha-stop { opacity: 1; transform: none; }
.ha[data-s="2"] .ha-dot { opacity: 1; animation: ha-pulse 1s ease-in-out infinite; }
.ha[data-s="3"] .ha-thumb { opacity: 1; transform: none; }
.ha[data-s="0"] .ha-file, .ha[data-s="1"] .ha-file, .ha[data-s="2"] .ha-file, .ha[data-s="3"] .ha-file { opacity: 0; transform: scale(.7); }
/* Reset (state 0) and state 3 entry slide the thumbnail in from the right. */
.ha[data-s="0"] .ha-thumb, .ha[data-s="1"] .ha-thumb, .ha[data-s="2"] .ha-thumb { transform: translateX(150%); transition: none; }
@keyframes ha-pulse { 50% { opacity: .25; } }

/* Caption + controls */
.ha-foot { display: flex; align-items: center; gap: 12px; min-height: 40px; }
.ha-step { flex: none; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--sun); border: 3px solid var(--navy); box-shadow: 0 3px 0 var(--navy); font: 800 14px/1 var(--display); color: var(--navy); }
.ha-cap { flex: 1; min-width: 0; margin: 0; font-size: 15px; line-height: 1.35; color: var(--body); }
.ha-cap b { color: var(--navy); }
.ha-btn { flex: none; display: none; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; border: 2.5px solid var(--navy); background: #fff; color: var(--navy); font: 700 13px/1 var(--display); cursor: pointer; box-shadow: 0 3px 0 var(--navy); }
.ha-btn:active { translate: 0 2px; box-shadow: 0 1px 0 var(--navy); }
.ha-btn svg { width: 12px; height: 12px; }
.ha-steps { margin: 0; padding: 0 4px; list-style: none; display: grid; gap: 6px; font-size: 14.5px; color: var(--body); counter-reset: ha; }
.ha-steps li { display: flex; gap: 8px; }
.ha-steps li::before { counter-increment: ha; content: counter(ha); flex: none; width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--sun); border: 2px solid var(--navy); font: 800 12px/1 var(--display); color: var(--navy); }
.ha.is-js .ha-steps { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ha.is-js .ha-btn { display: inline-flex; }
.ha:not(.is-js) .ha-foot { display: none; }

@media (max-width: 560px) {
  .ha-card { padding: 14px 12px 12px; border-radius: 24px; }
  .ha-key { min-width: 42px; height: 46px; }
  .ha-key em { font-size: 17px; }
  .ha-keys { gap: 6px; padding: 10px 11px 12px; }
  .ha-bar i { width: 19px; height: 19px; }
  .ha-bar svg { width: 13px; height: 13px; }
  .ha-rec { padding: 4px 9px; font-size: 11px; }
  .ha-file { width: 70px; top: 24px; }
  .ha-filelabel { font-size: 8.5px; }
  .ha-cap { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ha .ha-dot { animation: none !important; }
  .ha * { transition: none !important; }
}
@media (min-width: 900px) {
  .ha { margin-left: calc(50% - min(440px, 50vw - 24px)); margin-right: calc(50% - min(440px, 50vw - 24px)); }
}
