:host {
  display: inline-block;
  width: var(--flower-size, 160px);
  aspect-ratio: 336 / 604;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  -webkit-tap-highlight-color: transparent; /* the flower can be tapped (it sways) */
}

/* ---------- palette (brand tokens from styles/theme.css) ---------- */
.stop-petal-shade    { stop-color: var(--color-petal-shade); }
.stop-petal          { stop-color: var(--color-petal); }
.stop-petal-light    { stop-color: var(--color-petal-light); }
.stop-face-highlight { stop-color: var(--color-face-highlight); }
.stop-face-light     { stop-color: var(--color-face-light); }
.stop-face           { stop-color: var(--color-face); }
.stop-face-shade     { stop-color: var(--color-face-shade); }
.stop-leaf           { stop-color: var(--color-leaf); }
.stop-leaf-light     { stop-color: var(--color-leaf-light); }
.stop-stem-shade     { stop-color: var(--color-stem-shade); }
.stop-stem-light     { stop-color: var(--color-stem-light); }
.stop-stem           { stop-color: var(--color-stem); }

/* ---------- shapes ---------- */
.ink {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 9;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.face-ink { stroke-width: 10; }

.petal-shade { fill: none; stroke: var(--color-petal-shade); stroke-width: 16; opacity: 0.6; }
.petal-tone  { fill: var(--color-petal-shade); }

.face-fill { fill: url(#face-grad); }
.face-shade { fill: none; stroke: var(--color-face-shade); stroke-width: 16; opacity: 0.7; }

.leaf-fill { fill: url(#leaf-grad); }
.leaf-shade { fill: none; stroke: var(--color-leaf-shade); stroke-width: 16; opacity: 0.6; }

.stem-fill { fill: url(#stem-grad); }

.shine {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.8;
}
.stem-shine { stroke-width: 2.6; opacity: 0.75; }
.shine-dot { fill: #fff; opacity: 0.8; }

.vein {
  fill: none;
  stroke: var(--color-ink);
  stroke-width: 3.2;
  stroke-linecap: round;
}

.glow   { fill: var(--color-glow); opacity: 0.5; }
.cheek  { fill: var(--color-face-shade); opacity: 0.35; }
.blush  { fill: var(--color-blush); opacity: 0.7; }
.eye    { fill: var(--color-ink); }
.eye-shine { fill: #fff; }
.tongue { fill: var(--color-tongue); stroke: var(--color-ink); stroke-width: 2; stroke-linejoin: round; }
.mouth  { fill: none; stroke: var(--color-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }


/* ---------- intro (plays once) ----------
   stem grows → leaves pop out → the moment the stem is fully grown, the face buds out of its tip
   → petals pop out around it one by one while the face's expression fades in */
.stem, .leaf, .face, .petal, .eyes { transform-box: fill-box; }

.stem {
  transform-origin: 50% 100%;
  animation: grow-up 0.7s cubic-bezier(0.3, 0.8, 0.4, 1) 0.1s both;   /* done at 0.8s */
}

.leaf { animation: pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) 0.35s both; }
.leaf-left  { transform-origin: 100% 40%; }
.leaf-right { transform-origin: 0% 40%; }

.glow { animation: glow-in 1.2s ease-out 0.6s both; }

/* grows from the stem tip (402, 360), which sits inside the face circle, starting at zero size
   exactly when the stem finishes — so the head is never there before the stem, nor separate from it */
.face {
  transform-origin: 61% 63%;
  animation: bud 0.65s cubic-bezier(0.3, 0.9, 0.4, 1.12) 0.8s both;
}

.petal {
  transform-origin: 50% 100%;
  animation: pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) calc(1.2s + var(--i) * 0.07s) both;
}

.features { animation: appear 0.6s ease-out 1.3s both; }

/* an occasional quick blink once everything has landed */
.eyes {
  transform-origin: 50% 50%;
  animation: blink 7s ease-in-out 4s infinite;
}

@keyframes grow-up { from { transform: scaleY(0); } to { transform: none; } }
@keyframes pop     { from { transform: scale(0); } to { transform: none; } }
/* nothing → the stem tip swells (bud starts as wide as the stem) → grows up and out into the face */
@keyframes bud {
  0%   { transform: scale(0); }
  1%   { transform: scale(0.17, 0.22); }
  100% { transform: none; }
}
@keyframes appear  { from { opacity: 0; } to { opacity: 1; } }
@keyframes glow-in { from { opacity: 0; } to { opacity: 0.5; } }
@keyframes blink {
  0%, 96%, 100% { transform: none; }
  98%           { transform: scaleY(0.1); }
}

:host([static]) .stem,
:host([static]) .leaf,
:host([static]) .glow,
:host([static]) .face,
:host([static]) .petal,
:host([static]) .features,
:host([static]) .eyes { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .stem, .leaf, .glow, .face, .petal, .features, .eyes { animation: none; }
}