// KaylinExpressions.jsx — Character expression sheet for Kaylin the unicorn.
// One default-export React component renders a 5×2 grid of 10 standalone SVG poses.
// Same silhouette across all poses: elegant peach unicorn, flowing lilac mane, small refined
// golden horn, pointed ears, lilac iris almond eyes. Only emotion + body language change.

/* ============================================================
   SHARED HELPERS — each pose carries its own <defs> so the SVG
   is extractable as a standalone file.
   ============================================================ */

const KaylinDefs = ({ id }) => (
  <defs>
    <radialGradient id={`${id}-body`} cx="38%" cy="30%" r="82%">
      <stop offset="0%" stopColor="#FFE6CF" />
      <stop offset="55%" stopColor="#F4A57A" />
      <stop offset="100%" stopColor="#B0612E" />
    </radialGradient>
    <linearGradient id={`${id}-mane`} x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stopColor="#EFDCF7" />
      <stop offset="50%" stopColor="#B89DD9" />
      <stop offset="100%" stopColor="#6F4A92" />
    </linearGradient>
    <linearGradient id={`${id}-mane2`} x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stopColor="#D5B8E8" />
      <stop offset="100%" stopColor="#8E69B3" />
    </linearGradient>
    <linearGradient id={`${id}-horn`} x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stopColor="#F2DBA6" />
      <stop offset="50%" stopColor="#C99B4E" />
      <stop offset="100%" stopColor="#8E6722" />
    </linearGradient>
    <radialGradient id={`${id}-cheek`} cx="50%" cy="50%" r="50%">
      <stop offset="0%" stopColor="#FF7A55" stopOpacity="0.5" />
      <stop offset="100%" stopColor="#FF7A55" stopOpacity="0" />
    </radialGradient>
    <linearGradient id={`${id}-rim`} x1="0%" y1="0%" x2="0%" y2="100%">
      <stop offset="0%" stopColor="#FFFFFF" stopOpacity="0.55" />
      <stop offset="100%" stopColor="#FFFFFF" stopOpacity="0" />
    </linearGradient>
    <radialGradient id={`${id}-glow`} cx="50%" cy="50%" r="50%">
      <stop offset="0%" stopColor="#FFEB80" stopOpacity="0.85" />
      <stop offset="50%" stopColor="#E8B651" stopOpacity="0.4" />
      <stop offset="100%" stopColor="#E8B651" stopOpacity="0" />
    </radialGradient>
    <filter id={`${id}-blur`} x="-30%" y="-30%" width="160%" height="160%">
      <feGaussianBlur stdDeviation="4" />
    </filter>
    <filter id={`${id}-soft`} x="-40%" y="-40%" width="180%" height="180%">
      <feGaussianBlur stdDeviation="3" />
    </filter>
  </defs>
);

const Shadow = ({ id, rx = 56, cy = 206, op = 0.22 }) => (
  <ellipse cx="100" cy={cy} rx={rx} ry="6" fill="#2C2B36" opacity={op} filter={`url(#${id}-blur)`} />
);

// Standard mane — flowing back-left + tail on right (most poses)
const ManeBack = ({ id }) => (
  <g>
    {/* tail behind body on right */}
    <path d="M150 178 Q180 168 178 138 Q186 122 174 116 Q166 124 170 138 Q160 156 152 168 Z" fill={`url(#${id}-mane)`} />
    <path d="M168 130 Q172 116 162 110 Q160 122 166 132 Z" fill={`url(#${id}-mane2)`} />
    {/* mane back-left flowing */}
    <path d="M50 88 Q32 70 38 46 Q50 36 58 56 Q50 68 60 84 Q48 96 52 110 Q40 108 50 88 Z" fill={`url(#${id}-mane)`} />
    <path d="M44 64 Q34 50 44 36 Q50 50 50 64 Z" fill={`url(#${id}-mane2)`} />
    {/* extra strand on neck */}
    <path d="M52 104 Q44 116 52 128 Q56 116 56 108 Z" fill={`url(#${id}-mane2)`} opacity="0.85" />
  </g>
);

// Flared mane — for surprise (mane explodes outward)
const ManeBackFlared = ({ id }) => (
  <g>
    {/* tail flared up + outward */}
    <path d="M150 178 Q194 152 188 110 Q184 84 160 92 Q168 116 172 138 Q160 158 152 170 Z" fill={`url(#${id}-mane)`} />
    <path d="M170 128 Q182 104 162 96 Q160 122 168 132 Z" fill={`url(#${id}-mane2)`} />
    {/* mane left side flared wider */}
    <path d="M48 90 Q12 56 18 22 Q42 18 56 50 Q50 70 60 86 Q44 96 52 112 Q36 110 48 90 Z" fill={`url(#${id}-mane)`} />
    <path d="M28 46 Q12 28 22 8 Q40 22 42 46 Z" fill={`url(#${id}-mane2)`} />
    {/* extra streamer over head */}
    <path d="M84 38 Q66 10 78 0 Q90 14 96 32 Z" fill={`url(#${id}-mane2)`} opacity="0.9" />
    {/* small floating mane wisps */}
    <path d="M152 88 Q170 70 180 78 Q166 82 158 96 Z" fill={`url(#${id}-mane)`} opacity="0.75" />
  </g>
);

