/* ============================================================
   Component Library — the atomic vocabulary
   Shows the 31 atomic elements grouped by category, using
   real screenshots from the actual design system.
   ============================================================ */

/* Inline SVG icons — rendered on dark background to match their actual context */
const ICON_SVGS = [
  {
    name: "Turn Right",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M5,21V10A4,4,0,0,1,9,6H19"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
        <polyline
          points="16 9 19 6 16 3"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
      </svg>
    ),
  },
  {
    name: "Turn Left",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M5,6H15a4,4,0,0,1,4,4V21"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
        <polyline
          points="8 3 5 6 8 9"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
      </svg>
    ),
  },
  {
    name: "Turn Around",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M18,21V7.5A4.49,4.49,0,0,0,13.5,3h0A4.49,4.49,0,0,0,9,7.5v7.4"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
        <path
          d="M6,12l2.86,2.86a.19.19,0,0,0,.28,0L12,12"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
      </svg>
    ),
  },
  {
    name: "Warning",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <circle
          cx="12"
          cy="12"
          r="10"
          fill="#E50013"
          stroke="#E50013"
          strokeWidth="2"
        />
        <line
          x1="12"
          y1="7"
          x2="12"
          y2="13"
          stroke="rgba(28,48,88,0.89)"
          strokeWidth="2"
          strokeLinecap="round"
        />
        <circle
          cx="12"
          cy="17"
          r="1"
          fill="rgba(28,48,88,0.89)"
          stroke="rgba(28,48,88,0.89)"
        />
      </svg>
    ),
  },
  {
    name: "Star",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M12 2 L14.9 8.5 L22 9.3 L16 14 L17.4 21 L12 17.8 L6.6 21 L8 14 L2 9.3 L9.1 8.5 Z"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
      </svg>
    ),
  },
  {
    name: "Flag",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M6 13.3 L7.21 13.84 A7.22 7.22 0 0 0 12.8 14 A5.17 5.17 0 0 1 17.03 14.18 L20.03 15.66 V5.38 L17.95 4.38 A7.18 7.18 0 0 0 12.08 4.14 A5.2 5.2 0 0 1 8 4 L6 3.11 V2 H4 V22 H6 Z"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
      </svg>
    ),
  },
  {
    name: "Leaves",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M12 21c5-1 8-5 7-10-3 2-7 3-9 7-2-4-6-6-9-7 1 5 4 9 9 10z"
          stroke="white"
          fill="white"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
      </svg>
    ),
  },
  {
    name: "Cloud",
    svg: (
      <svg
        viewBox="0 0 512 512"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M416.296 232.076c-0.042 0-0.079 0.009-0.121 0.009 0.056-1.594 0.121-3.187 0.121-4.79 0-76.646-62.131-138.771-138.763-138.771-71.785 0-130.854 54.521-138.03 124.419-10.066-3.113-20.755-4.791-31.842-4.791C48.207 208.152 0 256.354 0 315.814c0 59.46 48.207 107.662 107.662 107.662h308.634c52.852 0 95.704-42.842 95.704-95.695 0-52.862-42.852-95.705-95.704-95.705z"
          stroke="white"
          fill="white"
          strokeWidth="10"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
      </svg>
    ),
  },
  {
    name: "Calendar",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M3 9H21M17 13H7M10.33 17H7M7 3V5M17 3V5M6.2 21H17.8C18.92 21 19.48 21 19.91 20.78C20.28 20.59 20.59 20.28 20.78 19.91C21 19.48 21 18.92 21 17.8V8.2C21 7.08 21 6.52 20.78 6.09C20.59 5.72 20.28 5.41 19.91 5.22C19.48 5 18.92 5 17.8 5H6.2C5.08 5 4.52 5 4.09 5.22C3.72 5.41 3.41 5.72 3.22 6.09C3 6.52 3 7.08 3 8.2V17.8C3 18.92 3 19.48 3.22 19.91C3.41 20.28 3.72 20.59 4.09 20.78C4.52 21 5.08 21 6.2 21Z"
          stroke="white"
          fill="none"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="2"
        />
      </svg>
    ),
  },
  {
    name: "Accident",
    svg: (
      <svg
        viewBox="0 0 612 612"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M372.8,165.581l-50.3,65.9l32.2-76.9c0.8-4,4-6.3,6.3-6.3c0.8,0,1.5,0.8,3.1,1.5l4.7,2.3l4.7,2.3C377.6,156.981,376.8,160.781,372.8,165.581z M304.6,237.781l14.1-110.7c1.5-7.8-0.8-13.3-6.3-13.3H305.3c-1.5,0-8.6,0-8.6,0c-5.5,0-7.8,4.7-6.3,13.3L304.6,237.781z M324.2,357.781c4.7,11,6.3,18.101,6.3,28.2v91.8v12.601c0,4-3.1,7.8-7.8,7.8h-40.8c-4.7,0-7.8-3.101-7.8-7.8v-12.601v-13.3H56.6v13.3v12.601c0,4-3.1,7.8-7.8,7.8h-41c-4.7,0-7.8-3.101-7.8-7.8v-12.601v-91.8c0-10.3,1.5-18.1,6.3-28.2l51-106.7c5.5-12.6,21.2-22.7,35.3-22.7H237c14.1,0,29.9,10.3,36.2,22.7L324.2,357.781z M45.5,353.181H284l-34.5-73.7c-7.1-14.1-13.3-17.3-28.2-17.3h-113c-2.3,0-4,0-5.5,0c-11,1.5-16.5,5.5-21.9,17.3L45.5,353.181z M78.5,406.481c0-14.1-11.8-25.1-25.9-25.1s-25.1,11-25.1,25.1s11,25.9,25.1,25.9S78.5,420.681,78.5,406.481z M302.9,406.481c0-14.1-11.8-25.1-25.9-25.1s-25.1,11-25.1,25.1s11,25.9,25.1,25.9C291.1,432.481,302.9,420.681,302.9,406.481z M287.3,238.481l-32.2-76.9c-1.5-4-4-6.3-6.3-6.3c-0.8,0-1.5,0-2.3,0s-0.8,0.8-1.5,0.8l-4.7,2.3l-4,3.1c-4,2.3-3.1,6.3,0.8,11L287.3,238.481z M609.7,389.181l-23.601,88.7l-3.1,11.8c-0.8,4-5.5,6.3-9.4,5.5l-39.199-10.3c-4-0.801-6.301-5.5-5.5-9.4l3.1-11.8l4-12.601l-193.9-51.8v-14.899c0-6.301-0.8-13.301-2.3-19.601c10.3-0.8,19.601-7.8,22.7-18.899c4-13.301-4.7-27.4-18.1-31.4c-8.601-1.5-17.301,0.8-23.601,6.3l-18.1-37.7c0.8-0.8,1.5-2.3,2.3-3.1l76.9-89.5c7.1-8.6,18.899-13.3,29.899-14.1c4,0,7.101,0,10.3,0.8l137.4,35.3c14.1,4,26.7,18.1,29,31.4l21.9,116.2C612.9,371.881,612.2,379.881,609.7,389.181z M576,348.481l-14.9-80c-3.1-15.6-8.6-20.4-22.699-24.4l-109.101-29.9c-5.5-1.5-9.399-1.5-13.3-1.5c-6.3,0.8-11.8,4.7-18.1,11.8l-53.4,61.9L576,348.481z M561.1,373.581c-1.5-0.8-3.1-0.8-4.699-0.8c-1.601,0-3.101,0-4.7,0c-10.3,0.8-18.9,7.8-21.2,18.9c-4,13.3,4,27.399,17.3,31.399s27.4-4.699,31.4-18.1C583,391.481,574.5,377.381,561.1,373.581z"
          stroke="white"
          fill="white"
          strokeLinecap="round"
          strokeLinejoin="round"
          strokeWidth="1.5"
        />
      </svg>
    ),
  },
  {
    name: "Food",
    svg: (
      <svg
        viewBox="0 0 64 64"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M3.481 7.421c.24-.941.715-.011.715-.011s.166 9.74 1.246 9.846c1.08.106.248-10.022 1.526-10.216c1.188-.189.51 10.377 1.592 10.27c1.078-.114 1.26-9.85 1.26-9.85s.48-.929.717.005c2.928 11.51.559 16.215.559 16.215s-.4.989-1.35.994c-.089-.005-.022 27.336-.028 31.012c.002 1.787-5.5 1.732-5.497-.047c.004-3.676.111-31.014.025-31.012c-.953 0-1.352-.988-1.352-.988s-2.36-4.702.587-16.218"
          stroke="white"
          fill="white"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
        <path
          d="M55.62 7c1.238-.003 6.374 3.7 6.38 17.462c.006 4.401-2.395 4.4-2.391 7.153c.004 2.748.019 24.606.019 24.606s-2.634 1.807-4.592-.084L55 7.391c.002.001-.005-.392.62-.391"
          stroke="white"
          fill="white"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
        <path
          d="M32.749 46.92c8.648 0 15.674-6.633 15.973-14.92c-.299-8.287-7.325-14.92-15.973-14.92c-8.647 0-15.675 6.633-15.97 14.92c.294 8.287 7.322 14.92 15.97 14.92"
          stroke="white"
          fill="white"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
      </svg>
    ),
  },
  {
    name: "Gas Station",
    svg: (
      <svg
        viewBox="0 0 122.88 122.88"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M99.08 20.2c0.27 0.13 0.51 0.3 0.74 0.52 0.06 0.06 0.11 0.12 0.16 0.18 2.89 2.29 5.78 4.88 7.88 8 2.32 3.45 3.61 7.44 2.83 12.17 -0.33 1.98-1.08 3.71-2.22 5.24-0.82 1.09-1.82 2.05-3 2.89-0.06 1.53-0.08 3.03-0.08 4.52 0.01 1.91 0.07 3.88 0.18 5.9 0.25 4.74 0.96 9.52 1.67 14.26 0.76 5.1 1.52 10.16 1.72 15.43 0.27 6.75-0.53 12.3-2.76 16.22-2.48 4.38-6.51 6.72-12.45 6.51l0 0c-7.09-0.13-11.45-4.11-13.42-11.46-1.72-6.43-1.46-15.61 0.49-27.16-0.06-9.15-1.25-16.08-3.61-20.75-1.54-3.05-3.63-5.07-6.27-6.03v59.92c0.86 0.41 1.64 0.97 2.3 1.64 1.52 1.52 2.47 3.63 2.47 5.95v5.98c0 1.51-1.23 2.74-2.74 2.74H2.74c-1.51 0-2.74-1.23-2.74-2.74v-5.98c0-2.32 0.95-4.42 2.47-5.95 0.47-0.47 1-0.89 1.57-1.24V14.52c0-4 1.63-7.63 4.26-10.26C10.93 1.63 14.56 0 18.56 0h37.78c4.01 0 7.66 1.64 10.3 4.28 2.64 2.64 4.28 6.29 4.28 10.31v26.36c4.86 1.06 8.57 4.17 11.15 9.27 2.77 5.47 4.15 13.31 4.19 23.46 0 0.16-0.01 0.32-0.04 0.47h0.01c-1.85 10.87-2.15 19.35-0.63 25.02 1.27 4.77 3.95 7.35 8.24 7.41h0.05l0 0c3.66 0.12 6.09-1.22 7.52-3.75 1.69-2.98 2.28-7.55 2.05-13.31 -0.19-4.88-0.94-9.85-1.68-14.85-0.72-4.82-1.44-9.68-1.71-14.78 -0.11-2.01-0.17-4.06-0.18-6.18-0.01-1.68 0.02-3.34 0.09-4.97 -5.11-4.48-8.22-8.96-9.18-13.42-0.91-4.23 0.05-8.29 3-12.17 -2.25-1.54-4.54-2.8-6.86-3.81-3.17-1.38-3.19-1.5-6.51-2.04 -1.49-0.24-2.5-1.65-2.26-3.14 0.24-1.49 1.65-2.5 3.14-2.26 3.76 0.61 4.21 0.85 7.82 2.42C92.56 15.82 95.87 17.75 99.08 20.2z M98.17 26.5c-1.91 2.56-2.55 5.12-1.99 7.7 0.67 3.12 3 6.44 6.88 9.95 0.39-0.35 0.74-0.72 1.03-1.11 0.61-0.81 1.02-1.76 1.19-2.84 0.52-3.16-0.37-5.87-1.97-8.25C101.99 29.98 100.15 28.16 98.17 26.5z M21.86 12.54h31.82c1.65 0 3.15 0.67 4.24 1.76 0.07 0.08 0.15 0.15 0.22 0.24 0.96 1.07 1.55 2.48 1.55 4v20.3c0 1.65-0.67 3.16-1.76 4.24-1.08 1.08-2.58 1.76-4.24 1.76H21.86c-1.64 0-3.13-0.68-4.23-1.76l-0.01 0.01c-1.08-1.08-1.76-2.59-1.76-4.24V18.53c0-1.65 0.67-3.15 1.76-4.24C18.93 13.12 20.33 12.54 21.86 12.54z M68.43 111.48c-0.08 0.01-0.15 0.01-0.23 0.01H7.26c-0.34 0.15-0.65 0.36-0.91 0.62-0.53 0.53-0.86 1.26-0.86 2.07v3.24h64.74v-3.24c0-0.8-0.33-1.53-0.86-2.07C69.1 111.84 68.78 111.63 68.43 111.48z"
          stroke="white"
          fill="white"
          strokeWidth="2"
          strokeLinecap="round"
          strokeLinejoin="round"
        />
      </svg>
    ),
  },
  {
    name: "WiFi",
    svg: (
      <svg
        viewBox="0 0 16 16"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M0 7L1.17157 5.82843C2.98259 4.01741 5.43884 3 8 3C10.5612 3 13.0174 4.01742 14.8284 5.82843L16 7L14.5858 8.41421L13.4142 7.24264C11.9783 5.8067 10.0307 5 8 5C5.96928 5 4.02173 5.8067 2.58579 7.24264L1.41421 8.41421L0 7Z"
          fill="white"
        />
        <path
          d="M4.24264 11.2426L2.82843 9.82843L4 8.65685C5.06086 7.59599 6.49971 7 8 7C9.50029 7 10.9391 7.59599 12 8.65686L13.1716 9.82843L11.7574 11.2426L10.5858 10.0711C9.89999 9.38527 8.96986 9 8 9C7.03014 9 6.1 9.38527 5.41421 10.0711L4.24264 11.2426Z"
          fill="white"
        />
        <path
          d="M8 15L5.65685 12.6569L6.82842 11.4853C7.13914 11.1746 7.56057 11 8 11C8.43942 11 8.86085 11.1746 9.17157 11.4853L10.3431 12.6569L8 15Z"
          fill="white"
        />
      </svg>
    ),
  },
  {
    name: "Parking",
    svg: (
      <svg
        viewBox="0 0 512 512"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M0,0v512h512V0H0z M351.727,292.225c-20.324,20.362-48.769,33.077-79.833,33.061h-55.546v87.233h-79.585V99.481h74.276h5.308h55.546c31.064-0.016,59.518,12.699,79.833,33.078c20.378,20.315,33.085,48.76,33.07,79.833C384.812,243.448,372.105,271.909,351.727,292.225z"
          stroke="white"
          fill="white"
          strokeWidth="2"
        />
        <path
          d="M271.894,171.107h-55.546v82.553h55.546c11.51-0.015,21.606-4.57,29.191-12.093c7.524-7.585,12.07-17.673,12.086-29.176c-0.016-11.518-4.562-21.606-12.093-29.192C293.499,175.677,283.404,171.123,271.894,171.107z"
          stroke="white"
          fill="white"
          strokeWidth="2"
        />
      </svg>
    ),
  },
  {
    name: "WC",
    svg: (
      <svg
        viewBox="0 0 24 24"
        xmlns="http://www.w3.org/2000/svg"
        width="28"
        height="28"
      >
        <path
          d="M9.80469 13.7734L10.8186 7.05043C10.8555 6.80585 11.0657 6.625 11.3131 6.625H12.5595C12.8706 6.625 13.1062 6.9062 13.0517 7.21257L11.2062 17.5876C11.1637 17.8262 10.9563 18 10.7139 18H9.23878C9.0001 18 8.7947 17.8313 8.74831 17.5972L7.5 11.2969L6.26659 17.5961C6.22065 17.8307 6.01501 18 5.77591 18H4.29362C4.05139 18 3.84399 17.8264 3.80141 17.5879L1.94873 7.2129C1.89401 6.90643 2.12963 6.625 2.44095 6.625H3.70217C3.94969 6.625 4.15996 6.8061 4.19665 7.05088L5.20312 13.7656L6.46272 7.03305C6.50698 6.79647 6.71351 6.625 6.95419 6.625H8.05354C8.29426 6.625 8.50081 6.79652 8.54503 7.03315L9.80469 13.7734Z"
          fill="white"
        />
        <path
          d="M20.7068 14.2109C20.9916 14.2109 21.2212 14.4491 21.1879 14.732C21.0651 15.7739 20.7144 16.582 20.1356 17.1562C19.4637 17.8229 18.5158 18.1562 17.2919 18.1562C16.0054 18.1562 15.0184 17.7344 14.3309 16.8906C13.6486 16.0417 13.3075 14.8333 13.3075 13.2656V11.3516C13.3075 9.78906 13.6617 8.58594 14.37 7.74219C15.0783 6.89323 16.0627 6.46875 17.3231 6.46875C18.5627 6.46875 19.5028 6.8151 20.1434 7.50781C20.6978 8.10246 21.0469 8.91971 21.1906 9.95956C21.2303 10.2464 20.9992 10.4922 20.7097 10.4922H19.4275C19.1564 10.4922 18.9378 10.2757 18.9121 10.0059C18.8604 9.46252 18.7448 9.07255 18.5653 8.83594C18.3414 8.52865 17.9273 8.375 17.3231 8.375C16.7085 8.375 16.2736 8.59115 16.0184 9.02344C15.7632 9.45052 15.6278 10.1562 15.6122 11.1406V13.2891C15.6122 14.4193 15.7372 15.1953 15.9872 15.6172C16.2424 16.0391 16.6773 16.25 17.2919 16.25C17.896 16.25 18.3127 16.1042 18.5419 15.8125C18.7201 15.5816 18.8385 15.2073 18.897 14.6897C18.9271 14.4232 19.1444 14.2109 19.4126 14.2109H20.7068Z"
          fill="white"
        />
      </svg>
    ),
  },
]

