/* Guard Pea checks our code: at the "Our place" desk a "Pea update" card slides up, Guard Pea's
   badge glints and a soft shield of light sweeps the card, the shield pulses, "Checked." is
   stamped on it, and it travels on to Your Pea. Under 600px the frame stacks (container query). */

.anim-guard .gd-frame { container: gd / inline-size; max-width: 880px; }
.anim-guard .gd-stage { position: relative; aspect-ratio: 43 / 20; overflow: hidden;
  background: radial-gradient(ellipse 30% 56% at 26% 60%, rgba(199, 222, 168, .55), rgba(199, 222, 168, 0) 70%), radial-gradient(circle at 86% 42%, rgba(199, 222, 168, .45), rgba(199, 222, 168, 0) 13%), linear-gradient(180deg, var(--card), #f6f8f1); }

.anim-guard .gd-ground { position: absolute; left: 3%; width: 56%; top: 83%; height: 7%; border-radius: 50%; background: radial-gradient(closest-side, rgba(34, 56, 26, .17), rgba(34, 56, 26, 0)); }

/* ---------- Guard Pea ---------- */
.anim-guard .gd-pea { position: absolute; z-index: 3; left: 4.5%; bottom: 13%; height: 76%; aspect-ratio: 566 / 820; transform-origin: 50% 100%; }
.anim-guard .gd-pose { position: absolute; left: 50%; bottom: 0; translate: -50% 0; width: auto; max-width: none; height: 100%; opacity: 0; filter: drop-shadow(0 14px 14px rgba(34, 56, 26, .22)); }
.anim-guard .gd-pose.is-on { opacity: 1; }

/* ---------- the inspection light: a glint on the badge, then a soft shield that sweeps the card ---------- */
.anim-guard .gd-glint { position: absolute; z-index: 6; left: 0; top: 0; width: clamp(38px, 5.6cqw, 52px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, var(--card) 0 14%, rgba(226, 200, 145, .9) 30%, rgba(226, 200, 145, 0) 68%); opacity: 0; pointer-events: none; }
.anim-guard .gd-glint::before, .anim-guard .gd-glint::after { content: ""; position: absolute; left: -20%; top: 50%; width: 140%; height: 4px; margin-top: -2px; border-radius: 4px; background: linear-gradient(90deg, rgba(251, 252, 248, 0), var(--card) 50%, rgba(251, 252, 248, 0)); }
.anim-guard .gd-glint::after { transform: rotate(90deg); }
.anim-guard .gd-beam { position: absolute; z-index: 6; left: 0; top: 0; width: clamp(62px, 10cqw, 90px); aspect-ratio: 100 / 106; opacity: 0; pointer-events: none; filter: drop-shadow(0 0 14px rgba(182, 224, 127, .95)) drop-shadow(0 4px 8px rgba(63, 106, 43, .25)); }
.anim-guard .gd-beam svg { display: block; width: 100%; height: 100%; overflow: visible; }
.anim-guard .gd-beam__s1 { stop-color: var(--card); stop-opacity: .96; }
.anim-guard .gd-beam__s2 { stop-color: #b6e07f; stop-opacity: .7; }
.anim-guard .gd-beam__s3 { stop-color: #b6e07f; stop-opacity: .3; }
.anim-guard .gd-beam__body { fill: url(#gd-beam-fill); }
.anim-guard .gd-beam__edge { fill: none; stroke: var(--pea-hi); stroke-opacity: .75; stroke-width: 3.5; stroke-linejoin: round; }

/* ---------- the desk at our place ---------- */
.anim-guard .gd-desk { position: absolute; z-index: 4; left: 30%; width: 26.5%; bottom: 13%; height: 27%; display: grid; grid-template-rows: auto 1fr; }
.anim-guard .gd-desk__top { height: clamp(10px, 1.6cqw, 14px); margin: 0 -4%; border-radius: 7px; background: color-mix(in srgb, var(--brass) 42%, var(--brass-soft)); box-shadow: 0 6px 10px -6px rgba(138, 101, 38, .6); }
.anim-guard .gd-desk__front { display: grid; place-items: center; border-radius: 0 0 12px 12px; background: var(--brass-soft); border: 1.5px solid #e2c891; border-top: 0; box-shadow: 0 16px 22px -18px rgba(138, 101, 38, .7); }
.anim-guard .gd-desk__plaque { display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; background: var(--card); border: 1.5px solid #e2c891; font: 800 clamp(11.5px, 1.55cqw, 14px)/1 var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--brass); white-space: nowrap; }
.anim-guard .gd-desk__plaque i { width: 8px; height: 8px; border-radius: 50%; background: var(--pea-hi); box-shadow: 0 0 0 3px rgba(111, 161, 74, .25); }

/* ---------- the Pea update card ---------- */
.anim-guard .gd-card { position: absolute; z-index: 2; left: 33%; width: 20.5%; bottom: 40%; padding: clamp(10px, 1.5cqw, 14px) clamp(11px, 1.6cqw, 15px) clamp(12px, 1.8cqw, 16px); border-radius: 16px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); text-align: left; transform-origin: 50% 100%; }
.anim-guard .gd-card.is-fly { z-index: 6; }
.anim-guard .gd-card__top { display: flex; align-items: center; gap: 8px; font: 700 clamp(12px, 1.6cqw, 15px)/1.2 var(--body); color: var(--ink); white-space: nowrap; }
.anim-guard .gd-card__dot { flex: none; width: 1.15em; height: 1.15em; border-radius: 50%; background: radial-gradient(circle at 38% 34%, #a9cf7f, var(--pea-hi) 55%, var(--pea)); }
.anim-guard .gd-code { position: relative; display: grid; gap: clamp(7px, 1.05cqw, 9px); margin-top: clamp(10px, 1.5cqw, 13px); }
.anim-guard .gd-code__row { display: flex; gap: 6%; }
.anim-guard .gd-code__row.in1 { padding-left: 10%; }
.anim-guard .gd-code__row.in2 { padding-left: 20%; }
.anim-guard .gd-code__row i { height: clamp(7px, 1.05cqw, 9px); border-radius: 9px; background: var(--line); }
.anim-guard .gd-code__row i.w2 { width: 15%; }
.anim-guard .gd-code__row i.w3 { width: 22%; }
.anim-guard .gd-code__row i.w4 { width: 30%; }
.anim-guard .gd-code__row i.w5 { width: 40%; }
.anim-guard .gd-code__row i.c1 { background: var(--pea-glow); }
.anim-guard .gd-code__row i.c2 { background: color-mix(in srgb, var(--brass) 32%, var(--brass-soft)); }
.anim-guard .gd-code__row i.c3 { background: color-mix(in srgb, var(--pea-hi) 55%, #fff); }
.anim-guard .gd-scan { position: absolute; left: -6%; right: -6%; top: -10%; height: 32%; border-radius: 8px; background: linear-gradient(180deg, rgba(182, 224, 127, 0), rgba(182, 224, 127, .5) 50%, rgba(182, 224, 127, 0)); opacity: 0; pointer-events: none; }

/* the shield on the card's corner */
.anim-guard .gd-shield { position: absolute; top: clamp(-18px, -2cqw, -12px); right: clamp(-18px, -2cqw, -12px); width: clamp(38px, 5.6cqw, 50px); aspect-ratio: 100 / 106; }
.anim-guard .gd-shield svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.anim-guard .gd-shield__body { filter: drop-shadow(0 6px 8px rgba(34, 56, 26, .25)); }
.anim-guard .gd-shield__body path { fill: #e3efd3; stroke: var(--pea-hi); stroke-width: 4; stroke-linejoin: round; }
.anim-guard .gd-shield__body .gd-shield__inner { fill: #fff; stroke: var(--pea-glow); stroke-width: 2.5; }
.anim-guard .gd-shield__body .gd-shield__pea { fill: var(--pea-hi); stroke: var(--pea); stroke-width: 2.5; }
.anim-guard .gd-shield__body .gd-shield__shine { fill: rgba(255, 255, 255, .65); stroke: none; }
.anim-guard .gd-shield__ring { opacity: 0; }
.anim-guard .gd-shield__ring path { fill: none; stroke: var(--pea-hi); stroke-width: 3; }

/* the stamp */
.anim-guard .gd-stamp { position: absolute; right: 8%; bottom: clamp(10px, 1.6cqw, 14px); padding: .26em .5em .3em; border-radius: 10px; border: 3px solid var(--pea); background: rgba(223, 232, 211, .92); color: var(--pea); font: 800 clamp(18px, 2.7cqw, 26px)/1 var(--display); letter-spacing: -.02em; white-space: nowrap; rotate: -8deg; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .55), 0 8px 14px -10px rgba(34, 56, 26, .6); }

/* ---------- the road to Your Pea ---------- */
.anim-guard .gd-path { position: absolute; z-index: 1; left: 54%; width: 25.5%; top: 42%; height: 0; }
.anim-guard .gd-path__track { position: absolute; left: 0; right: 0; top: -1.5px; height: 3px; border-radius: 3px; background: repeating-linear-gradient(90deg, var(--pea-glow) 0 9px, transparent 9px 16px); transform-origin: 0 50%; }

.anim-guard .gd-dest { --pad: clamp(64px, 10.4cqw, 92px); position: absolute; z-index: 5; left: 86%; top: calc(42% - var(--pad) / 2); translate: -50% 0; display: grid; justify-items: center; gap: 10px; }
.anim-guard .gd-dest__pad { position: relative; display: grid; place-items: center; width: var(--pad); height: var(--pad); border-radius: 50%; background: var(--card); border: 2px solid var(--pea-glow); box-shadow: 0 16px 26px -16px rgba(34, 56, 26, .55); }
.anim-guard .gd-dest__pad img { width: auto; height: 70%; margin-top: 4%; }
.anim-guard .gd-dest__ring { position: absolute; top: 0; left: 50%; width: var(--pad); height: var(--pad); margin-left: calc(var(--pad) / -2); border-radius: 50%; border: 3px solid var(--pea-hi); opacity: 0; pointer-events: none; }
.anim-guard .gd-dest__ok { position: absolute; top: -8px; left: calc(50% + var(--pad) * .24); width: clamp(28px, 3.9cqw, 34px); aspect-ratio: 100 / 106; filter: drop-shadow(0 5px 6px rgba(34, 56, 26, .3)); }
.anim-guard .gd-dest__ok svg { display: block; width: 100%; height: 100%; overflow: visible; }
.anim-guard .gd-dest__ok path { fill: var(--pea-hi); stroke: var(--card); stroke-width: 7; stroke-linejoin: round; }
.anim-guard .gd-dest__ok .gd-dest__tick { fill: none; stroke: #fff; stroke-width: 11; stroke-linecap: round; stroke-linejoin: round; }
.anim-guard .gd-dest__lbl { padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font: 800 clamp(13px, 1.7cqw, 16px)/1 var(--display); letter-spacing: -.02em; color: var(--ink); white-space: nowrap; }

/* ---------- caption ---------- */
.anim-guard .gd-cap { min-height: 1.3em; padding: 16px 20px 22px; border-top: 1px solid var(--line); text-align: center; font: 800 clamp(19px, 2.9cqw, 26px)/1.2 var(--display); letter-spacing: -.02em; color: var(--ink); text-wrap: balance; }

/* ---------- start state (only once the script is running) ---------- */
.anim-guard.gd-ready .gd-card, .anim-guard.gd-ready .gd-stamp, .anim-guard.gd-ready .gd-shield, .anim-guard.gd-ready .gd-dest__ok { opacity: 0; }
.anim-guard.gd-ready .gd-path__track { transform: scaleX(0); }
/* the control row shows from the first frame (the sound button, centred on its own while it
   plays); Watch again joins it at the end. The row keeps its height the whole time */
.anim-guard .anim-ctl { min-height: 44px; align-items: center; }
.anim-guard.gd-ready .gd-again { display: none; }
.anim-guard.gd-ready.gd-done .gd-again { display: inline-flex; animation: guard-in .4s ease both; }
@keyframes guard-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- phones and narrow frames: Guard Pea on the left, the desk on the right,
   and the road runs up to Your Pea. Guard Pea sits a little smaller and in from the edge, so
   its hand stays clear of the card ---------- */
@container gd (max-width: 600px) {
  .anim-guard .gd-stage { aspect-ratio: 9 / 10; background: radial-gradient(ellipse 46% 40% at 28% 62%, rgba(199, 222, 168, .55), rgba(199, 222, 168, 0) 70%), radial-gradient(circle at 73.5% 12%, rgba(199, 222, 168, .5), rgba(199, 222, 168, 0) 20%), linear-gradient(180deg, var(--card), #f6f8f1); }
  .anim-guard .gd-ground { left: -2%; width: 104%; top: 88.5%; height: 6%; }
  .anim-guard .gd-pea { left: 7%; bottom: 8%; height: 58%; }
  .anim-guard .gd-desk { left: 50%; width: 47%; bottom: 8%; height: 17%; }
  .anim-guard .gd-desk__top { margin: 0 -3%; }
  .anim-guard .gd-desk__plaque { padding: 6px 10px; font-size: 12px; }
  .anim-guard .gd-card { left: 56%; width: 38%; bottom: 25%; border-radius: 14px; padding: 11px 12px 13px; }
  .anim-guard .gd-card__top { font-size: 13px; }
  .anim-guard .gd-code { gap: 8px; margin-top: 10px; }
  .anim-guard .gd-code__row i { height: 7px; }
  .anim-guard .gd-shield { width: 38px; top: -14px; right: -12px; }
  .anim-guard .gd-beam { width: 60px; }
  .anim-guard .gd-glint { width: 36px; }
  .anim-guard .gd-stamp { font-size: 20px; right: 6%; bottom: 10px; }
  .anim-guard .gd-path { left: 73.5%; width: 0; top: 28.5%; height: 46%; }
  .anim-guard .gd-path__track { left: -1.5px; right: auto; top: 0; bottom: 0; width: 3px; height: auto; background: repeating-linear-gradient(180deg, var(--pea-glow) 0 8px, transparent 8px 14px); transform-origin: 50% 100%; }
  .anim-guard.gd-ready .gd-path__track { transform: scaleY(0); }
  .anim-guard .gd-dest { --pad: 58px; left: 73.5%; top: 4%; gap: 8px; }
  .anim-guard .gd-dest__lbl { font-size: 14px; padding: 5px 11px; }
  /* room for two lines (box-sizing is border-box, so the padding counts): "Checked, then on its way to your Pea." wraps, the first caption doesn't, and the row under the frame must not jump */
  .anim-guard .gd-cap { padding: 14px 16px 18px; min-height: calc(2.4em + 34px); font-size: 20px; }
}
