// Hawaiian Style — Marketing site composite components.
// Depends on Primitives.jsx (Pill, Eyebrow, Headline, etc on window).

// Top promo bar — rotates 3 messages on a 4s cycle.
// Scrolls away on its own (NOT sticky). The Nav below it stays sticky.
const TopBar = () => {
  const { useState, useEffect } = React;
  const messages = [
    { txt: 'Free shipping on orders over ฿500',          script: 'across Thailand' },
    { txt: 'Made in Thailand since 1995',                script: 'reef-safe formulas' },
    { txt: 'Kona Club members get 15% off first bottle', script: "join free" },
    { txt: 'Now in 14,000+ stores nationwide',           script: 'pick a beach' },
  ];
  const [i, setI] = useState(0);
  useEffect(() => {
    const id = setInterval(() => setI(n => (n + 1) % messages.length), 4000);
    return () => clearInterval(id);
  }, []);
  const m = messages[i];
  return (
    <div style={{
      background: 'var(--brown)', color: 'var(--paper)',
      borderBottom: '1.5px solid rgba(252, 213, 182, 0.15)',
      overflow: 'hidden',
    }}>
      <div style={{
        maxWidth: 1320, margin: '0 auto', padding: '10px 36px',
        display: 'flex', alignItems: 'center', justifyContent: 'center', gap: 16,
        minHeight: 40,
      }}>
        <span style={{ fontFamily: 'var(--font-display)', fontSize: 12, letterSpacing: '0.18em', textTransform: 'uppercase', color: 'var(--sun)' }}>★</span>
        <span key={`txt-${i}`} style={{
          fontFamily: 'var(--font-body)', fontSize: 12, fontWeight: 700,
          letterSpacing: '0.14em', textTransform: 'uppercase',
          animation: 'hws-fade-in .4s ease-out',
        }}>{m.txt}</span>
        <span style={{ color: 'var(--orange)' }}>·</span>
        <span key={`scr-${i}`} style={{
          fontFamily: 'var(--font-script)', fontSize: 18,
          color: 'var(--sun)', lineHeight: 1, transform: 'translateY(-1px)',
          animation: 'hws-fade-in .4s ease-out',
        }}>{m.script}</span>
        <span style={{ color: 'var(--orange)' }}>·</span>
        <span style={{ fontFamily: 'var(--font-mono)', fontSize: 10, letterSpacing: '0.18em', color: 'rgba(252,213,182,0.55)' }}>EST. 1995</span>
      </div>
      <style>{`@keyframes hws-fade-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }`}</style>
    </div>
  );
};