// Resting mane — for sleepy (less voluminous, drooped)
const ManeBackResting = ({ id }) => (
  <g>
    {/* shorter tail */}
    <path d="M148 178 Q170 184 172 156 Q174 142 160 138 Q158 152 158 162 Q154 170 148 178 Z" fill={`url(#${id}-mane)`} />
    <path d="M164 150 Q170 138 160 134 Q160 144 164 152 Z" fill={`url(#${id}-mane2)`} />
    {/* mane resting flatter on shoulder */}
    <path d="M52 96 Q42 80 46 64 Q56 58 62 76 Q58 86 64 100 Q52 104 52 96 Z" fill={`url(#${id}-mane)`} />
    <path d="M48 78 Q42 68 50 58 Q54 68 54 78 Z" fill={`url(#${id}-mane2)`} />
  </g>
);

const Body = ({ id, transform }) => (
  <g transform={transform}>
    <ellipse cx="100" cy="172" rx="52" ry="38" fill={`url(#${id}-body)`} />
    <ellipse cx="100" cy="180" rx="30" ry="20" fill="#FFE6CF" opacity="0.65" />
  </g>
);

const Hoof = ({ cx, cy = 200 }) => (
  <g>
    <ellipse cx={cx} cy={cy} rx="10" ry="6" fill="#7E5BA0" />
    <ellipse cx={cx} cy={cy} rx="7" ry="2.5" fill="#B89DD9" opacity="0.6" />
  </g>
);

// Horn — small, refined, gold. `glow` adds soft halo for proud pose.
const Horn = ({ id, glow = false, transform }) => (
  <g transform={transform}>
    {glow && (
      <>
        <circle cx="100" cy="46" r="22" fill={`url(#${id}-glow)`} />
        <circle cx="100" cy="46" r="14" fill="#FFEB80" opacity="0.55" filter={`url(#${id}-soft)`} />
      </>
    )}
    <path d="M100 44 L94 76 L106 76 Z" fill={`url(#${id}-horn)`} stroke="#7A5A24" strokeWidth="0.6" />
    <path d="M96 70 L104 70" stroke="#7A5A24" strokeWidth="1" opacity="0.6" />
    <path d="M97 62 L103 62" stroke="#7A5A24" strokeWidth="0.9" opacity="0.6" />
    <path d="M98 54 L102 54" stroke="#7A5A24" strokeWidth="0.7" opacity="0.6" />
    <path d="M97 48 L99 70" stroke="#FBEACA" strokeWidth="1.1" opacity="0.7" />
    {glow && (
      <g fill="#FFFFFF" opacity="0.9">
        <circle cx="100" cy="42" r="2" />
      </g>
    )}
  </g>
);

const HeadBase = ({ id, transform }) => (
  <g transform={transform}>
    <ellipse cx="100" cy="112" rx="54" ry="52" fill={`url(#${id}-body)`} />
    <ellipse cx="76" cy="82" rx="28" ry="15" fill={`url(#${id}-rim)`} />
    {/* mane forelock */}
    <path d="M70 72 Q60 50 86 46 Q78 60 90 70 Q80 76 70 72 Z" fill={`url(#${id}-mane)`} />
    <path d="M88 60 Q92 38 108 42 Q100 56 110 70 Q94 72 88 60 Z" fill={`url(#${id}-mane2)`} />
    <path d="M112 60 Q122 42 132 56 Q124 66 122 76 Q112 72 112 60 Z" fill={`url(#${id}-mane)`} />
  </g>
);

const EarsRelaxed = ({ id }) => (
  <g>
    <path d="M62 80 L58 60 L76 72 Z" fill={`url(#${id}-body)`} />
    <path d="M138 80 L142 60 L124 72 Z" fill={`url(#${id}-body)`} />
    <path d="M64 76 L62 66 L72 72 Z" fill="#B89DD9" />
    <path d="M136 76 L138 66 L128 72 Z" fill="#B89DD9" />
  </g>
);

const EarsPerked = ({ id }) => (
  <g>
    {/* both alert + taller */}
    <path d="M62 78 L56 42 L80 64 Z" fill={`url(#${id}-body)`} />
    <path d="M138 78 L144 42 L120 64 Z" fill={`url(#${id}-body)`} />
    <path d="M64 72 L60 50 L74 64 Z" fill="#B89DD9" />
    <path d="M136 72 L140 50 L126 64 Z" fill="#B89DD9" />
  </g>
);

const EarsStraight = ({ id }) => (
  <g>
    {/* completely vertical (surprised) */}
    <path d="M64 76 L60 28 L80 60 Z" fill={`url(#${id}-body)`} />
    <path d="M136 76 L140 28 L120 60 Z" fill={`url(#${id}-body)`} />
    <path d="M66 70 L62 40 L74 60 Z" fill="#B89DD9" />
    <path d="M134 70 L138 40 L126 60 Z" fill="#B89DD9" />
  </g>
);

const EarsDrooped = ({ id }) => (
  <g>
    {/* drooped down (sleepy) */}
    <path d="M62 78 Q56 92 78 86 L76 72 Z" fill={`url(#${id}-body)`} />
    <path d="M138 78 Q144 92 122 86 L124 72 Z" fill={`url(#${id}-body)`} />
    <path d="M64 80 Q62 86 72 84 L70 76 Z" fill="#B89DD9" />
    <path d="M136 80 Q138 86 128 84 L130 76 Z" fill="#B89DD9" />
  </g>
);