function Prototype() {
  const groups = [
    {
      label: "Typography · 8 styles",
      desc: "Text styles the LLM can assign to any content it generates. Weight, size, and color are fixed per style to maintain visual hierarchy.",
      items: [
        {
          name: "HeadlineText",
          img: "/case-study/assets/elements/type-headline.png",
        },
        {
          name: "SecondaryNumText",
          img: "/case-study/assets/elements/type-secondary-num.png",
        },
        {
          name: "SecondaryContinuousMultilineText",
          img: "/case-study/assets/elements/type-continuous-multiline.png",
        },
        {
          name: "TertiaryContinuousDemiText",
          img: "/case-study/assets/elements/type-continuous-demi.png",
        },
        {
          name: "TertiaryContinuousLightText",
          img: "/case-study/assets/elements/type-continuous-light.png",
        },
        {
          name: "TertiarySingleLineDemiText",
          img: "/case-study/assets/elements/type-single-line.png",
        },
        { name: "TertiarySingleLineLightText", img: null },
        { name: "SyncText", img: "/case-study/assets/elements/type-sync.png" },
      ],
    },
    {
      label: "Icons · 15 glyphs",
      desc: "A fixed icon set. The LLM references icons by name. No custom icons can be generated.",
      custom: "icons",
    },
    {
      label: "Containers · 2",
      desc: "The two screen regions the LLM can target. It decides which container each piece of content goes into based on priority and information type.",
      items: [
        {
          name: "AppPanel (vertical content area)",
          img: "/case-study/assets/elements/app-panel.png",
          note: "Left side of the screen. Holds primary content like navigation, alerts, and lists.",
        },
        {
          name: "ZeroLayerPanel (bottom bar)",
          img: "/case-study/assets/elements/app-panel.png",
          note: "Horizontal strip at the bottom. Shows glanceable summaries like fuel, weather, and media. Same visual treatment, different region.",
        },
      ],
    },
    {
      label: "Layout Skeletons · 2",
      desc: "Empty but styled containers. The LLM decides what content goes inside and how to arrange it. Think of them as flexible slots with no predetermined content.",
      custom: "skeletons",
    },
    {
      label: "Navigation · 2",
      desc: "Turn-by-turn and supplementary route info. Structure is fixed; the LLM populates distances, street names, and icons.",
      items: [
        {
          name: "Navigation",
          img: "/case-study/assets/elements/navigation.png",
          note: "Primary turn instruction with distance, street, and directional icon.",
        },
        {
          name: "AdditionalNavigation",
          img: "/case-study/assets/elements/additional-nav.png",
          note: "ETA, remaining distance, and delay info in a compact row.",
        },
      ],
    },
    {
      label: "Content · 7 elements",
      desc: "The building blocks the LLM arranges inside containers. Each has a fixed visual structure; the LLM provides the data.",
      items: [
        {
          name: "ListItemWithNoImage",
          img: "/case-study/assets/elements/list-item.png",
          note: "Numbered list row with title and description.",
        },
        {
          name: "ListItemWithImage",
          img: "/case-study/assets/elements/list-item-image.png",
          note: "List row with a thumbnail (fetched via Pixabay API).",
        },
        {
          name: "HorizontalList",
          img: "/case-study/assets/elements/horizontal-list.png",
          note: "Scrollable card row for recommendations.",
        },
        { name: "Carousel", img: null, note: "Swipeable content cards." },
        { name: "Divider", img: "/case-study/assets/elements/divider.png" },
        {
          name: "Image (via Pixabay)",
          img: null,
          note: "Dynamic image fetched by keyword.",
        },
        {
          name: "ActivityIndicator",
          img: null,
          note: "Loading spinner shown while content is being generated.",
        },
      ],
    },
  ]

  const total = 31
  const [expanded, setExpanded] = useState(null)

  return (
    <section id="component-library" style={{ paddingBottom: 120 }}>
      <div className="wrap">
        <SectionHead
          num="04.2 — Library"
          eyebrow="The atomic vocabulary"
          title={`${total} pre-designed elements. The only things the AI can use.`}
        >
          <p className="lede">
            The LLM doesn't draw from scratch. It picks from this fixed set of
            brand-compliant, safety-validated components and fills them with
            contextual content. The structure of each element is locked; the AI
            controls <em>which</em> ones appear, <em>where</em> they go, and
            <em> what data</em> they carry.
          </p>
        </SectionHead>

        <div className="cl-groups">
          {groups.map((g, gi) => (
            <div key={g.label} className="cl-group">
              <button
                className="cl-group-header"
                onClick={() => setExpanded(expanded === gi ? null : gi)}
                aria-expanded={expanded === gi}
              >
                <div>
                  <div className="cl-group-label">{g.label}</div>
                  <div className="cl-group-desc">{g.desc}</div>
                </div>
                <span className="cl-group-toggle">
                  {expanded === gi ? "−" : "+"}
                </span>
              </button>

              <div
                className={"cl-items-wrap" + (expanded === gi ? " open" : "")}
              >
                {g.custom === "icons" ? (
                  <IconGrid />
                ) : g.custom === "skeletons" ? (
                  <SkeletonPreview />
                ) : (
                  <div className="cl-items">
                    {g.items.map((item) => (
                      <div key={item.name} className="cl-item">
                        <div
                          className={
                            "cl-preview" +
                            (item.img &&
                            (item.name.includes("Navigation") ||
                              item.name.includes("Panel"))
                              ? " cl-preview-dark"
                              : "")
                          }
                        >
                          {item.img ? (
                            <img
                              src={item.img}
                              alt={item.name}
                              className="cl-preview-img"
                              loading="lazy"
                            />
                          ) : (
                            <div className="cl-preview-placeholder">
                              <span className="cl-preview-ph-label">
                                PREVIEW
                              </span>
                              <span className="cl-preview-ph-text">
                                Replace with screenshot
                              </span>
                            </div>
                          )}
                        </div>
                        <div className="cl-meta">
                          <div className="cl-name">{item.name}</div>
                          {item.note && (
                            <div className="cl-note">{item.note}</div>
                          )}
                        </div>
                      </div>
                    ))}
                  </div>
                )}
              </div>
            </div>
          ))}
        </div>
      </div>

      <style>{`
        .cl-groups {
          display: flex;
          flex-direction: column;
          gap: 0;
        }
        .cl-group {
          border-top: 1px solid var(--page-line);
        }
        .cl-group:last-child {
          border-bottom: 1px solid var(--page-line);
        }
        .cl-group-header {
          display: flex;
          align-items: flex-start;
          justify-content: space-between;
          gap: 16px;
          width: 100%;
          padding: 20px 0;
          background: transparent;
          border: none;
          cursor: pointer;
          text-align: left;
          font-family: var(--font-sans);
          color: var(--page-fg);
          transition: opacity 200ms;
        }
        .cl-group-header:hover { opacity: 0.8; }
        .cl-group-label {
          font-family: var(--font-mono);
          font-size: 12px;
          font-weight: 600;
          letter-spacing: 0.08em;
          text-transform: uppercase;
          color: var(--page-fg);
          margin-bottom: 6px;
        }
        .cl-group-desc {
          font-size: 13px;
          color: var(--page-muted);
          line-height: 1.5;
          max-width: 60ch;
        }
        .cl-group-toggle {
          font-size: 20px;
          color: var(--page-accent);
          flex-shrink: 0;
          width: 32px;
          height: 32px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 999px;
          border: 1px solid var(--page-line);
          margin-top: 4px;
          transition: transform 200ms;
        }
        .cl-items-wrap {
          max-height: 0;
          overflow: hidden;
          transition: max-height 400ms cubic-bezier(.2,0,0,1), opacity 300ms;
          opacity: 0;
        }
        .cl-items-wrap.open {
          max-height: 2000px;
          opacity: 1;
        }
        .cl-items {
          display: flex;
          flex-wrap: wrap;
          gap: 10px;
          padding-bottom: 24px;
        }
        .cl-item {
          background: var(--page-card);
          border: 1px solid var(--page-line);
          border-radius: 10px;
          overflow: hidden;
          display: flex;
          flex-direction: column;
          min-width: 140px;
          max-width: 220px;
          flex: 1 1 180px;
          transition: border-color 200ms, transform 150ms;
        }
        .cl-meta {
          min-height: 68px;
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
        }
        .cl-item:hover {
          border-color: var(--page-accent);
          transform: translateY(-1px);
        }
        .cl-preview {
          background: var(--page-bg);
          padding: 16px;
          display: flex;
          align-items: center;
          justify-content: center;
          height: 100px;
        }
        .cl-preview-dark {
          background: #0E1116;
        }
        .cl-preview-img {
          max-width: 100%;
          max-height: 68px;
          object-fit: contain;
          display: block;
        }
        .cl-preview-dark .cl-preview-img {
          max-height: 68px;
        }
        .cl-preview-placeholder {
          display: flex;
          flex-direction: column;
          align-items: center;
          gap: 4px;
          text-align: center;
        }
        .cl-preview-ph-label {
          font-family: var(--font-mono);
          font-size: 9px;
          letter-spacing: 0.08em;
          color: var(--page-muted);
        }
        .cl-preview-ph-text {
          font-size: 10px;
          color: var(--page-line);
        }
        .cl-meta {
          padding: 10px 12px;
          border-top: 1px solid var(--page-line);
          min-height: 68px;
        }
        .cl-name {
          font-size: 11px;
          font-family: var(--font-mono);
          color: var(--page-fg);
          line-height: 1.3;
          word-break: break-word;
          font-weight: 500;
        }
        .cl-note {
          font-size: 11px;
          color: var(--page-muted);
          line-height: 1.4;
          margin-top: 4px;
        }

        /* Icon grid */
        .cl-icon-grid {
          display: grid;
          grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
          gap: 8px;
          padding-bottom: 24px;
        }
        .cl-icon-cell {
          background: var(--page-card);
          border: 1px solid var(--page-line);
          border-radius: 10px;
          display: flex;
          flex-direction: column;
          align-items: center;
          overflow: hidden;
          transition: border-color 200ms, transform 150ms;
        }
        .cl-icon-cell:hover {
          border-color: var(--page-accent);
          transform: translateY(-1px);
        }
        .cl-icon-preview {
          width: 100%;
          background: #0E1116;
          display: flex;
          align-items: center;
          justify-content: center;
          padding: 16px 8px;
          height: 64px;
        }
        .cl-icon-name {
          font-size: 9px;
          font-family: var(--font-mono);
          color: var(--page-muted);
          text-align: center;
          line-height: 1.2;
          letter-spacing: 0.02em;
          padding: 7px 4px 8px;
          border-top: 1px solid var(--page-line);
          width: 100%;
        }

        /* Skeleton previews */
        .cl-skel-row {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 12px;
          padding-bottom: 24px;
        }
        .cl-skel {
          background: var(--page-card);
          border: 1px solid var(--page-line);
          border-radius: 10px;
          overflow: hidden;
          transition: border-color 200ms;
        }
        .cl-skel:hover { border-color: var(--page-accent); }
        .cl-skel-vis {
          padding: 20px;
          background: var(--page-bg);
          display: flex;
          align-items: center;
          justify-content: center;
          min-height: 80px;
        }
        .cl-skel-meta {
          padding: 10px 12px;
          border-top: 1px solid var(--page-line);
        }

        @media (max-width: 720px) {
          .cl-item { min-width: 120px; max-width: 100%; flex: 1 1 140px; }
          .cl-icon-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
          .cl-skel-row { grid-template-columns: 1fr; }
        }
      `}</style>
    </section>
  )
}

