
// cozy-shapes.jsx — Decorative SVG primitives for the cozy-rift theme.
//
// All shapes are ORIGINAL designs (not derived from any branded IP):
//  - HexFrame      : generic hexagonal clip used for avatars / colour swatches.
//  - PawMascot     : hooded summoner emblem (front-facing silhouette w/ glowing eyes).
//  - PawPrint      : three-slash claw mark sigil.
//  - CrystalSparkle: faceted 4-point gem star.
//  - LaurelCrest   : sword-and-shield "owned by" crest.
//  - WyrmSilhouette: fanged, winged dragon, decorative only.
//  - RuneGlyph     : carved-stone angular runes.
//  - RoleSilhouette: stylised fantasy archetypes (Vanguard/Stalker/Mage/Marksman/Warden).
//
// Naming kept from the previous "cozy critter" pass for back-compat with screens
// that already import window.PawMascot / window.PawPrint, but the artwork is now
// a more mature/RPG aesthetic.

const hexClip = 'polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)';

// -----------------------------------------------------------------------------
// HexFrame — geometric hex container for avatars, swatches, lobby badges
// -----------------------------------------------------------------------------
function HexFrame({ size = 56, color = '#F7DFA0', borderColor = '#C4845A', borderWidth = 2.5, children, glow = false, style = {} }) {
  return (
    <div style={{
      position: 'relative',
      width: size, height: size,
      display: 'inline-flex', alignItems: 'center', justifyContent: 'center',
      flexShrink: 0,
      filter: glow ? `drop-shadow(0 0 8px ${borderColor}80)` : 'none',
      ...style,
    }}>
      {/* outer border hex */}
      <div style={{
        position: 'absolute', inset: 0,
        background: borderColor,
        clipPath: hexClip,
      }} />
      {/* inner fill hex */}
      <div style={{
        position: 'absolute',
        inset: borderWidth,
        background: color,
        clipPath: hexClip,
      }} />
      {/* content */}
      <div style={{ position: 'relative', zIndex: 1, display: 'flex', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100%' }}>
        {children}
      </div>
    </div>
  );
}

// -----------------------------------------------------------------------------
// PawMascot — hooded summoner emblem (front-on silhouette, glowing crystal eyes)
// Original design; reads as a mysterious RPG-guild avatar.
// -----------------------------------------------------------------------------
function PawMascot({ size = 32, color = '#C4845A', accent = '#F7DFA0', gem = '#C5B4E3', style = {} }) {
  return (
    <svg viewBox="0 0 32 32" width={size} height={size} style={{ display: 'inline-block', verticalAlign: 'middle', ...style }}>
      {/* cloak shoulders */}
      <path d="M3 30 L5 22 Q8 19 12 19 L20 19 Q24 19 27 22 L29 30 Z" fill={color} />
      {/* hood outer */}
      <path d="M16 3 C9.5 3 5 8 5 15 L5 21 Q8 24 16 24 Q24 24 27 21 L27 15 C27 8 22.5 3 16 3 Z" fill={color} />
      {/* hood point */}
      <path d="M16 2 L17.6 6 L14.4 6 Z" fill={color} />
      {/* face shadow */}
      <path d="M16 8.5 C12 8.5 9.5 11 9.5 14.5 L9.5 19 Q10 21 16 21 Q22 21 22.5 19 L22.5 14.5 C22.5 11 20 8.5 16 8.5 Z" fill="#2A1F18" opacity="0.78" />
      {/* hood inner rim shadow */}
      <path d="M9.5 14 Q16 11.5 22.5 14" stroke="#2A1F18" strokeWidth="0.9" fill="none" opacity="0.5" />
      {/* glowing crystal eyes */}
      <ellipse cx="13" cy="15.6" rx="1.1" ry="1.5" fill={accent} />
      <ellipse cx="19" cy="15.6" rx="1.1" ry="1.5" fill={accent} />
      <ellipse cx="13" cy="15" rx="0.4" ry="0.6" fill="#FFFAF3" opacity="0.9" />
      <ellipse cx="19" cy="15" rx="0.4" ry="0.6" fill="#FFFAF3" opacity="0.9" />
      {/* forehead gem */}
      <path d="M16 5.4 L17.1 7.2 L16 9 L14.9 7.2 Z" fill={gem} />
      <path d="M16 5.4 L17.1 7.2 L16 7.4 Z" fill="#FFFAF3" opacity="0.6" />
      {/* clasp at neck */}
      <circle cx="16" cy="22.5" r="1.4" fill={gem} />
      <circle cx="16" cy="22.5" r="0.5" fill="#FFFAF3" opacity="0.8" />
    </svg>
  );
}

// -----------------------------------------------------------------------------
// PawPrint — three-slash claw mark sigil (was: cute paw print)
// -----------------------------------------------------------------------------
function PawPrint({ size = 18, color = '#C4845A', style = {} }) {
  return (
    <svg viewBox="0 0 24 24" width={size} height={size} style={{ display: 'inline-block', verticalAlign: 'middle', ...style }}>
      <path d="M6  20 Q4  10 9  3"  stroke={color} strokeWidth="2.6" fill="none" strokeLinecap="round" />
      <path d="M12 22 Q11 10 14 2"  stroke={color} strokeWidth="2.6" fill="none" strokeLinecap="round" />
      <path d="M18 20 Q20 10 17 3"  stroke={color} strokeWidth="2.6" fill="none" strokeLinecap="round" />
    </svg>
  );
}

// -----------------------------------------------------------------------------
// CrystalSparkle — 4-point gem with facet highlight
// -----------------------------------------------------------------------------
function CrystalSparkle({ size = 14, color = '#C4845A', style = {} }) {
  return (
    <svg viewBox="0 0 20 20" width={size} height={size} style={{ display: 'inline-block', verticalAlign: 'middle', ...style }}>
      <path d="M10 1 L11.6 8.4 L19 10 L11.6 11.6 L10 19 L8.4 11.6 L1 10 L8.4 8.4 Z" fill={color} />
      {/* inner facet */}
      <path d="M10 3.5 L11 8.8 L10 10 L9 8.8 Z" fill="#FFFAF3" opacity="0.55" />
      <path d="M10 10 L11 11.2 L10 16.5 L9 11.2 Z" fill="#000" opacity="0.12" />
    </svg>
  );
}

// -----------------------------------------------------------------------------
// LaurelCrest — sword-and-shield crest (was: laurel/star).
// Keeps the same export name; reads more knightly / RPG-guild.
// -----------------------------------------------------------------------------
function LaurelCrest({ size = 22, color = '#7CBF8E', style = {} }) {
  return (
    <svg viewBox="0 0 24 24" width={size} height={size} style={{ display: 'inline-block', verticalAlign: 'middle', ...style }}>
      {/* shield silhouette */}
      <path d="M12 2.5 L20 5.5 L20 13 C20 17.5 16.5 20.5 12 22 C7.5 20.5 4 17.5 4 13 L4 5.5 Z" fill={color} stroke="#4A372830" strokeWidth="0.6" />
      {/* shield highlight */}
      <path d="M12 2.5 L20 5.5 L20 9 C16 8 12 8 8 9 L4 9 L4 5.5 Z" fill="#FFFAF3" opacity="0.18" />
      {/* sword blade */}
      <rect x="11.4" y="5.8" width="1.2" height="11" fill="#FFFAF3" />
      {/* sword point */}
      <path d="M11.4 16.8 L12.6 16.8 L12 18.2 Z" fill="#FFFAF3" />
      {/* crossguard */}
      <rect x="9" y="10" width="6" height="1.4" rx="0.3" fill="#FFFAF3" />
      {/* pommel */}
      <circle cx="12" cy="5.4" r="1" fill="#FFFAF3" />
      <circle cx="12" cy="5.4" r="0.4" fill={color} opacity="0.5" />
    </svg>
  );
}

// -----------------------------------------------------------------------------
// WyrmSilhouette — fanged winged dragon, decorative background only
// -----------------------------------------------------------------------------
function WyrmSilhouette({ size = 220, color = '#C4845A', opacity = 0.08, style = {} }) {
  return (
    <svg viewBox="0 0 200 140" width={size} height={size * 0.7} style={{ display: 'block', opacity, ...style }}>
      {/* body / curl */}
      <path d="M30 95
               Q18 65 50 53
               Q72 47 92 60
               Q112 50 132 60
               Q152 55 172 70
               L188 65
               L182 78
               Q170 65 150 75
               Q130 85 110 78
               Q90 82 75 92
               Q60 100 55 118
               L40 112
               Q32 102 30 95 Z" fill={color} />
      {/* large wing */}
      <path d="M90 60 Q92 22 130 28 Q150 33 148 55 Q126 50 110 68 Z" fill={color} />
      <path d="M100 58 L122 35 M110 58 L132 42 M118 60 L138 48" stroke="#FFFAF3" strokeWidth="0.9" opacity="0.28" />
      {/* back spines */}
      <path d="M60 67 L62 58 L70 62 Z" fill={color} />
      <path d="M76 64 L78 56 L86 60 Z" fill={color} />
      <path d="M152 68 L154 60 L162 64 Z" fill={color} />
      {/* head: pointed jaw + horn */}
      <path d="M188 65 L196 60 L194 70 L186 72 Z" fill={color} />
      <path d="M192 60 L196 52 L198 60 Z" fill={color} />
      {/* fangs */}
      <path d="M190 70 L191 74 L192 70 Z" fill="#FFFAF3" />
      <path d="M193 70 L194 73 L195 70 Z" fill="#FFFAF3" />
      {/* eye */}
      <circle cx="190" cy="64" r="1" fill="#FFFAF3" />
      {/* tail */}
      <path d="M40 112 L34 122 L48 118 Z" fill={color} />
      <path d="M48 118 L42 128 L56 122 Z" fill={color} />
    </svg>
  );
}

// -----------------------------------------------------------------------------
// RuneGlyph — angular carved-stone runes (4 variants)
// -----------------------------------------------------------------------------
function RuneGlyph({ variant = 0, size = 24, color = '#C4845A', style = {} }) {
  const paths = [
    // 0: anchored trinity — triangle with anchor stem
    <g key="0">
      <path d="M12 3 L21 19 L3 19 Z" stroke={color} strokeWidth="2" fill="none" strokeLinejoin="round" />
      <path d="M12 9 L12 21" stroke={color} strokeWidth="2" strokeLinecap="round" />
      <circle cx="12" cy="9" r="1.6" fill={color} />
    </g>,
    // 1: zigzag bolt rune (lightning sigil)
    <g key="1">
      <path d="M8 3 L8 11 L4 11 L14 21 L14 13 L18 13 L8 3 Z" stroke={color} strokeWidth="1.8" fill={color} fillOpacity="0.35" strokeLinejoin="round" />
    </g>,
    // 2: framed diamond — gem rune
    <g key="2">
      <path d="M12 2 L22 12 L12 22 L2 12 Z" stroke={color} strokeWidth="1.8" fill="none" strokeLinejoin="round" />
      <path d="M12 7 L17 12 L12 17 L7 12 Z" stroke={color} strokeWidth="1.4" fill={color} fillOpacity="0.4" />
      <circle cx="12" cy="12" r="1.4" fill={color} />
    </g>,
    // 3: forked rune (algiz-style)
    <g key="3">
      <path d="M12 22 L12 6 M12 6 L5 13 M12 6 L19 13 M12 10 L7 5 M12 10 L17 5" stroke={color} strokeWidth="2" fill="none" strokeLinecap="round" />
    </g>,
  ];
  return (
    <svg viewBox="0 0 24 24" width={size} height={size} style={{ display: 'inline-block', ...style }}>
      {paths[variant % paths.length]}
    </svg>
  );
}

// -----------------------------------------------------------------------------
// RoleSilhouette — stylised fantasy archetype emblems (refined, more game-art)
// -----------------------------------------------------------------------------
function RoleSilhouette({ archetype, size = 28, color = '#4A3728', style = {} }) {
  const s = { width: size, height: size, display: 'inline-block', flexShrink: 0, ...style };
  switch (archetype) {
    case 'vanguard': // Plated knight w/ horned helm = TOP
      return (
        <svg viewBox="0 0 32 32" style={s}>
          {/* horned helm */}
          <path d="M16 4 C11 4 8 7 8 12 L8 15 L7 17 L25 17 L24 15 L24 12 C24 7 21 4 16 4 Z" fill={color} />
          {/* horns */}
          <path d="M8 8 L5 4 L9 7 Z" fill={color} />
          <path d="M24 8 L27 4 L23 7 Z" fill={color} />
          {/* visor slit */}
          <rect x="11" y="11" width="10" height="2.2" rx="0.8" fill="#FFFAF3" opacity="0.55" />
          {/* breastplate */}
          <path d="M8 17 L24 17 L25 27 L20 30 L12 30 L7 27 Z" fill={color} />
          {/* center crest */}
          <path d="M16 19 L17.5 23 L16 28 L14.5 23 Z" fill="#FFFAF3" opacity="0.5" />
        </svg>
      );
    case 'stalker': // Hooded ranger w/ blades = JUNGLE
      return (
        <svg viewBox="0 0 32 32" style={s}>
          {/* hood */}
          <path d="M16 3 C10 3 6 7 6 14 L6 22 L26 22 L26 14 C26 7 22 3 16 3 Z" fill={color} />
          {/* face shadow */}
          <path d="M11 11 L21 11 L21 17 Q16 19 11 17 Z" fill="#FFFAF3" opacity="0.15" />
          {/* glowing eyes */}
          <circle cx="13" cy="14" r="1.1" fill="#B8E0C0" />
          <circle cx="19" cy="14" r="1.1" fill="#B8E0C0" />
          {/* body */}
          <path d="M10 22 L22 22 L23 30 L9 30 Z" fill={color} />
          {/* crossed daggers */}
          <path d="M5 26 L13 22 L13.5 23 L5.5 27 Z" fill={color} />
          <path d="M27 26 L19 22 L18.5 23 L26.5 27 Z" fill={color} />
        </svg>
      );
    case 'mage': // Robed mage with staff + sigil = MID
      return (
        <svg viewBox="0 0 32 32" style={s}>
          {/* pointed hat */}
          <path d="M16 2 L11 12 L21 12 Z" fill={color} />
          {/* hat band */}
          <rect x="11" y="11" width="10" height="1.6" fill="#FFFAF3" opacity="0.4" />
          {/* hat star */}
          <path d="M16 5 L16.6 7 L18.5 7 L17 8.2 L17.6 10 L16 8.8 L14.4 10 L15 8.2 L13.5 7 L15.4 7 Z" fill="#C5B4E3" />
          {/* robed body */}
          <path d="M10 13 L22 13 L25 30 L7 30 Z" fill={color} />
          {/* robe collar */}
          <path d="M13 13 L19 13 L17 17 L15 17 Z" fill="#FFFAF3" opacity="0.3" />
          {/* staff */}
          <rect x="3" y="10" width="1.4" height="20" fill={color} />
          <circle cx="3.7" cy="9" r="2.4" fill="#C5B4E3" />
          <circle cx="3.7" cy="9" r="1" fill="#FFFAF3" opacity="0.7" />
        </svg>
      );
    case 'marksman': // Archer drawing a bow = ADC
      return (
        <svg viewBox="0 0 32 32" style={s}>
          {/* head w/ hair tie */}
          <circle cx="12" cy="7" r="3.4" fill={color} />
          <path d="M12 4 L15 3 L14 5 Z" fill={color} />
          {/* body */}
          <path d="M9 11 L17 11 L19 22 L16 22 L16 30 L10 30 L10 22 L7 22 Z" fill={color} />
          {/* drawn bow */}
          <path d="M23 4 Q31 16 23 28" stroke={color} strokeWidth="2" fill="none" strokeLinecap="round" />
          <path d="M23 4 L23 28" stroke={color} strokeWidth="1" />
          {/* arrow */}
          <path d="M14 16 L26 16" stroke={color} strokeWidth="1.4" />
          <path d="M26 16 L23 14 L23 18 Z" fill={color} />
          {/* fletching */}
          <path d="M14 16 L11 14 L12 16 L11 18 Z" fill={color} />
        </svg>
      );
    case 'warden': // Caped warden with lantern + glaive = SUPPORT
      return (
        <svg viewBox="0 0 32 32" style={s}>
          {/* cape */}
          <path d="M9 11 L19 11 L22 30 L6 30 Z" fill={color} opacity="0.55" />
          {/* head + circlet */}
          <circle cx="13" cy="7" r="3.4" fill={color} />
          <path d="M9.5 5.5 L16.5 5.5" stroke="#F7DFA0" strokeWidth="1.2" />
          <circle cx="13" cy="5.5" r="0.9" fill="#F7DFA0" />
          {/* body */}
          <path d="M10 11 L17 11 L18 22 L15 22 L15 30 L11 30 L11 22 L9 22 Z" fill={color} />
          {/* lantern hanging */}
          <rect x="21" y="14" width="6" height="7" rx="0.8" fill={color} />
          <rect x="22" y="15" width="4" height="5" fill="#F7DFA0" />
          <circle cx="24" cy="17.5" r="1" fill="#FFFAF3" opacity="0.85" />
          <path d="M24 14 L24 11 L20 11 M24 11 L28 11" stroke={color} strokeWidth="1.2" />
        </svg>
      );
    default:
      return null;
  }
}

const ARCHETYPE_BY_POSITION = {
  TOP: 'vanguard',
  JUNGLE: 'stalker',
  MID: 'mage',
  ADC: 'marksman',
  SUPPORT: 'warden',
};

Object.assign(window, {
  HexFrame, PawMascot, PawPrint, CrystalSparkle, LaurelCrest,
  WyrmSilhouette, RuneGlyph, RoleSilhouette, ARCHETYPE_BY_POSITION, hexClip,
});
