/* global React */
// Hand-drawn illustration accents for the Garden direction.
// All SVG, all hand-feel: imperfect lines, organic curves.

const Sprout = ({ size = 80, color = "var(--sprout)", accent = "var(--sun)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    <path d="M 40 72 L 40 36" stroke={color} strokeWidth="1.8" fill="none" strokeLinecap="round" />
    <path d="M 40 48 Q 22 44, 18 24 Q 36 22, 40 42" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <path d="M 40 42 Q 50 18, 66 18 Q 64 38, 40 46" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <circle cx="40" cy="32" r="3.5" fill={accent} />
  </svg>
);

const Sun = ({ size = 80, color = "var(--sun)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    <circle cx="40" cy="40" r="18" fill="none" stroke={color} strokeWidth="1.8" />
    <g stroke={color} strokeWidth="1.6" strokeLinecap="round">
      <line x1="40" y1="10" x2="40" y2="2" />
      <line x1="40" y1="78" x2="40" y2="70" />
      <line x1="10" y1="40" x2="2" y2="40" />
      <line x1="78" y1="40" x2="70" y2="40" />
      <line x1="18" y1="18" x2="13" y2="13" />
      <line x1="62" y1="18" x2="67" y2="13" />
      <line x1="18" y1="62" x2="13" y2="67" />
      <line x1="62" y1="62" x2="67" y2="67" />
    </g>
  </svg>
);

const House = ({ size = 80, color = "var(--sprout)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    <path d="M 12 68 L 12 36 L 40 14 L 68 36 L 68 68 Z" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <path d="M 32 68 L 32 48 L 48 48 L 48 68" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <path d="M 8 38 L 40 12 L 72 38" fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" strokeLinecap="round" />
  </svg>
);

const Heart = ({ size = 80, color = "var(--sun)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    <path
      d="M 40 66 C 14 48, 14 22, 28 22 C 34 22, 40 28, 40 34 C 40 28, 46 22, 52 22 C 66 22, 66 48, 40 66 Z"
      fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round"
    />
  </svg>
);

const Compass = ({ size = 80, color = "var(--sprout)", accent = "var(--sun)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    <circle cx="40" cy="40" r="28" fill="none" stroke={color} strokeWidth="1.8" />
    <path d="M 40 18 L 46 40 L 40 62 L 34 40 Z" fill={accent} stroke={color} strokeWidth="1.4" strokeLinejoin="round" />
    <circle cx="40" cy="40" r="2" fill={color} />
  </svg>
);

const Book = ({ size = 80, color = "var(--sprout)", accent = "var(--sun)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    {/* open book — two pages curving outward from a central spine */}
    <path d="M 12 28 Q 26 24, 40 30 Q 54 24, 68 28 L 68 62 Q 54 58, 40 64 Q 26 58, 12 62 Z"
      fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <path d="M 40 30 L 40 64" stroke={color} strokeWidth="1.6" fill="none" strokeLinecap="round" />
    {/* faint text lines on each page */}
    <g stroke={color} strokeWidth="1.3" strokeLinecap="round" opacity="0.5" fill="none">
      <path d="M 18 40 L 34 40" />
      <path d="M 18 46 L 34 46" />
      <path d="M 18 52 L 30 52" />
      <path d="M 46 40 L 62 40" />
      <path d="M 46 46 L 62 46" />
      <path d="M 46 52 L 58 52" />
    </g>
    {/* small spark above — curiosity / insight */}
    <circle cx="40" cy="16" r="2.8" fill={accent} />
  </svg>
);

const Hands = ({ size = 80, color = "var(--sprout)" }) => (
  <svg width={size} height={size} viewBox="0 0 80 80" style={{ overflow: "visible" }}>
    {/* two cupped hands holding something */}
    <path d="M 12 50 Q 18 38, 30 40 Q 36 32, 40 40 Q 44 32, 50 40 Q 62 38, 68 50 Q 64 64, 40 64 Q 16 64, 12 50 Z"
      fill="none" stroke={color} strokeWidth="1.8" strokeLinejoin="round" />
    <circle cx="40" cy="28" r="6" fill="none" stroke="var(--sun)" strokeWidth="1.8" />
  </svg>
);

// A border of small hand-drawn marks — for section breaks
const GardenStrip = ({ width = 800, color = "var(--sprout-2)" }) => {
  const items = [];
  const step = 60;
  const count = Math.floor(width / step);
  for (let i = 0; i < count; i++) {
    const x = i * step + 30;
    const variant = i % 4;
    if (variant === 0) {
      items.push(<g key={i} transform={`translate(${x},10)`}>
        <path d="M 0 16 L 0 4 M -4 8 L 0 6 M 4 8 L 0 6" stroke={color} strokeWidth="1.2" fill="none" strokeLinecap="round" />
      </g>);
    } else if (variant === 1) {
      items.push(<circle key={i} cx={x} cy={10} r="2.5" fill={color} />);
    } else if (variant === 2) {
      items.push(<g key={i} transform={`translate(${x},10)`}>
        <path d="M 0 14 L 0 6 M -3 9 Q -6 6 -3 3" stroke={color} strokeWidth="1.2" fill="none" strokeLinecap="round" />
      </g>);
    } else {
      items.push(<g key={i} transform={`translate(${x},10)`}>
        <path d="M -4 14 Q 0 8 4 14" stroke={color} strokeWidth="1.2" fill="none" strokeLinecap="round" />
      </g>);
    }
  }
  return (
    <svg width={width} height={24} style={{ overflow: "visible", display: "block" }}>
      {items}
    </svg>
  );
};

// Ground line — horizontal undulating line, suggests landscape
const GroundLine = ({ width = 800, color = "var(--sprout-2)" }) => {
  let d = `M 0 12`;
  const segs = Math.floor(width / 40);
  for (let i = 1; i <= segs; i++) {
    const x = (width / segs) * i;
    const y = 12 + (i % 2 === 0 ? -3 : 3);
    d += ` Q ${x - width / segs / 2} ${y} ${x} 12`;
  }
  return (
    <svg width={width} height={24} style={{ display: "block", overflow: "visible" }}>
      <path d={d} fill="none" stroke={color} strokeWidth="1.4" strokeLinecap="round" />
    </svg>
  );
};

// Hero scene — a small garden in a row
const GardenScene = ({ width = 560, height = 240 }) => (
  <svg width={width} height={height} viewBox={`0 0 ${width} ${height}`} style={{ overflow: "visible", display: "block" }}>
    {/* sun */}
    <g transform={`translate(${width - 80}, 30)`}>
      <circle cx="0" cy="0" r="22" fill="none" stroke="var(--sun)" strokeWidth="1.6" />
      <g stroke="var(--sun)" strokeWidth="1.4" strokeLinecap="round">
        <line x1="0" y1="-30" x2="0" y2="-38" />
        <line x1="-30" y1="0" x2="-38" y2="0" />
        <line x1="30" y1="0" x2="38" y2="0" />
        <line x1="-21" y1="-21" x2="-27" y2="-27" />
        <line x1="21" y1="-21" x2="27" y2="-27" />
        <line x1="-21" y1="21" x2="-27" y2="27" />
        <line x1="21" y1="21" x2="27" y2="27" />
      </g>
    </g>

    {/* ground */}
    <path d={`M 0 ${height - 30} Q ${width / 4} ${height - 36} ${width / 2} ${height - 32} Q ${width * 0.75} ${height - 28} ${width} ${height - 32}`}
      fill="none" stroke="var(--sprout)" strokeWidth="1.5" strokeLinecap="round" />

    {/* main sprout (big) */}
    <g transform={`translate(${width / 2 - 30}, ${height - 32})`}>
      <path d="M 0 0 L 0 -90" stroke="var(--sprout)" strokeWidth="2" fill="none" strokeLinecap="round" />
      <path d="M 0 -50 Q -30 -52, -38 -78 Q -10 -82, 0 -64" fill="none" stroke="var(--sprout)" strokeWidth="2" strokeLinejoin="round" />
      <path d="M 0 -70 Q 18 -90, 40 -84 Q 38 -64, 0 -62" fill="none" stroke="var(--sprout)" strokeWidth="2" strokeLinejoin="round" />
      <circle cx="0" cy="-92" r="4.5" fill="var(--sun)" />
    </g>

    {/* small plants left */}
    <g transform={`translate(80, ${height - 32})`}>
      <path d="M 0 0 L 0 -36 M -8 -22 Q -12 -28 -8 -32 M 8 -22 Q 12 -28 8 -32" stroke="var(--sprout-2)" strokeWidth="1.5" fill="none" strokeLinecap="round" />
    </g>
    <g transform={`translate(140, ${height - 32})`}>
      <path d="M 0 0 L 0 -22 M -6 -14 L 0 -16 M 6 -14 L 0 -16" stroke="var(--sprout-2)" strokeWidth="1.4" fill="none" strokeLinecap="round" />
    </g>

    {/* small plants right */}
    <g transform={`translate(${width - 160}, ${height - 32})`}>
      <path d="M 0 0 L 0 -42 M -10 -22 Q -14 -30 -8 -36 M 10 -24 Q 14 -32 8 -36" stroke="var(--sprout-2)" strokeWidth="1.5" fill="none" strokeLinecap="round" />
      <circle cx="0" cy="-44" r="2.5" fill="var(--sun-2)" />
    </g>
    <g transform={`translate(${width - 100}, ${height - 32})`}>
      <path d="M 0 0 L 0 -28 M -7 -16 Q -10 -22 -6 -26 M 7 -16 Q 10 -22 6 -26" stroke="var(--sprout-2)" strokeWidth="1.4" fill="none" strokeLinecap="round" />
    </g>

    {/* tiny seeds dots in the soil */}
    <g fill="var(--ink-3)" opacity="0.5">
      <circle cx="40" cy={height - 22} r="1.2" />
      <circle cx="200" cy={height - 18} r="1.2" />
      <circle cx="320" cy={height - 22} r="1.2" />
      <circle cx="450" cy={height - 18} r="1.2" />
    </g>
  </svg>
);

window.GardenIllos = { Sprout, Sun, House, Heart, Compass, Hands, Book, GardenStrip, GroundLine, GardenScene };