const Cheeks = ({ id, lx = 68, rx = 132, cy = 132, r = 11 }) => (
  <g>
    <circle cx={lx} cy={cy} r={r} fill={`url(#${id}-cheek)`} />
    <circle cx={rx} cy={cy} r={r} fill={`url(#${id}-cheek)`} />
  </g>
);

const Muzzle = ({ cx = 100, cy = 144 }) => (
  <g>
    <ellipse cx={cx} cy={cy} rx="15" ry="10" fill="#FFE6CF" opacity="0.75" />
    <ellipse cx={cx} cy={cy} rx="4" ry="2.5" fill="#7E5BA0" />
  </g>
);

/* ============================================================
   EYE VARIANTS — Kaylin's eyes are elegant almond shape (8×11)
   with lilac iris (#B89DD9), 2 sweeping lashes per eye.
   ============================================================ */

const EyeOpen = ({ cx, cy, irisDx = 0, irisDy = 2 }) => (
  <g>
    <ellipse cx={cx} cy={cy} rx="8" ry="11" fill="#2C2B36" />
    <ellipse cx={cx + irisDx} cy={cy + irisDy} rx="4" ry="6" fill="#B89DD9" />
    <ellipse cx={cx + irisDx} cy={cy + irisDy} rx="3" ry="4" fill="#D5B8E8" opacity="0.55" />
    <ellipse cx={cx + irisDx} cy={cy + irisDy + 1} rx="1.8" ry="3" fill="#2C2B36" />
    <circle cx={cx + 3} cy={cy - 5} r="3" fill="#FFFFFF" />
    <circle cx={cx - 3} cy={cy + 4} r="1.2" fill="#FFFFFF" />
  </g>
);

const EyeWide = ({ cx, cy }) => (
  <g>
    <ellipse cx={cx} cy={cy} rx="9" ry="13" fill="#2C2B36" />
    <ellipse cx={cx} cy={cy} rx="5" ry="8" fill="#B89DD9" />
    <ellipse cx={cx} cy={cy} rx="3.5" ry="5" fill="#D5B8E8" opacity="0.55" />
    <ellipse cx={cx} cy={cy + 1} rx="2" ry="3.5" fill="#2C2B36" />
    <circle cx={cx + 3} cy={cy - 6} r="3.4" fill="#FFFFFF" />
    <circle cx={cx - 3} cy={cy + 5} r="1.4" fill="#FFFFFF" />
  </g>
);

const EyeSquint = ({ cx, cy }) => (
  <path
    d={`M${cx - 9} ${cy + 1} Q${cx} ${cy - 10} ${cx + 9} ${cy + 1}`}
    stroke="#2C2B36"
    strokeWidth="2.8"
    strokeLinecap="round"
    fill="none"
  />
);

const EyeSleepy = ({ cx, cy }) => (
  <g>
    {/* lower curve */}
    <path d={`M${cx - 9} ${cy + 1} Q${cx} ${cy + 8} ${cx + 9} ${cy + 1}`} stroke="#2C2B36" strokeWidth="2.2" fill="none" strokeLinecap="round" />
    {/* upper lid */}
    <path d={`M${cx - 9} ${cy + 1} Q${cx - 8} ${cy - 3} ${cx} ${cy - 4} Q${cx + 8} ${cy - 3} ${cx + 9} ${cy + 1} Z`} fill="#2C2B36" />
    {/* tiny iris hint */}
    <ellipse cx={cx} cy={cy} rx="3" ry="1.6" fill="#B89DD9" opacity="0.85" />
  </g>
);

const EyeSmug = ({ cx, cy, dir = 1 }) => (
  <g>
    <path
      d={`M${cx - 9} ${cy - 2} Q${cx} ${cy - 6} ${cx + 9} ${cy - 2} Q${cx + 8} ${cy + 3} ${cx} ${cy + 4} Q${cx - 8} ${cy + 3} ${cx - 9} ${cy - 2} Z`}
      fill="#2C2B36"
    />
    <ellipse cx={cx + dir * 1.5} cy={cy} rx="3" ry="2.5" fill="#B89DD9" />
    <ellipse cx={cx + dir * 1.5} cy={cy + 1} rx="1.4" ry="1.6" fill="#2C2B36" />
    <circle cx={cx + dir * 1.5 + 1.2} cy={cy - 1} r="0.9" fill="#FFFFFF" />
  </g>
);

const EyeFocused = ({ cx, cy }) => (
  <g>
    <ellipse cx={cx} cy={cy + 2} rx="8" ry="7" fill="#2C2B36" />
    <ellipse cx={cx} cy={cy + 2} rx="4" ry="4" fill="#B89DD9" />
    <ellipse cx={cx} cy={cy + 3} rx="1.8" ry="2.4" fill="#2C2B36" />
    <circle cx={cx + 3} cy={cy - 1} r="2.4" fill="#FFFFFF" />
  </g>
);