const Nav = ({ cartCount = 0, onCartClick }) => {
  const { useState, useEffect } = React;
  const [shopOpen, setShopOpen] = useState(false);
  const [schoolOpen, setSchoolOpen] = useState(false);
  const [drawerOpen, setDrawerOpen] = useState(false);
  const [liveCount, setLiveCount] = useState(cartCount);

  // Close drawer on Esc + on link click + lock body scroll while open.
  useEffect(() => {
    if (!drawerOpen) { document.body.style.overflow = ""; return; }
    document.body.style.overflow = "hidden";
    const onKey = (e) => { if (e.key === "Escape") setDrawerOpen(false); };
    window.addEventListener("keydown", onKey);
    return () => { window.removeEventListener("keydown", onKey); document.body.style.overflow = ""; };
  }, [drawerOpen]);

  // Keep the badge in sync with localStorage cart across pages.
  useEffect(() => {
    const read = () => {
      try {
        const raw = localStorage.getItem('hws-cart-v1');
        if (!raw) return cartCount;
        const arr = JSON.parse(raw);
        return arr.reduce((s, it) => s + (it.qty || 1), 0);
      } catch { return cartCount; }
    };
    setLiveCount(read());
    const onChange = () => setLiveCount(read());
    window.addEventListener('hws-cart-changed', onChange);
    window.addEventListener('storage', onChange);
    return () => {
      window.removeEventListener('hws-cart-changed', onChange);
      window.removeEventListener('storage', onChange);
    };
  }, [cartCount]);

  const displayCount = Math.max(cartCount, liveCount);

  const shopItems = [
    { label: 'Tanning', href: '/#tanning' },
    { label: 'Aftersun', href: '/#aftersun' },
    { label: 'Sunblock', href: '/#sunblock' },
    { label: 'Merch', href: '/#merch' },
    { label: 'Shop All', href: '/#bestsellers' },
  ];

  const schoolItems = [
    { label: 'Sun School', href: '/sun-school' },
    { label: 'Postcards from the beach', href: '/#reviews' },
    { label: 'FAQ', href: '/faq' },
  ];

  const links = [
    { label: 'Kona Club', href: '/#beachclub' },
    { label: 'Our Story', href: '/#our-story' },
    { label: 'Where to Buy', href: '/#where-to-buy' },
  ];

  return (
  <nav style={{
    position: 'sticky', top: 0, zIndex: 100,
    background: 'rgba(245, 231, 206, 0.88)',
    backdropFilter: 'blur(10px)', WebkitBackdropFilter: 'blur(10px)',
    borderBottom: '1.5px solid rgba(61, 47, 35, 0.12)',
  }}>
    <div style={{
      maxWidth: 1320, margin: '0 auto',
      display: 'flex', alignItems: 'center', justifyContent: 'space-between',
      padding: '14px 36px', gap: 32,
    }}>
      <a href="/" style={{ display: 'flex', alignItems: 'center', gap: 14, color: 'var(--brown)', textDecoration: 'none' }}>
        <img src="assets/logos/hws-official-stacked-black.png" alt="Hawaiian Style" style={{ height: 86, width: 'auto' }} />
        <div style={{ display: 'flex', flexDirection: 'column', lineHeight: 1 }}>
          <span style={{ fontFamily: 'var(--font-display)', fontSize: 22, letterSpacing: '0.04em', textTransform: 'uppercase' }}>Hawaiian Style</span>
          <span style={{ fontFamily: 'var(--font-script)', fontSize: 18, color: 'var(--orange)', marginTop: 4 }}>est. 1995</span>
        </div>
      </a>
      <div className="hws-nav-center" style={{ display: 'flex', gap: 32, fontSize: 15, fontFamily: 'var(--font-body)', fontWeight: 700, textTransform: 'uppercase', letterSpacing: '0.08em', alignItems: 'center' }}>
        {/* SHOP — dropdown */}
        <div
          style={{ position: 'relative' }}
          onMouseEnter={() => setShopOpen(true)}
          onMouseLeave={() => setShopOpen(false)}
        >
          <a href="/#bestsellers" style={{
              color: shopOpen ? 'var(--orange)' : 'var(--brown)',
              textDecoration: 'none', padding: '4px 0',
              display: 'inline-flex', alignItems: 'center', gap: 6,
              transition: 'color .2s',
            }}>
            Shop
            <svg width="10" height="10" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"
              style={{ transform: shopOpen ? 'rotate(180deg)' : 'rotate(0)', transition: 'transform .2s' }}>
              <polyline points="3,4.5 6,7.5 9,4.5"/>
            </svg>
          </a>
          {/* Dropdown */}
          <div style={{
            position: 'absolute', top: 'calc(100% + 8px)', left: -14,
            minWidth: 184,
            background: 'var(--paper-soft)',
            border: '1.5px solid rgba(61, 47, 35, 0.15)',
            borderRadius: 14,
            boxShadow: '0 18px 40px -16px rgba(61, 47, 35, 0.35), 0 4px 0 rgba(61, 47, 35, 0.08)',
            padding: '8px',
            opacity: shopOpen ? 1 : 0,
            visibility: shopOpen ? 'visible' : 'hidden',
            transform: shopOpen ? 'translateY(0)' : 'translateY(-6px)',
            transition: 'opacity .18s, transform .18s, visibility .18s',
          }}>
            {shopItems.map((it, i) => (
              <a key={it.label} href={it.href} style={{
                display: 'block',
                padding: '10px 14px',
                color: 'var(--brown)',
                fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 12,
                letterSpacing: '0.1em', textTransform: 'uppercase',
                textDecoration: 'none',
                borderRadius: 8,
                transition: 'background .15s, color .15s',
                borderTop: i === shopItems.length - 1 ? '1.5px solid rgba(61, 47, 35, 0.10)' : 'none',
                marginTop: i === shopItems.length - 1 ? 4 : 0,
                paddingTop: i === shopItems.length - 1 ? 14 : 10,
              }}
                onMouseOver={e => { e.currentTarget.style.background = 'var(--sun)'; e.currentTarget.style.color = 'var(--brown)'; }}
                onMouseOut={e => { e.currentTarget.style.background = 'transparent'; e.currentTarget.style.color = 'var(--brown)'; }}
              >{it.label}</a>
            ))}
          </div>
        </div>

        {/* SUN SCHOOL — dropdown */}
        <div
          style={{ position: 'relative' }}
          onMouseEnter={() => setSchoolOpen(true)}
          onMouseLeave={() => setSchoolOpen(false)}
        >
          <a href="/sun-school" style={{
              color: schoolOpen ? 'var(--orange)' : 'var(--brown)',
              textDecoration: 'none', padding: '4px 0',
              display: 'inline-flex', alignItems: 'center', gap: 6,
              transition: 'color .2s',
            }}>
            Sun School
            <svg width="10" height="10" viewBox="0 0 12 12" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"
              style={{ transform: schoolOpen ? 'rotate(180deg)' : 'rotate(0)', transition: 'transform .2s' }}>
              <polyline points="3,4.5 6,7.5 9,4.5"/>
            </svg>
          </a>
          <div style={{
            position: 'absolute', top: 'calc(100% + 8px)', left: -14,
            minWidth: 224,
            background: 'var(--paper-soft)',
            border: '1.5px solid rgba(61, 47, 35, 0.15)',
            borderRadius: 14,
            boxShadow: '0 18px 40px -16px rgba(61, 47, 35, 0.35), 0 4px 0 rgba(61, 47, 35, 0.08)',
            padding: '8px',
            opacity: schoolOpen ? 1 : 0,
            visibility: schoolOpen ? 'visible' : 'hidden',
            transform: schoolOpen ? 'translateY(0)' : 'translateY(-6px)',
            transition: 'opacity .18s, transform .18s, visibility .18s',
          }}>
            {schoolItems.map((it) => (
              <a key={it.label} href={it.href} style={{
                display: 'block', padding: '10px 14px',
                color: 'var(--brown)',
                fontFamily: 'var(--font-body)', fontWeight: 700, fontSize: 12,
                letterSpacing: '0.1em', textTransform: 'uppercase',
                textDecoration: 'none', borderRadius: 8,
                transition: 'background .15s, color .15s',
              }}
                onMouseOver={e => { e.currentTarget.style.background = 'var(--sun)'; e.currentTarget.style.color = 'var(--brown)'; }}
                onMouseOut={e => { e.currentTarget.style.background = 'transparent'; e.currentTarget.style.color = 'var(--brown)'; }}
              >{it.label}</a>
            ))}
          </div>
        </div>

        {/* Other links */}
        {links.map(l =>
          <a key={l.label} href={l.href}
            style={{ color: 'var(--brown)', textDecoration: 'none', padding: '4px 0', transition: 'color .2s' }}
            onMouseOver={e => e.currentTarget.style.color = 'var(--orange)'}
            onMouseOut={e => e.currentTarget.style.color = 'var(--brown)'}>
            {l.label}
          </a>
        )}
      </div>
      <div className="hws-nav-right" style={{ display: 'flex', alignItems: 'center', gap: 14 }}>
        <Pill variant="sun" size="sm" href="/#bestsellers">Shop Now →</Pill>
        <a href="/checkout" aria-label="Cart" style={{
          width: 40, height: 40, borderRadius: 999, background: 'var(--brown)', color: 'var(--paper)',
          display: 'grid', placeItems: 'center', fontFamily: 'var(--font-body)', fontWeight: 800, fontSize: 13,
          textDecoration: 'none', position: 'relative',
        }}>
          {displayCount}
        </a>
        <button className="hws-nav-burger" aria-label="Open menu" onClick={() => setDrawerOpen(true)} style={{
          display: "none", width: 44, height: 44, borderRadius: 12,
          background: "transparent", border: "1.5px solid rgba(61,47,35,0.2)",
          color: "var(--brown)", cursor: "pointer", padding: 0,
          alignItems: "center", justifyContent: "center",
        }}>
          <svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round">
            <line x1="4" y1="7"  x2="20" y2="7"/>
            <line x1="4" y1="12" x2="20" y2="12"/>
            <line x1="4" y1="17" x2="20" y2="17"/>
          </svg>
        </button>
      </div>
    </div>
    {ReactDOM.createPortal(
      <React.Fragment>
        {/* Mobile drawer (only visible ≤760px via CSS) */}
        <div className="hws-drawer-backdrop" data-open={drawerOpen} onClick={() => setDrawerOpen(false)} />
        <aside className="hws-drawer" data-open={drawerOpen} aria-hidden={!drawerOpen}>
          <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center", padding: "20px 22px 14px", borderBottom: "1.5px solid rgba(61,47,35,0.1)" }}>
            <span style={{ fontFamily: "var(--font-display)", fontSize: 16, letterSpacing: "0.08em", textTransform: "uppercase", color: "var(--brown)" }}>Menu</span>
            <button onClick={() => setDrawerOpen(false)} aria-label="Close menu" style={{
              width: 36, height: 36, borderRadius: 10, background: "transparent",
              border: "1.5px solid rgba(61,47,35,0.2)", color: "var(--brown)",
              cursor: "pointer", padding: 0, display: "grid", placeItems: "center",
            }}>
              <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.4" strokeLinecap="round">
                <line x1="6" y1="6" x2="18" y2="18"/><line x1="18" y1="6" x2="6" y2="18"/>
              </svg>
            </button>
          </div>
          <nav style={{ padding: "10px 14px 22px", display: "flex", flexDirection: "column" }}>
            {/* Shop section */}
            <div className="hws-drawer-section-label">Shop</div>
            {shopItems.map(it => (
              <a key={"shop-"+it.label} href={it.href} className="hws-drawer-link" onClick={() => setDrawerOpen(false)}>{it.label}</a>
            ))}
            <div className="hws-drawer-divider" />
            <div className="hws-drawer-section-label">Sun School</div>
            {schoolItems.map(it => (
              <a key={"sch-"+it.label} href={it.href} className="hws-drawer-link" onClick={() => setDrawerOpen(false)}>{it.label}</a>
            ))}
            <div className="hws-drawer-divider" />
            <div className="hws-drawer-section-label">Explore</div>
            {links.map(l => (
              <a key={"lnk-"+l.label} href={l.href} className="hws-drawer-link" onClick={() => setDrawerOpen(false)}>{l.label}</a>
            ))}
            <div className="hws-drawer-divider" />
            <Pill variant="sun" href="/#bestsellers" onClick={() => setDrawerOpen(false)} style={{ marginTop: 18 }}>Shop Now →</Pill>
          </nav>
        </aside>
      </React.Fragment>,
      document.body
    )}
  </nav>
  );
};

