// Friendly edition - simple icons & sections
const { useState: uS, useEffect: uE, useMemo: uM } = React;

const Icon = ({ name, size = 24, color = "currentColor" }) => {
  const paths = {
    phone: <path d="M5 4h4l2 5-2.5 1.5a11 11 0 0 0 5 5L15 13l5 2v4a2 2 0 0 1-2 2A16 16 0 0 1 3 6a2 2 0 0 1 2-2z" stroke={color} strokeWidth="2.5" fill="none" strokeLinecap="round" strokeLinejoin="round"/>,
    pin: <><path d="M12 2a8 8 0 0 0-8 8c0 6 8 12 8 12s8-6 8-12a8 8 0 0 0-8-8z" stroke={color} strokeWidth="2.5" fill="none" strokeLinejoin="round"/><circle cx="12" cy="10" r="3" stroke={color} strokeWidth="2.5" fill="none"/></>,
    clock: <><circle cx="12" cy="12" r="9" stroke={color} strokeWidth="2.5" fill="none"/><path d="M12 7v5l3 2" stroke={color} strokeWidth="2.5" strokeLinecap="round"/></>,
    box: <path d="M3 7l9-4 9 4v10l-9 4-9-4V7zm0 0l9 4m0 0l9-4m-9 4v9" stroke={color} strokeWidth="2.5" fill="none" strokeLinejoin="round"/>,
    arrow: <path d="M5 12h14m-6-6l6 6-6 6" stroke={color} strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" fill="none"/>,
    check: <path d="M5 12l5 5 9-10" stroke={color} strokeWidth="3" strokeLinecap="round" strokeLinejoin="round" fill="none"/>,
    chat: <path d="M21 12a8 8 0 0 1-12 7l-5 1 1-4a8 8 0 1 1 16-4z" stroke={color} strokeWidth="2.5" fill="none" strokeLinejoin="round"/>,
    ig: <><rect x="3" y="3" width="18" height="18" rx="5" stroke={color} strokeWidth="2.5" fill="none"/><circle cx="12" cy="12" r="4" stroke={color} strokeWidth="2.5" fill="none"/><circle cx="17.5" cy="6.5" r="1.2" fill={color}/></>,
  };
  return <svg width={size} height={size} viewBox="0 0 24 24">{paths[name]}</svg>;
};

const FDonut = ({ glaze = "#f25e83", dough = "#d99845", spr = false }) => (
  <svg viewBox="0 0 200 200">
    <ellipse cx="100" cy="178" rx="68" ry="6" fill="rgba(0,0,0,0.18)"/>
    <circle cx="100" cy="100" r="78" fill={dough} stroke="#1f1611" strokeWidth="3"/>
    <circle cx="100" cy="100" r="74" fill={glaze}/>
    <ellipse cx="78" cy="78" rx="28" ry="14" fill="#fff" opacity="0.35"/>
    <circle cx="100" cy="100" r="26" fill={dough} stroke="#1f1611" strokeWidth="3"/>
    {spr && [...Array(12)].map((_, i) => {
      const a = i * 30, r = 50, c = ["#2e8a4e","#ffd35e","#1f1611","#fff","#2f6fb0","#f25e83"][i%6];
      const x = 100 + Math.cos(a*Math.PI/180)*r, y = 100 + Math.sin(a*Math.PI/180)*r;
      return <rect key={i} x={x} y={y} width="4" height="11" rx="2" fill={c} transform={`rotate(${a+45} ${x} ${y})`}/>;
    })}
  </svg>
);

const FBar = () => (
  <svg viewBox="0 0 200 200">
    <ellipse cx="100" cy="170" rx="76" ry="6" fill="rgba(0,0,0,0.18)"/>
    <rect x="22" y="64" width="156" height="76" rx="38" fill="#d99845" stroke="#1f1611" strokeWidth="3"/>
    <path d="M30 78 q40 -16 86 -10 q42 6 56 14 q-2 24 -12 30 q-30 14 -78 8 q-42 -6 -54 -14 q-4 -14 2 -28 z" fill="#7a4a26"/>
    <ellipse cx="80" cy="80" rx="32" ry="6" fill="#fff" opacity="0.3"/>
  </svg>
);

