;; kufi-craft -- handmade kufi cap marketplace
(define-data-var cap-count uint u0)
(define-map caps uint { maker: principal, style: (string-ascii 20), color: (string-ascii 15), price: uint, sold: bool })
(define-public (list-kufi (style (string-ascii 20)) (color (string-ascii 15)) (price uint))
(let ((id (+ (var-get cap-count) u1)))
(var-set cap-count id)
(map-set caps id { maker: tx-sender, style: style, color: color, price: price, sold: false }) (ok id)))
(define-public (buy-kufi (id uint))
(let ((c (unwrap! (map-get? caps id) (err u404))))
(map-set caps id (merge c { sold: true })) (ok true)))
(define-read-only (get-kufi (id uint)) (map-get? caps id))
(define-read-only (get-count) (var-get cap-count))