/* ============================================================================
 * Pia Hero Animation — Component CSS
 *
 * A drop-in hero illustration that cycles through three Pia mechanics:
 *   1. Voice input → laptop ("Created on your device")
 *   2. Conversations → laptop ("Stored on your device")
 *   3. Laptop → encrypted cloud sync ("End-to-end encrypted")
 *
 * Everything is scoped under .pia-hero-anim, so this CSS will not leak
 * into the rest of your site. Keyframes are prefixed `pha-`.
 *
 * Required at runtime:
 *   - pia-hero-animation.js (vanilla, no dependencies)
 *   - 'Outfit' (UI/captions) and 'Instrument Serif' (italic tagline) web fonts
 *     loaded somewhere on the page. The component will fall back to system
 *     fonts if they are missing, but the editorial feel depends on them.
 *
 * Sizing:
 *   The component is responsive — fills its container width, 1:1 aspect ratio,
 *   capped at max-width: 420px. Drop it where you already render the hero
 *   persona and it will size to that slot.
 * ========================================================================== */

.pia-hero-anim {
  /* Brand tokens — override these on .pia-hero-anim to retint */
  --pha-paper:       #FAFAF7;
  --pha-ink:         #1C1917;
  --pha-ink-soft:    #44403C;
  --pha-ink-mute:    #78716C;
  --pha-rule:        #E7E5E4;
  --pha-rule-soft:   #F0EFEB;
  --pha-accent:      #0078D4;
  --pha-accent-soft: rgba(0, 120, 212, .08);
  --pha-accent-mid:  rgba(0, 120, 212, .18);

  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.pia-hero-anim .pha-glow {
  position: absolute; inset: -20%;
  background: radial-gradient(circle, rgba(0, 120, 212, .10) 0%, transparent 60%);
  filter: blur(40px);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
 * Swap layers — persona ↔ mechanic crossfade
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-swap {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .8s cubic-bezier(.16, 1, .3, 1),
              transform .8s cubic-bezier(.16, 1, .3, 1);
  pointer-events: none;
}
.pia-hero-anim .pha-swap.is-active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
 * Persona
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-persona-img {
  width: 86%; max-width: 360px;
  display: block;
  animation: pha-hero-float 6s ease-in-out infinite;
  filter: drop-shadow(0 30px 60px rgba(28, 25, 23, .12));
}
.pia-hero-anim .pha-persona-fallback {
  width: 86%; max-width: 360px; aspect-ratio: 1 / 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 28%, #FFFFFF 0%, transparent 32%),
    radial-gradient(circle at 50% 60%, rgba(0, 120, 212, .28) 0%, transparent 60%),
    conic-gradient(from 215deg at 50% 50%, #DDE9F4, #F2F0EA, #DCE6EF, #E9E2D5, #DDE9F4);
  box-shadow: inset 0 -40px 60px rgba(0, 120, 212, .18),
              0 30px 60px rgba(28, 25, 23, .10);
  animation: pha-hero-float 6s ease-in-out infinite;
}
@keyframes pha-hero-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
@media (prefers-reduced-motion: reduce) {
  .pia-hero-anim .pha-persona-img,
  .pia-hero-anim .pha-persona-fallback,
  .pia-hero-anim .pha-cloud-stage { animation: none; }
}

/* --------------------------------------------------------------------------
 * Mechanic stage
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-mech {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px;
  font-family: 'Outfit', ui-sans-serif, system-ui, -apple-system, sans-serif;
}

.pia-hero-anim .pha-eyebrow {
  font-size: 9.5px; letter-spacing: .26em; text-transform: uppercase;
  color: var(--pha-ink-mute); font-weight: 500;
  opacity: 0; transform: translateY(6px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .is-running .pha-eyebrow { opacity: 1; transform: translateY(0); }
.pia-hero-anim .is-running .pha-eyebrow.is-top { transition-delay: .15s; }
/* Bottom eyebrow lands with the laptop, not earlier */
.pia-hero-anim .is-running .pha-eyebrow.is-bottom { opacity: 0; transform: translateY(6px); }
.pia-hero-anim .is-computer-in .pha-eyebrow.is-bottom { opacity: 1; transform: translateY(0); transition-delay: .15s; }

/* --------------------------------------------------------------------------
 * Source slot — holds mic / chat bubbles / cloud, they crossfade
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-source-slot {
  position: relative;
  width: 130px;
  height: 130px;
}
.pia-hero-anim .pha-source-mic,
.pia-hero-anim .pha-source-chat,
.pia-hero-anim .pha-source-cloud {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  transition: opacity .55s ease;
}
.pia-hero-anim .pha-source-mic   { opacity: 1; }
.pia-hero-anim .pha-source-chat  { opacity: 0; padding: 6px 4px; gap: 5px; }
.pia-hero-anim .pha-source-cloud { opacity: 0; }

.pia-hero-anim .pha-mech.is-mode-2 .pha-source-mic   { opacity: 0; }
.pia-hero-anim .pha-mech.is-mode-2 .pha-source-chat  { opacity: 1; }

.pia-hero-anim .pha-mech.is-mode-3 .pha-source-mic   { opacity: 0; }
.pia-hero-anim .pha-mech.is-mode-3 .pha-source-chat  { opacity: 0; }
.pia-hero-anim .pha-mech.is-mode-3 .pha-source-cloud { opacity: 1; }

/* --------------------------------------------------------------------------
 * Mic puck + recording pings
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-mic-puck {
  position: relative;
  width: 96px; height: 96px;
  display: grid; place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #FFFFFF 0%, transparent 55%),
    linear-gradient(180deg, #F7F5EF 0%, #ECEAE3 100%);
  border: 1px solid var(--pha-rule);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 -1px 0 rgba(0, 0, 0, .04) inset,
    0 14px 28px -12px rgba(28, 25, 23, .18),
    0 3px 10px -4px rgba(28, 25, 23, .06);
  opacity: 0; transform: scale(.85);
  transition: opacity .6s cubic-bezier(.16, 1, .3, 1),
              transform .8s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .is-running .pha-mic-puck {
  opacity: 1; transform: scale(1); transition-delay: .2s;
}
.pia-hero-anim .pha-mic-puck::before,
.pia-hero-anim .pha-mic-puck::after {
  content: ''; position: absolute; inset: -3px;
  border-radius: 50%;
  border: 1.5px solid var(--pha-accent);
  opacity: 0;
}
.pia-hero-anim .is-recording .pha-mic-puck::before {
  animation: pha-mic-ping 2.4s cubic-bezier(.16, 1, .3, 1) infinite;
}
.pia-hero-anim .is-recording .pha-mic-puck::after {
  animation: pha-mic-ping 2.4s cubic-bezier(.16, 1, .3, 1) infinite 1.2s;
}
@keyframes pha-mic-ping {
  0%   { transform: scale(.98); opacity: .55; }
  70%  { transform: scale(1.28); opacity: 0; }
  100% { transform: scale(1.32); opacity: 0; }
}

/* --------------------------------------------------------------------------
 * Equalizer bars
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-eq {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 4px;
  height: 28px; width: 110px;
  opacity: 0;
  transition: opacity .5s ease;
}
.pia-hero-anim .is-running .pha-eq { opacity: 1; transition-delay: .5s; }
.pia-hero-anim .pha-eq .pha-bar {
  width: 3.5px; border-radius: 2px;
  background: linear-gradient(180deg, var(--pha-accent) 0%, rgba(0, 120, 212, .35) 100%);
  height: 6px;
  transform-origin: bottom center;
}
.pia-hero-anim .is-recording .pha-eq .pha-bar {
  animation: pha-eq-pulse var(--pha-eq-dur, 1s) ease-in-out infinite;
  animation-delay: var(--pha-eq-delay, 0s);
}
@keyframes pha-eq-pulse {
  0%, 100% { height: 6px; }
  50%      { height: 26px; }
}
.pia-hero-anim .pha-mech.is-mode-2 .pha-source-mic .pha-eq .pha-bar { animation: none; }

/* --------------------------------------------------------------------------
 * Chat bubbles
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-bubble {
  border-radius: 9px;
  height: 16px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .5s ease, transform .55s cubic-bezier(.16, 1, .3, 1);
  position: relative;
}
.pia-hero-anim .pha-bubble.is-user {
  align-self: flex-end;
  width: 56px;
  background: linear-gradient(180deg, #292524 0%, #1C1917 100%);
  border-radius: 10px 10px 3px 10px;
}
.pia-hero-anim .pha-bubble.is-assistant {
  align-self: flex-start;
  width: 84px; height: 20px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F5EF 100%);
  border: 1px solid var(--pha-rule);
  border-radius: 10px 10px 10px 3px;
}
.pia-hero-anim .pha-bubble.is-assistant::before {
  content: ''; position: absolute;
  left: 6px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--pha-accent);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, .15);
}
.pia-hero-anim .pha-bubble.is-user.is-small { width: 38px; height: 14px; }

.pia-hero-anim .pha-mech.is-mode-2 .pha-bubble { opacity: 1; transform: translateY(0); }
.pia-hero-anim .pha-mech.is-mode-2 .pha-bubble.pha-b1 { transition-delay: .05s; }
.pia-hero-anim .pha-mech.is-mode-2 .pha-bubble.pha-b2 { transition-delay: .25s; }
.pia-hero-anim .pha-mech.is-mode-2 .pha-bubble.pha-b3 { transition-delay: .45s; }

/* --------------------------------------------------------------------------
 * Cloud + vault card + lock badges (mode 3)
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-cloud-stage {
  display: flex; flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: pha-cloud-bob 5s ease-in-out infinite;
}
@keyframes pha-cloud-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.pia-hero-anim .pha-cloud-glyph {
  width: 30px; height: 20px;
  color: var(--pha-ink-mute);
  opacity: .6;
}

.pia-hero-anim .pha-vault-card {
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F5EF 100%);
  border: 1px solid var(--pha-rule);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 14px 28px -14px rgba(28, 25, 23, .18),
    0 4px 10px -4px rgba(28, 25, 23, .06);
}

.pia-hero-anim .pha-lock-badge {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: rgba(0, 120, 212, .06);
  border: 1px solid rgba(0, 120, 212, .45);
  color: var(--pha-accent);
  display: grid; place-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0, 120, 212, .10);
  opacity: 0; transform: scale(.55);
  transition: opacity .45s ease, transform .55s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .pha-lock-badge svg { width: 10px; height: 10px; }
.pia-hero-anim .pha-mech.is-mode-3.is-cloud-receive .pha-lock-badge { opacity: 1; transform: scale(1); }
.pia-hero-anim .pha-mech.is-mode-3.is-cloud-receive .pha-lock-badge.pha-lb1 { transition-delay: 0s; }
.pia-hero-anim .pha-mech.is-mode-3.is-cloud-receive .pha-lock-badge.pha-lb2 { transition-delay: .12s; }
.pia-hero-anim .pha-mech.is-mode-3.is-cloud-receive .pha-lock-badge.pha-lb3 { transition-delay: .24s; }
.pia-hero-anim .pha-mech.is-mode-3.is-cloud-receive .pha-lock-badge.pha-lb4 { transition-delay: .36s; }

/* --------------------------------------------------------------------------
 * Channel — connector between source and laptop
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-channel {
  position: relative;
  width: 60px; height: 70px;
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .6s ease;
}
.pia-hero-anim .is-running .pha-channel { opacity: 1; transition-delay: .75s; }
.pia-hero-anim .pha-channel svg { width: 100%; height: 100%; overflow: visible; }
.pia-hero-anim .pha-channel .pha-track {
  stroke: var(--pha-rule); stroke-width: 1.5; fill: none;
  stroke-dasharray: 3 5;
}
.pia-hero-anim .pha-channel .pha-pulse {
  stroke: var(--pha-accent); stroke-width: 2; fill: none;
  stroke-linecap: round;
  stroke-dasharray: 22 200;
  stroke-dashoffset: 200;
  opacity: 0;
}
.pia-hero-anim .is-flowing .pha-channel .pha-pulse {
  opacity: 1;
  animation: pha-pulse-flow 1.5s cubic-bezier(.5, .1, .5, .9) infinite;
}
@keyframes pha-pulse-flow {
  0%   { stroke-dashoffset: 200; opacity: 0; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { stroke-dashoffset: 0;   opacity: 0; }
}
/* Reverse direction in mode 3 (laptop → cloud) */
.pia-hero-anim .pha-mech.is-mode-3 .pha-channel .pha-pulse { animation-direction: reverse; }

/* --------------------------------------------------------------------------
 * Laptop card
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-pc-card {
  position: relative;
  width: 150px; padding: 12px 12px 10px;
  border-radius: 14px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F5EF 100%);
  border: 1px solid var(--pha-rule);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 18px 36px -16px rgba(28, 25, 23, .20),
    0 5px 12px -6px rgba(28, 25, 23, .10);
  opacity: 0; transform: scale(.88) translateY(6px);
  transition: opacity .8s cubic-bezier(.16, 1, .3, 1),
              transform .9s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .is-computer-in .pha-pc-card { opacity: 1; transform: scale(1) translateY(0); }

.pia-hero-anim .pha-pc-card::before {
  content: ''; position: absolute; inset: -6px;
  border-radius: 18px;
  border: 1.5px solid var(--pha-accent);
  opacity: 0;
}
.pia-hero-anim .is-computer-pulse .pha-pc-card::before {
  animation: pha-pc-receive 1.6s cubic-bezier(.16, 1, .3, 1) 2;
}
@keyframes pha-pc-receive {
  0%   { transform: scale(.96); opacity: .6; }
  100% { transform: scale(1.1);  opacity: 0; }
}

.pia-hero-anim .pha-pc-screen {
  aspect-ratio: 16 / 10;
  border-radius: 7px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(0, 120, 212, .12) 0%, transparent 60%),
    linear-gradient(180deg, #1C1917 0%, #292524 100%);
  position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.pia-hero-anim .pha-pc-screen::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(96, 205, 255, .18) 50%, transparent 70%);
  transform: translateX(-100%);
}
.pia-hero-anim .is-computer-pulse .pha-pc-screen::after {
  animation: pha-screen-sweep 1.8s ease-in-out 1.5;
}
@keyframes pha-screen-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Inner content of the screen — waveform vs lock */
.pia-hero-anim .pha-pc-screen > .pha-pc-waveform,
.pia-hero-anim .pha-pc-screen > .pha-pc-lock {
  position: absolute; inset: 0;
  height: auto;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .45s ease;
}
.pia-hero-anim .pha-pc-waveform { gap: 2.5px; }
.pia-hero-anim .pha-pc-waveform span {
  display: block; width: 2.5px; border-radius: 2px;
  background: rgba(96, 205, 255, .85);
  height: 3px;
}
.pia-hero-anim .is-computer-pulse .pha-pc-waveform span {
  animation: pha-eq-pulse-sm 1.4s ease-in-out infinite;
}
@keyframes pha-eq-pulse-sm {
  0%, 100% { height: 3px; }
  50%      { height: 13px; }
}
.pia-hero-anim .pha-pc-lock { opacity: 0; }
.pia-hero-anim .pha-pc-lock svg {
  width: 22px; height: 22px;
  color: rgba(96, 205, 255, .95);
}
.pia-hero-anim .pha-mech.is-mode-3 .pha-pc-waveform { opacity: 0; }
.pia-hero-anim .pha-mech.is-mode-3 .pha-pc-lock     { opacity: 1; }

.pia-hero-anim .pha-pc-stand {
  margin: 6px auto 0; width: 60%; height: 3px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, #E7E5E4 0%, #D6D3D1 100%);
}
.pia-hero-anim .pha-pc-foot {
  margin: 3px auto 0; width: 22%; height: 5px;
  border-radius: 50%;
  background: rgba(28, 25, 23, .10);
  filter: blur(.5px);
}

/* "local" pill anchored to the laptop */
.pia-hero-anim .pha-local-pill {
  position: absolute;
  left: 50%; bottom: -12px;
  transform: translate(-50%, 6px);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--pha-paper);
  border: 1px solid var(--pha-accent-mid);
  color: var(--pha-accent);
  font-size: 10.5px; font-weight: 600; letter-spacing: .14em;
  text-transform: uppercase;
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  box-shadow: 0 6px 14px -6px rgba(0, 120, 212, .25);
  opacity: 0;
  transition: opacity .6s ease, transform .7s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .is-local-in .pha-local-pill {
  opacity: 1; transform: translate(-50%, 0);
}
.pia-hero-anim .pha-local-pill svg { width: 11px; height: 11px; }

/* --------------------------------------------------------------------------
 * Tagline (Instrument Serif, sits below the whole composition)
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-tagline {
  position: absolute;
  left: 0; right: 0;
  bottom: -40px;
  text-align: center;
  font-family: 'Instrument Serif', 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.3;
  color: var(--pha-ink-soft);
  letter-spacing: -0.01em;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .8s ease, transform .8s cubic-bezier(.16, 1, .3, 1);
}
.pia-hero-anim .pha-tagline em {
  font-style: italic;
  color: var(--pha-accent);
}
.pia-hero-anim .is-local-in .pha-tagline {
  opacity: 1; transform: translateY(0); transition-delay: .2s;
}

/* --------------------------------------------------------------------------
 * Replay button (hover-only, top-right)
 * ------------------------------------------------------------------------ */
.pia-hero-anim .pha-replay {
  position: absolute; top: 6px; right: 6px;
  z-index: 5;
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  border: 1px solid var(--pha-rule);
  color: var(--pha-ink-mute);
  font-family: 'Outfit', ui-sans-serif, system-ui, sans-serif;
  font-size: 10.5px; font-weight: 500; letter-spacing: .04em;
  cursor: pointer;
  opacity: 0;
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  transition: background .25s, color .25s, opacity .3s;
}
.pia-hero-anim:hover .pha-replay { opacity: 1; }
.pia-hero-anim .pha-replay:hover { background: #fff; color: var(--pha-ink); }
.pia-hero-anim .pha-replay svg { width: 11px; height: 11px; }