const EyeLookUp = ({ cx, cy }) => (
  <g>
    <ellipse cx={cx} cy={cy} rx="8" ry="11" fill="#2C2B36" />
    <ellipse cx={cx} cy={cy - 3} rx="4" ry="6" fill="#B89DD9" />
    <ellipse cx={cx} cy={cy - 3} rx="3" ry="4" fill="#D5B8E8" opacity="0.55" />
    <ellipse cx={cx} cy={cy - 3} rx="1.8" ry="3" fill="#2C2B36" />
    <circle cx={cx + 3} cy={cy - 8} r="2.8" fill="#FFFFFF" />
  </g>
);

const Lashes = ({ cx, cy }) => (
  <g stroke="#2C2B36" strokeWidth="1.4" strokeLinecap="round" fill="none">
    <path d={`M${cx - 7} ${cy - 6} L${cx - 12} ${cy - 11}`} />
    <path d={`M${cx - 5} ${cy - 11} L${cx - 6} ${cy - 17}`} />
    <path d={`M${cx + 7} ${cy - 6} L${cx + 12} ${cy - 11}`} />
    <path d={`M${cx + 5} ${cy - 11} L${cx + 6} ${cy - 17}`} />
  </g>
);

/* ============================================================
   MOUTH VARIANTS
   ============================================================ */

const MouthSmile = () => (
  <g>
    <path d="M100 148 Q95 154 90 150" stroke="#2C2B36" strokeWidth="1.6" fill="none" strokeLinecap="round" />
    <path d="M100 148 Q105 154 110 150" stroke="#2C2B36" strokeWidth="1.6" fill="none" strokeLinecap="round" />
  </g>
);

const MouthGentleSmile = () => (
  <path d="M92 150 Q100 156 108 150" stroke="#2C2B36" strokeWidth="1.7" fill="none" strokeLinecap="round" />
);

const MouthOpenSmile = () => (
  <g>
    <path d="M90 150 Q100 162 110 150 Q106 152 100 152 Q94 152 90 150 Z" fill="#5C1E3A" />
    <path d="M93 152 Q100 157 107 152" stroke="#3F102A" strokeWidth="0.6" fill="none" />
    <ellipse cx="100" cy="156" rx="3" ry="2" fill="#E07AA0" />
  </g>
);

const MouthO = ({ cy = 150, ry = 3.5 }) => (
  <ellipse cx="100" cy={cy} rx="3" ry={ry} fill="#5C1E3A" />
);

const MouthYawn = () => (
  <g>
    <ellipse cx="100" cy="152" rx="4.5" ry="6" fill="#5C1E3A" />
    <ellipse cx="100" cy="155" rx="2.5" ry="1.6" fill="#E07AA0" />
  </g>
);

const MouthSly = () => (
  <g>
    <path d="M90 150 Q96 148 100 150 Q108 154 112 149" stroke="#2C2B36" strokeWidth="1.8" fill="none" strokeLinecap="round" />
    <rect x="105" y="150" width="2" height="2.2" rx="0.5" fill="#FFFFFF" />
  </g>
);

const MouthSet = () => (
  <path d="M93 151 Q100 152 107 151" stroke="#2C2B36" strokeWidth="1.8" fill="none" strokeLinecap="round" />
);

/* ============================================================
   BROW VARIANTS
   ============================================================ */

const BrowFurrowed = () => (
  <g stroke="#5C1E3A" strokeWidth="2" strokeLinecap="round" fill="none">
    <path d="M72 96 Q78 94 86 96" />
    <path d="M128 96 Q122 94 114 96" />
  </g>
);

const BrowDetermined = () => (
  <g stroke="#5C1E3A" strokeWidth="2.4" strokeLinecap="round" fill="none">
    <path d="M70 102 L86 96" />
    <path d="M130 102 L114 96" />
  </g>
);

const BrowMisch = () => (
  <g stroke="#5C1E3A" strokeWidth="2.1" strokeLinecap="round" fill="none">
    <path d="M72 98 Q78 96 86 98" />
    <path d="M128 88 Q122 84 114 88" />
  </g>
);

/* ============================================================
   POSE 01 — IDLE
   ============================================================ */

const PoseIdle = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — idle">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBack id={id} />
    <Body id={id} />
    <Hoof cx={78} />
    <Hoof cx={122} />
    <HeadBase id={id} />
    <Horn id={id} />
    <EarsRelaxed id={id} />
    <EyeOpen cx={80} cy={116} />
    <EyeOpen cx={120} cy={116} />
    <Lashes cx={80} cy={116} />
    <Lashes cx={120} cy={116} />
    <Cheeks id={id} />
    <Muzzle />
    <MouthSmile />
  </svg>
);

/* ============================================================
   POSE 02 — CURIOUS  (head tilt, ears perked, wide eyes catching light)
   ============================================================ */

const PoseCurious = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — curious">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBack id={id} />
    <Body id={id} />
    <Hoof cx={78} />
    <Hoof cx={122} />
    <g transform="rotate(-10 100 130)">
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsPerked id={id} />
      <EyeWide cx={80} cy={116} />
      <EyeWide cx={120} cy={116} />
      <Lashes cx={80} cy={116} />
      <Lashes cx={120} cy={116} />
      <Cheeks id={id} />
      <Muzzle />
      <MouthO cy={150} ry={3.2} />
    </g>
    {/* "?" sparkle near head */}
    <g transform="translate(168 38)" className="anim-shimmer-soft">
      <circle cx="0" cy="0" r="11" fill="#F8E9DC" stroke="#B89DD9" strokeWidth="2" />
      <text x="0" y="5" textAnchor="middle" fontFamily="Fredoka, sans-serif" fontWeight="700" fontSize="14" fill="#7E5BA0">?</text>
    </g>
  </svg>
);