const FKolache = () => (
  <svg viewBox="0 0 200 200">
    <ellipse cx="100" cy="178" rx="70" ry="6" fill="rgba(0,0,0,0.18)"/>
    <path d="M40 100 q-4 -50 60 -54 q64 -4 64 54 q4 56 -60 60 q-66 -4 -64 -60 z" fill="#f3d18e" stroke="#1f1611" strokeWidth="3"/>
    <ellipse cx="100" cy="100" rx="36" ry="22" fill="#a93530" stroke="#1f1611" strokeWidth="2"/>
  </svg>
);

const FFritter = () => (
  <svg viewBox="0 0 200 200">
    <ellipse cx="100" cy="178" rx="74" ry="6" fill="rgba(0,0,0,0.18)"/>
    <path d="M40 90 q-8 -22 12 -34 q22 -14 36 4 q12 -22 36 -16 q24 6 22 28 q22 -8 36 8 q14 18 -4 36 q14 14 4 32 q-12 22 -36 14 q-8 22 -32 18 q-22 -4 -26 -22 q-22 6 -36 -10 q-14 -18 0 -34 q-18 -8 -12 -24 z" fill="#a96532" stroke="#1f1611" strokeWidth="3"/>
    <path d="M58 88 q12 8 6 22 m24 -22 q-2 12 12 18 m20 -28 q-4 14 14 18" stroke="#5a3424" strokeWidth="3" fill="none" strokeLinecap="round"/>
  </svg>
);

const FCake = () => (
  <svg viewBox="0 0 200 200">
    <ellipse cx="100" cy="178" rx="70" ry="6" fill="rgba(0,0,0,0.18)"/>
    <circle cx="100" cy="100" r="78" fill="#7e5a8a" stroke="#1f1611" strokeWidth="3"/>
    <circle cx="100" cy="100" r="26" fill="#5a3424" stroke="#1f1611" strokeWidth="2"/>
    {[[60,60],[140,65],[60,140],[145,138],[100,50]].map(([x,y],i)=>(<circle key={i} cx={x} cy={y} r="6" fill="#2f6fb0"/>))}
  </svg>
);

const ITEMS = [
  { id: 1, name: "Raspberry Glaze", desc: "Pink, fluffy, our most popular donut.", price: 2.50, pic: <FDonut glaze="#f25e83" dough="#e8b665"/>, bg: "pink" },
  { id: 2, name: "Sprinkle Donut", desc: "Lots of sprinkles. Kids love these.", price: 2.75, pic: <FDonut glaze="#fff" dough="#e8b665" spr/>, bg: "butter" },
  { id: 3, name: "Maple Bar", desc: "Long donut with sweet maple frosting.", price: 2.75, pic: <FBar/>, bg: "cream" },
  { id: 4, name: "Apple Fritter", desc: "Big and crunchy with cinnamon and apple.", price: 3.95, pic: <FFritter/>, bg: "cream" },
  { id: 5, name: "Sausage Kolache", desc: "Soft bread with sausage inside. A breakfast.", price: 3.25, pic: <FKolache/>, bg: "green" },
  { id: 6, name: "Blueberry Cake", desc: "A cakey donut with real blueberries.", price: 2.50, pic: <FCake/>, bg: "blue" },
];

const SIZES = [
  { n: 6, l: "Half Dozen", s: "Good for a small family", p: 14 },
  { n: 12, l: "One Dozen", s: "Most popular size", p: 26 },
  { n: 24, l: "Two Dozen", s: "Office or team breakfast", p: 50 },
  { n: 48, l: "Four Dozen", s: "Big group or party", p: 96 },
];