const Hero = () => (
  <header role="banner" style={{ position: 'relative', maxWidth: 1320, margin: '0 auto', padding: '32px 36px 60px' }}>
    <div style={{ display: 'grid', gridTemplateColumns: '1.05fr 0.95fr', gap: 40, alignItems: 'stretch' }}>
      {/* TEXT */}
      <div style={{ padding: '16px 0 0', display: 'flex', flexDirection: 'column', justifyContent: 'space-between', minHeight: 620 }}>
        <div>
          <Eyebrow>Analog Life · Born for Sunshine · Est. 1995</Eyebrow>
          <h1 style={{
            fontFamily: 'var(--font-display)', fontWeight: 400,
            fontSize: 'clamp(72px, 9.5vw, 168px)', lineHeight: 0.92,
            letterSpacing: '0.005em', textTransform: 'uppercase',
            color: 'var(--brown)', margin: '20px 0 0',
          }}>
            <span style={{ display: 'block' }}>Embrace</span>
            <span style={{ display: 'block' }}>the <span style={{ color: 'var(--orange)' }}>Sun</span>,</span>
            <span style={{
              display: 'block', fontFamily: 'var(--font-script)', textTransform: 'none',
              fontSize: '0.78em', color: 'var(--orange)',
              transform: 'rotate(-4deg) translateY(-0.08em)', lineHeight: 0.9,
            }}>adventure</span>
            <span style={{ display: 'block' }}>Unbound.</span>
          </h1>
          <p style={{ fontSize: 18, color: 'var(--brown-soft)', maxWidth: 480, marginTop: 28, lineHeight: 1.55 }}>
            Golden beach days, island escapes, and every outdoor adventure under the warmest sky. Tropical sun care from Thailand, the way summer's supposed to feel.
          </p>
          <p style={{ fontFamily: 'var(--font-thai)', fontSize: 14, color: 'var(--brown-soft)', marginTop: 12, opacity: 0.75 }}>
            โอบรับแสงแดด ปลดปล่อยทุกการผจญภัย — ตั้งแต่ปี 1995
          </p>
          <div style={{ display: 'flex', gap: 14, flexWrap: 'wrap', marginTop: 32 }}>
            <Pill variant="sun" href="/#bestsellers">Shop Now</Pill>
            <Pill variant="ghost" href="/#range">Explore Sun Care</Pill>
          </div>
        </div>
        <div style={{
          display: 'flex', gap: 28, marginTop: 48,
          borderTop: '2px solid rgba(61, 47, 35, 0.18)', paddingTop: 22,
        }}>
          {[
            { num: '30+', lbl: 'Years on the beach' },
            { num: 'SPF 50', lbl: 'Broad spectrum UVA + UVB' },
            { num: '14k', lbl: 'Stores nationwide' },
          ].map(m => (
            <div key={m.lbl}>
              <div style={{ fontFamily: 'var(--font-display)', fontSize: 38, color: 'var(--orange)', lineHeight: 1 }}>{m.num}</div>
              <div style={{ fontSize: 11, color: 'var(--brown-soft)', marginTop: 6, maxWidth: 140, textTransform: 'uppercase', letterSpacing: '0.06em', fontWeight: 600 }}>{m.lbl}</div>
            </div>
          ))}
        </div>
      </div>

      {/* VISUAL */}
      <div style={{
        position: 'relative', borderRadius: 28, overflow: 'hidden',
        background: 'radial-gradient(120% 80% at 65% 25%, #FFE49B 0%, #F7DF4D 30%, #D8721D 65%, #B85C12 100%)',
        boxShadow: 'var(--shadow-lg)', minHeight: 620,
        display: 'flex', alignItems: 'flex-end', justifyContent: 'center',
      }}>
        <div style={{ position: 'absolute', inset: 0, backgroundImage: 'repeating-linear-gradient(135deg, rgba(255,255,255,0.06) 0 2px, transparent 2px 14px)', pointerEvents: 'none' }} />
        <div style={{ position: 'absolute', top: 36, right: 36, zIndex: 6 }}>
          <VintageStamp year="Aloha!" label="Sunshine" />
        </div>
        <div style={{ position: 'absolute', top: 40, left: -10 }}>
          <Doodle.Sun size={110} spin />
        </div>
        <div style={{ position: 'absolute', bottom: '30%', left: 24 }}>
          <Doodle.Palm size={70} />
        </div>
        <div style={{ position: 'absolute', bottom: '16%', right: 32 }}>
          <Doodle.Shell size={60} />
        </div>
        <div style={{ position: 'absolute', top: '60%', right: -50, width: 280, height: 280, borderRadius: '50%',
          background: 'radial-gradient(circle at 35% 35%, #FFE49B 0%, #F7DF4D 60%, #D8721D 100%)',
          boxShadow: '0 0 80px rgba(247, 223, 77, 0.6)', transform: 'translateY(-50%)',
        }} />
        <div style={{ position: 'absolute', left: 0, right: 0, bottom: 0, height: '38%',
          background: 'linear-gradient(180deg, #465975 0%, #2E3D52 100%)',
        }}>
          <svg viewBox="0 0 1200 60" preserveAspectRatio="none" style={{ position: 'absolute', left: 0, right: 0, bottom: '100%', width: '100%', height: 50 }}>
            <path d="M0,40 Q150,5 300,30 T600,30 T900,30 T1200,30 L1200,60 L0,60 Z" fill="#465975"/>
            <path d="M0,50 Q150,20 300,40 T600,40 T900,40 T1200,40 L1200,60 L0,60 Z" fill="#2E3D52" opacity="0.65"/>
          </svg>
        </div>
        {/* Polaroid lifestyle photos — pinned to corners */}
        <div data-polaroid="patong" data-mobile-hide="true" style={{
          position: 'absolute', top: 280, left: '50%', zIndex: 7,
          marginLeft: -64,
          background: 'var(--paper-soft)', padding: '10px 10px 30px',
          boxShadow: '0 14px 24px -8px rgba(0,0,0,0.45), 0 2px 0 rgba(61,47,35,0.2)',
          transform: 'rotate(-5deg)', width: 128,
        }}>
          <div style={{
            width: '100%', aspectRatio: '1 / 1',
            backgroundImage: 'url(assets/imagery/walking-longboard.jpg)',
            backgroundSize: 'cover', backgroundPosition: 'center',
          }} />
          <div style={{ position: 'absolute', left: 0, right: 0, bottom: 6, fontFamily: 'var(--font-script)', fontSize: 15, color: 'var(--brown)', textAlign: 'center' }}>patong, '24</div>
        </div>

        <div data-polaroid="road-trip" data-mobile-hide="true" style={{
          position: 'absolute', top: 170, left: -8, zIndex: 6,
          background: 'var(--paper-soft)', padding: '10px 10px 30px',
          boxShadow: '0 14px 24px -8px rgba(0,0,0,0.45), 0 2px 0 rgba(61,47,35,0.2)',
          transform: 'rotate(-3deg)', width: 120,
        }}>
          <div style={{
            width: '100%', aspectRatio: '1 / 1',
            backgroundImage: 'url(assets/imagery/truck-bed-beach.jpg)',
            backgroundSize: 'cover', backgroundPosition: 'center',
          }} />
          <div style={{ position: 'absolute', left: 0, right: 0, bottom: 6, fontFamily: 'var(--font-script)', fontSize: 14, color: 'var(--brown)', textAlign: 'center' }}>road trip.</div>
        </div>

        <div data-polaroid="just-smile" data-mobile-hide="true" style={{
          position: 'absolute', bottom: 24, left: 18, zIndex: 7,
          background: 'var(--paper-soft)', padding: '10px 10px 30px',
          boxShadow: '0 14px 24px -8px rgba(0,0,0,0.45), 0 2px 0 rgba(61,47,35,0.2)',
          transform: 'rotate(5deg)', width: 120,
        }}>
          <div style={{
            width: '100%', aspectRatio: '1 / 1',
            backgroundImage: 'url(assets/imagery/laughing-palm.jpg)',
            backgroundSize: 'cover', backgroundPosition: 'center',
          }} />
          <div style={{ position: 'absolute', left: 0, right: 0, bottom: 6, fontFamily: 'var(--font-script)', fontSize: 14, color: 'var(--brown)', textAlign: 'center' }}>just smile.</div>
        </div>

        <div data-polaroid="golden-hr" data-mobile-hide="true" style={{
          position: 'absolute', top: 180, right: 22, zIndex: 7,
          background: 'var(--paper-soft)', padding: '10px 10px 32px',
          boxShadow: '0 14px 24px -8px rgba(0,0,0,0.45), 0 2px 0 rgba(61,47,35,0.2)',
          transform: 'rotate(8deg)', width: 128,
        }}>
          <div style={{
            width: '100%', aspectRatio: '1 / 1',
            backgroundImage: 'url(assets/imagery/poolside-bronzed.jpg)',
            backgroundSize: 'cover', backgroundPosition: 'center',
          }} />
          <div style={{ position: 'absolute', left: 0, right: 0, bottom: 6, fontFamily: 'var(--font-script)', fontSize: 15, color: 'var(--brown)', textAlign: 'center' }}>golden hr.</div>
        </div>

        <div data-polaroid="drip" data-mobile-hide="true" style={{
          position: 'absolute', bottom: 200, right: -6, zIndex: 6,
          background: 'var(--paper-soft)', padding: '10px 10px 30px',
          boxShadow: '0 14px 24px -8px rgba(0,0,0,0.45), 0 2px 0 rgba(61,47,35,0.2)',
          transform: 'rotate(-6deg)', width: 122,
        }}>
          <div style={{
            width: '100%', aspectRatio: '1 / 1',
            backgroundImage: 'url(assets/imagery/coconut-oil-drip.jpg)',
            backgroundSize: 'cover', backgroundPosition: 'center',
          }} />
          <div style={{ position: 'absolute', left: 0, right: 0, bottom: 6, fontFamily: 'var(--font-script)', fontSize: 14, color: 'var(--brown)', textAlign: 'center' }}>the drip.</div>
        </div>

        {/* Mascot — Kona surfing, bottom-right, peeking */}
        <img src="assets/mascots/kona-surf.png" alt="Kona"
          style={{
            position: 'absolute', bottom: -8, right: 24, zIndex: 8,
            width: 168, height: 'auto',
            transform: 'rotate(6deg)',
            filter: 'drop-shadow(0 10px 14px rgba(0,0,0,0.35))',
          }} />

        {/* Coco mascot — top-right, smaller sidekick */}
        <img src="assets/mascots/coco-look.png" alt="Coco"
          style={{
            position: 'absolute', top: 14, right: 160, zIndex: 8,
            width: 88, height: 'auto',
            transform: 'rotate(-10deg)',
            filter: 'drop-shadow(0 8px 12px rgba(0,0,0,0.30))',
          }} />
        <div data-hero-script="true" style={{ position: 'absolute', top: '62%', left: '50%', zIndex: 10, transform: 'translate(-50%, -50%) rotate(-8deg)', fontFamily: 'var(--font-script)', color: 'var(--paper)', fontSize: 56, opacity: 0.98, textShadow: '0 3px 8px rgba(0,0,0,0.4)', lineHeight: 0.9, textAlign: 'center', whiteSpace: 'nowrap' }}>
          golden hour, always.
        </div>
      </div>
    </div>
  </header>
);