/* Icon grid — inline SVGs on dark background (their native context) */
function IconGrid() {
  return (
    <div className="cl-icon-grid">
      {ICON_SVGS.map((icon) => (
        <div key={icon.name} className="cl-icon-cell">
          <div className="cl-icon-preview">{icon.svg}</div>
          <div className="cl-icon-name">{icon.name}</div>
        </div>
      ))}
    </div>
  )
}

/* Skeleton layout previews (abstract visual) */
function SkeletonPreview() {
  return (
    <div className="cl-skel-row">
      <div className="cl-skel">
        <div className="cl-skel-vis">
          <div
            style={{
              display: "flex",
              flexDirection: "column",
              gap: 8,
              width: "100%",
            }}
          >
            <div
              style={{
                height: 10,
                width: "70%",
                background: "var(--page-line)",
                borderRadius: 4,
              }}
            ></div>
            <div
              style={{
                height: 10,
                width: "50%",
                background: "var(--page-line)",
                borderRadius: 4,
                opacity: 0.6,
              }}
            ></div>
            <div
              style={{
                height: 10,
                width: "85%",
                background: "var(--page-line)",
                borderRadius: 4,
                opacity: 0.4,
              }}
            ></div>
            <div
              style={{
                height: 10,
                width: "40%",
                background: "var(--page-line)",
                borderRadius: 4,
                opacity: 0.3,
              }}
            ></div>
          </div>
        </div>
        <div className="cl-skel-meta">
          <div className="cl-name">VerticalStackSkeleton</div>
          <div className="cl-note">
            A vertical container. The LLM fills it with text, icons, or lists
            and decides the order and spacing.
          </div>
        </div>
      </div>
      <div className="cl-skel">
        <div className="cl-skel-vis">
          <div
            style={{
              display: "flex",
              gap: 10,
              width: "100%",
              alignItems: "center",
            }}
          >
            <div
              style={{
                height: 36,
                flex: "1 1 0",
                background: "var(--page-line)",
                borderRadius: 6,
              }}
            ></div>
            <div
              style={{
                height: 36,
                flex: "1 1 0",
                background: "var(--page-line)",
                borderRadius: 6,
                opacity: 0.6,
              }}
            ></div>
            <div
              style={{
                height: 36,
                flex: "1 1 0",
                background: "var(--page-line)",
                borderRadius: 6,
                opacity: 0.4,
              }}
            ></div>
          </div>
        </div>
        <div className="cl-skel-meta">
          <div className="cl-name">HorizontalStackSkeleton</div>
          <div className="cl-note">
            A horizontal container. Used for side-by-side content like ETA +
            distance pairs or compact info blocks.
          </div>
        </div>
      </div>
    </div>
  )
}

window.Prototype = Prototype