const App = () => {
  const [step, setStep] = uS(1);
  const [size, setSize] = uS(12);
  const [name, setName] = uS("");
  const [phone, setPhone] = uS("");
  const [date, setDate] = uS("");
  const [time, setTime] = uS("07:30");
  const [notes, setNotes] = uS("");
  const [done, setDone] = uS(false);

  const sz = SIZES.find(s => s.n === size);
  const days = [["Monday","5:00 AM — until sold out"],["Tuesday","5:00 AM — until sold out"],["Wednesday","5:00 AM — until sold out"],["Thursday","5:00 AM — until sold out"],["Friday","5:00 AM — until sold out"],["Saturday","5:00 AM — until sold out"],["Sunday","5:00 AM — until sold out"]];
  const today = (new Date().getDay() + 6) % 7;

  const submit = () => setDone(true);
  const reset = () => { setDone(false); setStep(1); setName(""); setPhone(""); setDate(""); setNotes(""); };

  return <>
    <div className="f-banner"><span className="dot"></span>Open today · 5 AM until sold out · 7 days a week</div>

    <header className="f-header">
      <a href="#top" className="f-logo">
        <img src="./assets/td-logo.jpg" alt="Tigard Donut logo"/>
        <span className="f-logo-text">Tigard Donut</span>
      </a>
      <nav className="f-header-links">
        <a href="#menu">Donuts</a>
        <a href="#order">Order</a>
        <a href="#visit">Visit</a>
        <a href="#faq">Help</a>
        <a href="https://www.doordash.com/store/tigard-donut-portland-36659779/82163749/" target="_blank" rel="noopener">DoorDash</a>
        <a href="https://www.yelp.com/biz/tigard-donut-portland-2" target="_blank" rel="noopener">Yelp</a>
        <a href="https://www.instagram.com/tigarddonut/" target="_blank" rel="noopener">Instagram</a>
      </nav>
      <a href="sms:+15036208518" className="f-call-big"><Icon name="phone" size={18}/>Call or Text</a>
    </header>

    <section className="f-hero" id="top">
      <div>
        <h1>Fresh donuts <span className="pink">made every morning</span> in Tigard.</h1>
        <p className="lede">Pick up a box of donuts and kolaches at the shop. Easy to order. Just call or text us, or fill out the simple form below.</p>
        <div className="f-hero-cta">
          <a href="#order" className="f-btn pink huge"><Icon name="box" size={22}/>Order a Box</a>
          <a href="sms:+15036208518" className="f-btn white huge"><Icon name="phone" size={22}/>Call or Text Us</a>
        </div>
      </div>
      <div className="f-hero-photo">
        <span className="tag">Hi! 👋</span>
        <FDonut glaze="#f25e83" dough="#e8b665" spr/>
      </div>
    </section>

    <section className="f-menu" id="menu">
      <div className="f-menu-head">
        <h2>What's in the case</h2>
        <p>Made fresh every morning. Get there early — most days we sell out before noon.</p>
        <p className="f-menu-note">Sample menu shown · final lineup and pricing confirmed with the shop.</p>
      </div>
      <div className="f-menu-grid">
        {ITEMS.map(it => (
          <article key={it.id} className="f-donut">
            <div className={`pic ${it.bg}`}>{it.pic}</div>
            <div className="body">
              <h3>{it.name}</h3>
              <p className="desc">{it.desc}</p>
              <div className="price-row">
                <span className="price">${it.price.toFixed(2)}</span>
                <span className="each">each</span>
              </div>
            </div>
          </article>
        ))}
      </div>
    </section>

    <section className="f-order" id="order">
      <div className="f-order-wrap">
        <div className="f-order-head">
          <h2>Order a box</h2>
          <p>Just answer a few simple questions. We'll do the rest.</p>
        </div>

        {!done && (
          <div className="f-progress">
            {[[1,"How many"],[2,"When"],[3,"Who"]].map(([n,l]) => (
              <React.Fragment key={n}>
                <div className={`step ${step===n?"on":""}`}>
                  <div className={`ball ${step>n?"done":step===n?"on":""}`}>{step>n?<Icon name="check" size={20}/>:n}</div>
                  <span className="label">{l}</span>
                </div>
                {n<3 && <div className="bar"/>}
              </React.Fragment>
            ))}
          </div>
        )}

        {done ? (
          <div className="f-success">
            <div className="check"><Icon name="check" size={42}/></div>
            <h3>All set! We got your order.</h3>
            <p>We'll text {phone || "you"} within the hour to confirm your {sz.l.toLowerCase()} for {date || "your date"} at {time}. Questions? Call or text us at (503) 620-8518.</p>
            <button onClick={reset} className="f-btn white">Order another box</button>
          </div>
        ) : step === 1 ? (
          <div className="f-card">
            <h3>How many donuts?</h3>
            <p className="help">Tap the size you'd like. You can change it later.</p>
            <div className="f-size-grid">
              {SIZES.map(s => (
                <button key={s.n} className={`f-size-card ${size===s.n?"on":""}`} onClick={()=>setSize(s.n)}>
                  <span className="num">{s.n}</span>
                  <span><span className="lab">{s.l}</span><br/><span className="sub">{s.s}</span></span>
                  <span className="price">${s.p}</span>
                </button>
              ))}
            </div>
            <div className="f-step-actions">
              <a href="tel:+15036208518" className="f-btn white"><Icon name="phone" size={20}/>Or call us</a>
              <button onClick={()=>setStep(2)} className="f-btn pink">Next: When<Icon name="arrow" size={20}/></button>
            </div>
          </div>
        ) : step === 2 ? (
          <div className="f-card">
            <h3>When would you like to pick up?</h3>
            <p className="help">We open at 5 AM most days. Same-day works if you order before 6 AM.</p>
            <div className="f-field-group">
              <div className="f-field">
                <label htmlFor="date">Date</label>
                <input id="date" className="f-input" type="date" value={date} onChange={e=>setDate(e.target.value)}/>
              </div>
              <div className="f-field">
                <label htmlFor="time">Time</label>
                <input id="time" className="f-input" type="time" value={time} onChange={e=>setTime(e.target.value)}/>
                <span className="help-text">Most pickups happen between 7:00 and 10:00 AM.</span>
              </div>
            </div>
            <div className="f-step-actions">
              <button onClick={()=>setStep(1)} className="f-btn white">← Back</button>
              <button onClick={()=>setStep(3)} className="f-btn pink">Next: Who<Icon name="arrow" size={20}/></button>
            </div>
          </div>
        ) : (
          <div className="f-card">
            <h3>Who is this for?</h3>
            <p className="help">We'll text you to confirm. Standard text rates apply.</p>

            <div className="f-summary">
              <h4>Your order so far</h4>
              <div className="row"><span className="l">Box size</span><span className="v">{sz.l} ({sz.n})</span></div>
              <div className="row"><span className="l">Pickup</span><span className="v">{date || "Pick a date"} at {time}</span></div>
              <div className="row"><span className="l">Estimated total</span><span className="v">${sz.p}</span></div>
            </div>

            <div className="f-field-group">
              <div className="f-field">
                <label htmlFor="name">Your name</label>
                <input id="name" className="f-input" value={name} onChange={e=>setName(e.target.value)} placeholder="First and last name"/>
              </div>
              <div className="f-field">
                <label htmlFor="phone">Phone number</label>
                <input id="phone" className="f-input" type="tel" value={phone} onChange={e=>setPhone(e.target.value)} placeholder="(503) 555-1234"/>
                <span className="help-text">We'll text or call to confirm.</span>
              </div>
              <div className="f-field">
                <label htmlFor="notes">Anything we should know? (optional)</label>
                <textarea id="notes" className="f-area" value={notes} onChange={e=>setNotes(e.target.value)} placeholder="Favorite donuts, allergies, the occasion..."/>
              </div>
            </div>
            <div className="f-step-actions">
              <button onClick={()=>setStep(2)} className="f-btn white">← Back</button>
              <button onClick={submit} className="f-btn green huge"><Icon name="check" size={22}/>Send my order</button>
            </div>
          </div>
        )}
      </div>
    </section>

    <section className="f-visit" id="visit">
      <div className="f-visit-card">
        <h2>Come visit us</h2>
        <div className="f-info-row">
          <div className="icon pink"><Icon name="pin" size={26} color="white"/></div>
          <div><div className="l">Address</div><div className="v">13815 SW Pacific Hwy<br/>Unit 80, Tigard, OR 97223</div></div>
        </div>
        <div className="f-info-row">
          <div className="icon green"><Icon name="phone" size={26} color="white"/></div>
          <div><div className="l">Phone</div><div className="v"><a href="tel:+15036208518">(503) 620-8518</a></div></div>
        </div>
        <div className="f-info-row">
          <div className="icon"><Icon name="chat" size={26}/></div>
          <div><div className="l">Text us</div><div className="v"><a href="sms:+15036208518">Send a text</a></div></div>
        </div>
        <div className="f-hours">
          <h4><Icon name="clock" size={16} color="currentColor"/> Hours this week</h4>
          {days.map(([d,t],i) => (
            <div key={d} className={`row ${i===today?"now":""}`}>
              <span className="d">{d}</span>
              <span className="t">{t}</span>
            </div>
          ))}
        </div>
        <a href="https://www.google.com/maps/search/?api=1&query=Tigard+Donut+13815+SW+Pacific+Hwy+Tigard+OR+97223" className="f-btn pink huge"><Icon name="pin" size={22}/>Get directions</a>
      </div>
      <div className="f-map">
        <div className="grid-bg"/>
        <div className="road h"><div className="lane"/></div>
        <div className="road v"/>
        <div className="pin">
          <span className="label">Tigard Donut</span>
          <span className="marker"/>
        </div>
        <div className="f-map-sticker">We're here! →</div>
      </div>
    </section>

    <section className="f-faq" id="faq">
      <div className="f-faq-wrap">
        <h2>Common questions</h2>
        <details open>
          <summary>How early should I order?</summary>
          <p>For 6 to 12 donuts, you can call as early as 5 AM and pick up the same morning. For two dozen or more, please order the day before so we can make sure we have what you need.</p>
        </details>
        <details>
          <summary>Can I just walk in?</summary>
          <p>Yes! Walk-ins are always welcome. Ordering ahead just means your box will be ready when you arrive.</p>
        </details>
        <details>
          <summary>Do you take credit cards?</summary>
          <p>Yes, we take all major credit and debit cards, plus cash. We can also do Venmo for big orders.</p>
        </details>
        <details>
          <summary>Do you have gluten-free or vegan options?</summary>
          <p>We don't, sorry — everything is made fresh in our small kitchen with shared equipment. Please call if you have specific allergy questions.</p>
        </details>
        <details>
          <summary>What if I need to change my order?</summary>
          <p>Just call us at (503) 620-8518. We're happy to adjust anything as long as we haven't started boxing.</p>
        </details>
      </div>
    </section>

    <footer className="f-foot">
      <img src="./assets/td-logo.jpg" alt="Tigard Donut" className="f-foot-logo"/>
      <h3>Have a <span className="pink">sweet</span> day!</h3>
      <p>Family-owned in Tigard · Est. 2003.</p>
      <div className="f-foot-cta">
        <a href="tel:+15036208518" className="f-btn pink"><Icon name="phone" size={20}/>Call (503) 620-8518</a>
        <a href="sms:+15036208518" className="f-btn pink"><Icon name="chat" size={20}/>Text the Shop</a>
        <a href="#order" className="f-btn butter"><Icon name="box" size={20}/>Order online</a>
        <a href="https://www.doordash.com/store/tigard-donut-portland-36659779/82163749/" target="_blank" rel="noopener" className="f-btn white">Order on DoorDash</a>
        <a href="https://www.yelp.com/biz/tigard-donut-portland-2" target="_blank" rel="noopener" className="f-btn white">Read Yelp Reviews</a>
        <a href="https://www.instagram.com/tigarddonut/" target="_blank" rel="noopener" className="f-btn white"><Icon name="ig" size={20}/>@tigarddonut</a>
      </div>
      <div className="f-foot-bottom">
        <span>© 2026 Tigard Donut · 13815 SW Pacific Hwy</span>
        <span>Est. 2003</span>
      </div>
    </footer>
  </>;
};

ReactDOM.createRoot(document.getElementById("app")).render(<App/>);