/* ============================================================
   POSE 03 — THINKING  (hoof to chin, looking up at sparkle, furrow)
   ============================================================ */

const PoseThinking = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — thinking">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBack id={id} />
    <Body id={id} />
    <Hoof cx={78} />
    {/* right hoof to chin */}
    <g>
      <ellipse cx="116" cy="172" rx="5" ry="9" fill="#F4A57A" transform="rotate(-30 116 172)" />
      <ellipse cx="110" cy="158" rx="7" ry="5" fill="#7E5BA0" />
      <ellipse cx="110" cy="158" rx="5" ry="2.5" fill="#B89DD9" opacity="0.6" />
    </g>
    <HeadBase id={id} />
    <Horn id={id} />
    <EarsRelaxed id={id} />
    <EyeLookUp cx={80} cy={116} />
    <EyeLookUp cx={120} cy={116} />
    <Lashes cx={80} cy={116} />
    <Lashes cx={120} cy={116} />
    <BrowFurrowed />
    <Cheeks id={id} />
    <Muzzle />
    <path d="M93 151 Q100 154 107 151" stroke="#2C2B36" strokeWidth="1.6" fill="none" strokeLinecap="round" />
    {/* upward sparkle Kaylin is looking at */}
    <g className="anim-shimmer-soft">
      <path d="M168 32 L170 42 L180 44 L170 46 L168 56 L166 46 L156 44 L166 42 Z" fill="#E8B651" />
      <circle cx="168" cy="44" r="3" fill="#FBEACA" />
    </g>
    {/* thought trail dots */}
    <g fill="#B89DD9" opacity="0.85">
      <circle cx="146" cy="56" r="2.5" />
      <circle cx="154" cy="50" r="3.4" />
    </g>
  </svg>
);

/* ============================================================
   POSE 04 — ENCOURAGING  (leaning forward, hoof out, sparkle smile)
   ============================================================ */

const PoseEncouraging = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — encouraging">
    <KaylinDefs id={id} />
    <Shadow id={id} rx={62} />
    <ManeBack id={id} />
    <g transform="rotate(4 100 178)">
      <Body id={id} />
    </g>
    <Hoof cx={84} />
    {/* extended right hoof */}
    <g>
      <ellipse cx="142" cy="178" rx="7" ry="5" fill="#F4A57A" transform="rotate(22 142 178)" />
      <ellipse cx="154" cy="180" rx="9" ry="6" fill="#7E5BA0" />
      <ellipse cx="154" cy="180" rx="6" ry="2.8" fill="#B89DD9" opacity="0.7" />
      <path d="M166 176 L172 173" stroke="#B89DD9" strokeWidth="1.6" strokeLinecap="round" opacity="0.7" />
      <path d="M167 182 L174 184" stroke="#B89DD9" strokeWidth="1.6" strokeLinecap="round" opacity="0.7" />
    </g>
    <g transform="rotate(3 100 108)">
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsRelaxed id={id} />
      <EyeOpen cx={80} cy={116} />
      <EyeOpen cx={120} cy={116} />
      <Lashes cx={80} cy={116} />
      <Lashes cx={120} cy={116} />
      <Cheeks id={id} />
      <Muzzle />
      <MouthGentleSmile />
    </g>
    {/* warm sparkles */}
    <g fill="#E8B651">
      <path d="M176 168 L177 171 L180 172 L177 173 L176 176 L175 173 L172 172 L175 171 Z" />
      <path d="M182 192 L183 194 L185 195 L183 196 L182 198 L181 196 L179 195 L181 194 Z" />
    </g>
  </svg>
);

/* ============================================================
   POSE 05 — CHEERING  (bouncing, both hooves up, squinted joy)
   ============================================================ */