const Ticker = ({ phrases }) => (
  <div style={{
    background: 'var(--brown)', color: 'var(--paper)', overflow: 'hidden',
    padding: '18px 0', borderTop: '2px solid var(--brown)', borderBottom: '2px solid var(--brown)',
  }}>
    <div style={{ display: 'flex', gap: 50, whiteSpace: 'nowrap', animation: 'hws-scroll 50s linear infinite', alignItems: 'center' }}>
      {[...phrases, ...phrases, ...phrases].map((p, i) => (
        <React.Fragment key={i}>
          {p.script
            ? <span style={{ fontFamily: 'var(--font-script)', fontSize: 32, color: 'var(--sun)', transform: 'translateY(-2px)' }}>{p.script}</span>
            : <span style={{ fontFamily: 'var(--font-display)', fontSize: 26, letterSpacing: '0.04em', textTransform: 'uppercase' }}>{p.txt}</span>}
          <span style={{ width: 10, height: 10, borderRadius: '50%', background: 'var(--orange)', display: 'inline-block' }} />
        </React.Fragment>
      ))}
    </div>
  </div>
);

// Three big category cards: tanning, aftersun, sunblock.
const CategoryCards = () => {
  const cards = [
    {
      slug: 'tanning', tone: 'tanning', soul: true,
      index: 'CATEGORY · 01 — Brand Soul', name: 'Tanning', script: 'a golden ritual',
      desc: 'Coconut tanning oils and accelerators that deepen your color while keeping skin nourished. Caramel skin, sunset moods, the scent of every beach day you\'ll remember.',
      meta: '4 PRODUCTS · START ฿245', cta: 'Enhance Your Glow',
      img: 'assets/products/coconut-tanning-oil.png',
      bg: 'radial-gradient(circle at 80% 10%, rgba(247, 223, 77, 0.5) 0%, transparent 50%), linear-gradient(160deg, #E78930 0%, #B85C12 100%)',
      fg: 'var(--paper)', scriptColor: 'var(--sun)',
    },
    {
      slug: 'aftersun', tone: 'aftersun',
      index: 'CATEGORY · 02', name: 'After\nsun', script: 'the cool down',
      desc: 'Aloe and coconut aftersun lotions and gels. Recover overnight, wake up glowing.',
      meta: '2 PRODUCTS · START ฿245', cta: 'Soothe After Sun',
      img: 'assets/products/after-sun.png',
      bg: 'radial-gradient(circle at 10% 90%, rgba(247, 223, 77, 0.3) 0%, transparent 50%), linear-gradient(160deg, #FCD5B6 0%, #F4BE92 100%)',
      fg: 'var(--brown)', scriptColor: 'var(--orange)',
    },
    {
      slug: 'sunblock', tone: 'sunblock',
      index: 'CATEGORY · 03', name: 'Sun\nblock', script: 'the enabler',
      desc: 'High-performance sunblock from SPF 15 to SPF 50+. Stay out longer, worry less.',
      meta: '3 PRODUCTS · START ฿285', cta: 'Protect Your Skin',
      img: 'assets/products/sunblock-spf50.png',
      bg: 'radial-gradient(circle at 80% 80%, rgba(247, 223, 77, 0.3) 0%, transparent 50%), linear-gradient(160deg, #6E83A0 0%, #465975 100%)',
      fg: 'var(--paper)', scriptColor: 'var(--sun)',
    },
  ];
  return (
    <div className="hws-mobile-scroller" data-scroller-cards="3" style={{ display: 'grid', gridTemplateColumns: '1.2fr 0.9fr 0.9fr', gap: 24 }}>
      {cards.map(c => (
        <a key={c.slug} href={`#${c.slug}`} className="hws-catcard" style={{
          position: 'relative', borderRadius: 24, overflow: 'hidden',
          padding: '36px 32px 32px', minHeight: 520,
          display: 'flex', flexDirection: 'column', justifyContent: 'space-between',
          boxShadow: 'var(--shadow-md)', transition: 'transform .25s, box-shadow .25s',
          color: c.fg, background: c.bg, textDecoration: 'none',
        }}
          onMouseOver={e => { e.currentTarget.style.transform = 'translateY(-4px)'; e.currentTarget.style.boxShadow = 'var(--shadow-lg)'; }}
          onMouseOut={e => { e.currentTarget.style.transform = 'translateY(0)'; e.currentTarget.style.boxShadow = 'var(--shadow-md)'; }}
        >
          {c.soul && <div style={{
            position: 'absolute', top: 26, right: 26, background: 'var(--sun)', color: 'var(--brown)',
            padding: '6px 14px', borderRadius: 999, fontFamily: 'var(--font-script)', fontSize: 18,
            transform: 'rotate(6deg)', zIndex: 2,
          }}>the soul ★</div>}
          <div>
            <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.12em', opacity: 0.7 }}>{c.index}</div>
            <h3 style={{
              fontFamily: 'var(--font-display)', fontSize: c.soul ? 'clamp(48px, 5.4vw, 80px)' : 'clamp(40px, 4.4vw, 64px)',
              marginTop: 14, lineHeight: 0.92, textTransform: 'uppercase', letterSpacing: '0.005em', color: c.fg, whiteSpace: 'pre-line',
            }}>
              {c.name}
              <span style={{
                fontFamily: 'var(--font-script)', textTransform: 'none',
                color: c.scriptColor, fontSize: '0.6em', display: 'block',
                transform: 'rotate(-3deg)', marginTop: '-0.05em', letterSpacing: 0,
              }}>{c.script}</span>
            </h3>
            <p style={{ fontSize: 14, marginTop: 14, maxWidth: 280, fontWeight: 500, opacity: c.fg === 'var(--paper)' ? 0.85 : 1, color: c.fg }}>{c.desc}</p>
          </div>
          <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-end' }}>
            <div>
              <div style={{ fontFamily: 'var(--font-mono)', fontSize: 11, letterSpacing: '0.12em', opacity: 0.7 }}>{c.meta}</div>
              <div style={{ marginTop: 8, fontFamily: 'var(--font-display)', fontSize: c.soul ? 22 : 18, textTransform: 'uppercase' }}>{c.cta}</div>
            </div>
            <div style={{
              width: 56, height: 56, borderRadius: 999, border: `2px solid ${c.fg}`,
              display: 'grid', placeItems: 'center', fontFamily: 'var(--font-display)', fontSize: 24, color: c.fg,
            }}>→</div>
          </div>
          <div className="catcard-product" style={{
            position: 'absolute', right: c.soul ? -30 : -10, bottom: c.soul ? 40 : 50,
            width: c.soul ? 280 : 240, height: c.soul ? 420 : 360,
            display: 'grid', placeItems: 'center', pointerEvents: 'none',
            transition: 'opacity .35s var(--ease-out), transform .35s var(--ease-out)',
          }}>
            <img src={c.img} alt="" style={{ width: '100%', height: '100%', objectFit: 'contain', filter: 'drop-shadow(0 22px 28px rgba(0,0,0,0.4))' }} />
          </div>
        </a>
      ))}
    </div>
  );
};

Object.assign(window, { Nav, TopBar, Hero, Ticker, CategoryCards });