const PoseCheering = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — cheering">
    <KaylinDefs id={id} />
    <Shadow id={id} rx={40} cy={210} op={0.16} />
    <g fill="#FFFFFF" opacity="0.6">
      <ellipse cx="64" cy="208" rx="6" ry="2" />
      <ellipse cx="136" cy="208" rx="6" ry="2" />
    </g>
    <g transform="translate(0 -8)">
      <ManeBack id={id} />
      <Body id={id} />
      {/* arms raised */}
      <g>
        <path d="M62 162 Q52 130 50 116 Q56 112 64 130 Q72 152 70 168 Z" fill={`url(#${id}-body)`} />
        <ellipse cx="50" cy="114" rx="9" ry="6" fill="#7E5BA0" />
        <ellipse cx="50" cy="114" rx="6" ry="2.8" fill="#B89DD9" opacity="0.7" />
        <path d="M138 162 Q148 130 150 116 Q144 112 136 130 Q128 152 130 168 Z" fill={`url(#${id}-body)`} />
        <ellipse cx="150" cy="114" rx="9" ry="6" fill="#7E5BA0" />
        <ellipse cx="150" cy="114" rx="6" ry="2.8" fill="#B89DD9" opacity="0.7" />
      </g>
      {/* tucked hind legs */}
      <ellipse cx="82" cy="206" rx="9" ry="5" fill="#7E5BA0" />
      <ellipse cx="118" cy="206" rx="9" ry="5" fill="#7E5BA0" />
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsRelaxed id={id} />
      <EyeSquint cx={80} cy={118} />
      <EyeSquint cx={120} cy={118} />
      <Cheeks id={id} lx={64} rx={136} cy={134} r={12} />
      <Muzzle />
      <MouthOpenSmile />
    </g>
    {/* burst of sparkles */}
    <g fill="#E8B651">
      <path d="M22 32 L23 36 L27 37 L23 38 L22 42 L21 38 L17 37 L21 36 Z" />
      <path d="M178 32 L179 36 L183 37 L179 38 L178 42 L177 38 L173 37 L177 36 Z" />
      <path d="M100 14 L101 18 L105 19 L101 20 L100 24 L99 20 L95 19 L99 18 Z" />
      <path d="M40 60 L41 63 L44 64 L41 65 L40 68 L39 65 L36 64 L39 63 Z" />
      <path d="M160 60 L161 63 L164 64 L161 65 L160 68 L159 65 L156 64 L159 63 Z" />
    </g>
    <g>
      <path d="M30 92 Q26 86 30 82 Q34 80 34 85 Q34 80 38 82 Q42 86 38 92 Q34 96 30 92 Z" fill="#B89DD9" opacity="0.85" />
      <path d="M170 96 Q166 90 170 86 Q174 84 174 89 Q174 84 178 86 Q182 90 178 96 Q174 100 170 96 Z" fill="#F4A57A" opacity="0.85" />
    </g>
  </svg>
);

/* ============================================================
   POSE 06 — SURPRISED  (mane flared, ears straight up, mouth O)
   ============================================================ */

const PoseSurprised = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — surprised">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBackFlared id={id} />
    <Body id={id} />
    {/* hooves up at chest level */}
    <g>
      <ellipse cx="62" cy="158" rx="8" ry="5" fill="#7E5BA0" transform="rotate(-10 62 158)" />
      <ellipse cx="62" cy="158" rx="5" ry="2.5" fill="#B89DD9" opacity="0.7" />
      <ellipse cx="138" cy="158" rx="8" ry="5" fill="#7E5BA0" transform="rotate(10 138 158)" />
      <ellipse cx="138" cy="158" rx="5" ry="2.5" fill="#B89DD9" opacity="0.7" />
    </g>
    <Hoof cx={84} cy={206} />
    <Hoof cx={116} cy={206} />
    <HeadBase id={id} />
    <Horn id={id} />
    <EarsStraight id={id} />
    <EyeWide cx={80} cy={116} />
    <EyeWide cx={120} cy={116} />
    <Lashes cx={80} cy={116} />
    <Lashes cx={120} cy={116} />
    <g stroke="#5C1E3A" strokeWidth="2.2" strokeLinecap="round" fill="none">
      <path d="M70 92 Q78 88 86 92" />
      <path d="M130 92 Q122 88 114 92" />
    </g>
    <Cheeks id={id} />
    <Muzzle />
    <MouthO cy={152} ry={4} />
    {/* "!" sparkle */}
    <g transform="translate(170 38)" className="anim-shimmer-soft">
      <path d="M0 0 L2 14 L-2 14 Z" fill="#E8B651" />
      <circle cx="0" cy="18" r="2" fill="#E8B651" />
    </g>
    {/* burst marks */}
    <g stroke="#B89DD9" strokeWidth="2" strokeLinecap="round" fill="none">
      <path d="M40 28 L46 34" />
      <path d="M154 28 L148 34" />
    </g>
  </svg>
);

/* ============================================================
   POSE 07 — PROUD  (chest puffed, head high, horn glowing softly)
   ============================================================ */

const PoseProud = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — proud">
    <KaylinDefs id={id} />
    <Shadow id={id} rx={58} />
    <ManeBack id={id} />
    <g transform="rotate(-3 100 178)">
      <Body id={id} />
    </g>
    <Hoof cx={80} cy={204} />
    <Hoof cx={120} cy={204} />
    {/* head tilted back/up, horn glowing */}
    <g transform="rotate(-6 100 110)">
      <HeadBase id={id} />
      <Horn id={id} glow />
      <EarsRelaxed id={id} />
      <EyeSmug cx={80} cy={117} />
      <EyeSmug cx={120} cy={117} />
      <Cheeks id={id} />
      <Muzzle />
      <path d="M92 150 Q100 156 108 150" stroke="#2C2B36" strokeWidth="1.7" fill="none" strokeLinecap="round" />
    </g>
    {/* additional glow sparkles around horn */}
    <g fill="#E8B651" className="anim-shimmer-soft">
      <path d="M70 32 L71 35 L74 36 L71 37 L70 40 L69 37 L66 36 L69 35 Z" />
      <path d="M130 26 L131 29 L134 30 L131 31 L130 34 L129 31 L126 30 L129 29 Z" />
      <path d="M124 50 L125 52 L127 53 L125 54 L124 56 L123 54 L121 53 L123 52 Z" />
    </g>
  </svg>
);

/* ============================================================
   POSE 08 — SLEEPY  (mane resting, half eyes, soft yawn)
   ============================================================ */

const PoseSleepy = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — sleepy">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBackResting id={id} />
    <Body id={id} />
    <Hoof cx={78} />
    {/* right hoof to mouth */}
    <g>
      <path d="M118 158 Q124 144 130 134 Q136 138 132 148 Q128 158 122 168 Z" fill={`url(#${id}-body)`} />
      <ellipse cx="128" cy="138" rx="7" ry="5" fill="#7E5BA0" transform="rotate(-25 128 138)" />
      <ellipse cx="128" cy="138" rx="4.5" ry="2.5" fill="#B89DD9" opacity="0.7" transform="rotate(-25 128 138)" />
    </g>
    <g transform="translate(0 4) rotate(5 100 112)">
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsDrooped id={id} />
      <EyeSleepy cx={80} cy={118} />
      <EyeSleepy cx={120} cy={118} />
      <Cheeks id={id} />
      <Muzzle />
      <MouthYawn />
    </g>
    {/* Z's */}
    <g fontFamily="Fredoka, sans-serif" fontWeight="700">
      <text x="158" y="64" fontSize="22" fill="#B89DD9">Z</text>
      <text x="178" y="46" fontSize="16" fill="#B89DD9" opacity="0.7">Z</text>
      <text x="190" y="32" fontSize="11" fill="#B89DD9" opacity="0.5">z</text>
    </g>
  </svg>
);

/* ============================================================
   POSE 09 — DETERMINED  (head tipped forward, horn pointed forward, V-brow)
   ============================================================ */

const PoseDetermined = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — determined">
    <KaylinDefs id={id} />
    <Shadow id={id} rx={58} />
    <ManeBack id={id} />
    <g transform="rotate(4 100 178)">
      <Body id={id} />
    </g>
    <Hoof cx={80} />
    {/* fist hoof raised */}
    <g>
      <path d="M120 166 Q126 152 128 140 Q134 142 132 154 Q130 166 128 174 Z" fill={`url(#${id}-body)`} />
      <circle cx="128" cy="136" r="8" fill="#7E5BA0" />
      <circle cx="128" cy="136" r="5.5" fill="#B89DD9" opacity="0.55" />
      <path d="M124 132 L132 132" stroke="#3F2C57" strokeWidth="1" opacity="0.7" />
    </g>
    {/* head tipped forward so horn points forward-down */}
    <g transform="rotate(8 100 108)">
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsRelaxed id={id} />
      <EyeFocused cx={80} cy={118} />
      <EyeFocused cx={120} cy={118} />
      <BrowDetermined />
      <Cheeks id={id} />
      <Muzzle />
      <MouthSet />
    </g>
    {/* motion lines */}
    <g stroke="#B89DD9" strokeWidth="2" strokeLinecap="round" fill="none">
      <path d="M22 90 L30 88" />
      <path d="M24 110 L32 110" />
      <path d="M22 130 L30 132" />
      <path d="M178 90 L170 88" />
      <path d="M176 110 L168 110" />
      <path d="M178 130 L170 132" />
    </g>
  </svg>
);

/* ============================================================
   POSE 10 — MISCHIEVOUS  (sly smile, raised brow, eye glint, heart)
   ============================================================ */

const PoseMischievous = ({ id }) => (
  <svg viewBox="0 0 200 220" className="w-full h-full block" aria-label="Kaylin — mischievous">
    <KaylinDefs id={id} />
    <Shadow id={id} />
    <ManeBack id={id} />
    <Body id={id} />
    <Hoof cx={80} />
    <g>
      <ellipse cx="128" cy="184" rx="8" ry="5" fill="#7E5BA0" transform="rotate(15 128 184)" />
      <ellipse cx="128" cy="184" rx="5" ry="2.5" fill="#B89DD9" opacity="0.7" transform="rotate(15 128 184)" />
    </g>
    <Hoof cx={120} />
    <g transform="rotate(-6 100 108)">
      <HeadBase id={id} />
      <Horn id={id} />
      <EarsRelaxed id={id} />
      {/* left eye smug + closed-ish */}
      <EyeSmug cx={80} cy={117} dir={1} />
      {/* right eye open + star glint */}
      <g>
        <ellipse cx="120" cy="116" rx="8" ry="11" fill="#2C2B36" />
        <ellipse cx="120" cy="118" rx="4" ry="6" fill="#B89DD9" />
        <ellipse cx="120" cy="118" rx="3" ry="4" fill="#D5B8E8" opacity="0.55" />
        <ellipse cx="120" cy="119" rx="1.8" ry="3" fill="#2C2B36" />
        {/* star glint */}
        <g transform="translate(124 111)">
          <path d="M0 -4 L1.2 -1.2 L4 0 L1.2 1.2 L0 4 L-1.2 1.2 L-4 0 L-1.2 -1.2 Z" fill="#FFFFFF" />
        </g>
      </g>
      <Lashes cx={120} cy={116} />
      <BrowMisch />
      <Cheeks id={id} />
      <Muzzle />
      <MouthSly />
    </g>
    {/* floating heart */}
    <g className="anim-shimmer-soft">
      <path d="M40 50 Q34 42 40 36 Q46 32 46 40 Q46 32 52 36 Q58 42 52 50 Q46 56 40 50 Z" fill="#E07AA0" />
      <ellipse cx="44" cy="40" rx="2" ry="3" fill="#FFFFFF" opacity="0.45" />
    </g>
  </svg>
);

/* ============================================================
   GRID + WRAPPER COMPONENT (default export)
   ============================================================ */

const POSES = [
  { id: "idle",        name: "Idle",        caption: "Default home / lobby pose",         Pose: PoseIdle },
  { id: "curious",     name: "Curious",     caption: "Use when a new prompt appears",     Pose: PoseCurious },
  { id: "thinking",    name: "Thinking",    caption: "Use during answer-pending",         Pose: PoseThinking },
  { id: "encouraging", name: "Encouraging", caption: "Use on wrong answer / retry",       Pose: PoseEncouraging },
  { id: "cheering",    name: "Cheering",    caption: "Use on correct answer",             Pose: PoseCheering },
  { id: "surprised",   name: "Surprised",   caption: "Use on streak-3 reveal",            Pose: PoseSurprised },
  { id: "proud",       name: "Proud",       caption: "Use on level-up",                   Pose: PoseProud },
  { id: "sleepy",      name: "Sleepy",      caption: "Use on app idle / come-back",       Pose: PoseSleepy },
  { id: "determined",  name: "Determined",  caption: "Use on hard problem intro",         Pose: PoseDetermined },
  { id: "mischievous", name: "Mischievous", caption: "Use on unlock / easter egg",        Pose: PoseMischievous },
];

function KaylinExpressions() {
  return (
    <div className="min-h-screen px-4 sm:px-8 lg:px-12 py-8 sm:py-12 max-w-[1320px] mx-auto">
      <header className="mb-8 sm:mb-12">
        <div className="flex items-start gap-2 text-[11px] uppercase tracking-[0.22em] font-semibold text-copper">
          <span className="inline-block w-6 h-px bg-copper mt-2" />
          <span>Character expression sheet</span>
        </div>
        <h1 className="font-display text-walnut mt-3 leading-[0.95] text-[40px] sm:text-[60px] lg:text-[72px] tracking-tight max-w-[16ch]">
          <span className="italic font-medium">Kaylin,</span>{" "}
          <span className="font-semibold">in ten moods.</span>
        </h1>
        <p className="font-display italic text-walnut-2 text-[15px] sm:text-[19px] mt-4 max-w-[60ch] leading-snug">
          Same silhouette, horn, mane style, hoof shape, and lilac iris throughout &mdash; only emotion
          and body language change. Drop these into any of Kaylin&rsquo;s 3rd-grade games as reaction art.
        </p>
        <div className="flex flex-wrap gap-2 mt-5">
          <span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-kaylin-bg ring-1 ring-kaylin-lilac/40 text-[11px] font-semibold text-kaylin-deep">
            <span className="w-1.5 h-1.5 rounded-full bg-kaylin-lilac" />
            3rd Grade · age 8
          </span>
          <span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-cream ring-1 ring-walnut/15 text-[11px] font-semibold text-walnut-2">
            Peach Sorbet palette
          </span>
          <span className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full bg-cream ring-1 ring-walnut/15 text-[11px] font-semibold text-walnut-2">
            10 / 10 poses
          </span>
        </div>
      </header>

      <div className="grid grid-cols-2 lg:grid-cols-5 gap-3 sm:gap-4">
        {POSES.map((p, i) => (
          <article
            key={p.id}
            className="rounded-[18px] bg-cream paper-grain ring-1 ring-walnut/15 shadow-lift overflow-hidden flex flex-col"
          >
            <div className="relative">
              <div className="aspect-square p-2 sm:p-3">
                <p.Pose id={`k-${p.id}`} />
              </div>
              <div className="absolute top-2 left-2 inline-flex items-center justify-center w-6 h-6 rounded-full bg-walnut text-cream text-[10px] font-semibold font-kid tracking-wider">
                {String(i + 1).padStart(2, "0")}
              </div>
            </div>
            <div className="px-3 sm:px-4 pb-3 sm:pb-4 pt-2 sm:pt-3 border-t border-walnut/10">
              <div className="font-display italic font-semibold text-walnut text-[18px] sm:text-[20px] leading-tight">
                {p.name}
              </div>
              <div className="font-kid text-[11px] sm:text-[12px] text-walnut-3 mt-1 leading-snug">
                {p.caption}
              </div>
            </div>
          </article>
        ))}
      </div>

      <footer className="mt-12 pt-6 border-t border-walnut/10 flex flex-wrap items-baseline justify-between gap-4 text-[12px] font-medium text-walnut-3">
        <p className="font-display italic text-walnut-2 text-[14px]">
          &ldquo;A pattern is a promise the world keeps.&rdquo;
        </p>
        <span>Cammy &amp; Caris Learning Club &middot; Kaylin expression sheet</span>
      </footer>
    </div>
  );
}

window.KaylinExpressions = KaylinExpressions;

// === HUSSL drop-in: expose every pose as named component on window ===
window.KaylinPoses = {
  idle:        PoseIdle,
  curious:     PoseCurious,
  thinking:    PoseThinking,
  encouraging: PoseEncouraging,
  cheering:    PoseCheering,
  surprised:   PoseSurprised,
  proud:       PoseProud,
  sleepy:      PoseSleepy,
  determined:  PoseDetermined,
  mischievous: PoseMischievous,
};
