// D_full_shared.jsx — Direction D · "La Maison"
// Pure white + bordeaux. Heraldic, axial, gallery-editorial.
// Namespace: D (tokens), DBtn, DChip, DEyebrow, DRule, DNav, DFooter, DTicket, etc.

const D = {
  // surfaces
  paper:    '#FFFFFF',       // primary white
  paperAlt: '#FAF7F2',       // warm paper for alt sections
  paperDim: '#F3EEE5',       // rare deeper paper for ledgers / cards
  inkDeep:  '#0E0A08',       // near-black for reverse blocks
  // ink
  ink:      '#1A1512',       // body
  inkSoft:  '#2B2320',       // secondary
  stone:    '#7F756D',       // tertiary
  stoneSoft:'#B5AEA7',
  // accents
  bord:     '#6B1220',       // primary — bordeaux (deeper than Option C)
  bordDeep: '#4A0C18',       // hover / headings
  bordInk:  '#2B0810',       // darkest, only for base
  gold:     '#A8864A',       // very rare — only hairline, seals
  goldSoft: '#C9A961',
  // lines
  line:     'rgba(26,21,18,.14)',
  lineSoft: 'rgba(26,21,18,.07)',
  lineBord: 'rgba(107,18,32,.22)',
  lineGold: 'rgba(168,134,74,.28)',

  // type
  serif: "'Cormorant Garamond', 'EB Garamond', Georgia, serif",
  body:  "'EB Garamond', Georgia, serif",
  sans:  "'Commissioner', -apple-system, sans-serif",  // all-caps labels — tighter than IBM Plex

  // image treatments — duotone bordeaux tint for gallery feel
  imgCard:  'grayscale(.35) sepia(.18) brightness(.98) contrast(1.04) saturate(.85)',
  imgEd:    'grayscale(.55) sepia(.25) brightness(.94) contrast(1.06) saturate(.78)',
  imgHero:  'grayscale(.65) sepia(.3) brightness(.88) contrast(1.08) saturate(.72)',
  imgDeep:  'grayscale(.82) sepia(.45) brightness(.78) contrast(1.12)',
};

// ── Roman numeral helper ─────────────────────────────────────────────────
function toRoman(n) {
  const map = [[1000,'M'],[900,'CM'],[500,'D'],[400,'CD'],[100,'C'],[90,'XC'],
    [50,'L'],[40,'XL'],[10,'X'],[9,'IX'],[5,'V'],[4,'IV'],[1,'I']];
  let r=''; for (const [v,s] of map) while(n>=v){ r+=s; n-=v; } return r;
}

// ── Small atoms ──────────────────────────────────────────────────────────

function DEyebrow({ children, style, tone }) {
  const col = tone==='gold' ? D.gold : tone==='ivory' ? 'rgba(255,255,255,.72)' : D.bord;
  return (
    <div style={{
      fontFamily: D.sans, fontSize: 10, letterSpacing: '.32em', textTransform: 'uppercase',
      color: col, fontWeight: 600, ...style,
    }}>{children}</div>
  );
}

function DLabel({ children, style, tone }) {
  // small-caps serif-like label, quieter than eyebrow
  const col = tone==='ivory' ? 'rgba(255,255,255,.6)' : D.stone;
  return (
    <div style={{ fontFamily: D.sans, fontSize: 9, letterSpacing: '.28em', color: col, fontWeight: 600, textTransform:'uppercase', ...style }}>
      {children}
    </div>
  );
}

// Hairline rule with fleuron center-mark — the signature divider
function DRule({ tone, mark='✦', style, wide=false }) {
  const isDark = tone==='dark';
  const col = isDark ? 'rgba(255,255,255,.35)' : D.lineBord;
  const markCol = isDark ? 'rgba(255,255,255,.85)' : D.bord;
  return (
    <div style={{ display:'flex', alignItems:'center', gap:18, ...style }}>
      <span style={{ flex:1, height:1, background: wide
        ? `linear-gradient(to right, transparent, ${col} 25%, ${col} 100%)` : col }}/>
      <span style={{ fontFamily:D.serif, fontSize:14, color:markCol, letterSpacing:'.4em' }}>{mark}</span>
      <span style={{ flex:1, height:1, background: wide
        ? `linear-gradient(to left, transparent, ${col} 25%, ${col} 100%)` : col }}/>
    </div>
  );
}

// Simple divider
function DDivider({ tone, style }) {
  return <div style={{ height:1, background: tone==='gold' ? D.lineGold : tone==='dark' ? 'rgba(255,255,255,.18)' : D.line, ...style }}/>;
}

// ── Wax seal / heraldic F·2·F monogram — used in nav + seal moments ───────
function DSeal({ size=56, style, tone='bord' }) {
  const col = tone==='ivory' ? '#FFFFFF' : tone==='gold' ? D.gold : D.bord;
  return (
    <svg width={size} height={size} viewBox="0 0 100 100" style={{ display:'block', ...style }}>
      {/* outer ring */}
      <circle cx="50" cy="50" r="48" fill="none" stroke={col} strokeWidth="1"/>
      <circle cx="50" cy="50" r="44" fill="none" stroke={col} strokeWidth="0.6" opacity=".5"/>
      {/* cardinal ticks */}
      {[0,90,180,270].map(a=>(
        <line key={a} x1="50" y1="2" x2="50" y2="8"
          transform={`rotate(${a} 50 50)`} stroke={col} strokeWidth="1"/>
      ))}
      {/* monogram F·2·F */}
      <text x="50" y="58" textAnchor="middle" fontFamily="Cormorant Garamond, serif"
        fontSize="28" fontWeight="300" letterSpacing="2" fill={col}>
        F<tspan fontStyle="italic" fontSize="18" dy="-1">·2·</tspan>F
      </text>
      {/* bottom arc label */}
      <path id={`seal-arc-${size}`} d="M 12 50 A 38 38 0 0 0 88 50" fill="none"/>
      <text fontFamily="Commissioner, sans-serif" fontSize="6" fontWeight="600" letterSpacing="3" fill={col}>
        <textPath href={`#seal-arc-${size}`} startOffset="50%" textAnchor="middle">
          · FABRIC TO FIT · MMXIX ·
        </textPath>
      </text>
    </svg>
  );
}

// ── Buttons ──────────────────────────────────────────────────────────────
function DBtn({ kind='bord', size='md', children, onClick, style, fullWidth }) {
  const base = {
    fontFamily: D.sans, fontWeight: 600, cursor: 'pointer',
    fontSize: size==='sm'?10:size==='lg'?12:11,
    letterSpacing: '.26em', textTransform: 'uppercase',
    padding: size==='sm'?'10px 18px':size==='lg'?'18px 36px':'13px 26px',
    display: 'inline-flex', alignItems: 'center', justifyContent:'center', gap: 12,
    transition: 'all .35s cubic-bezier(0.2,0.8,0.2,1)',
    border:'1px solid', borderRadius:0,
    width: fullWidth ? '100%' : 'auto',
  };
  const kinds = {
    bord:  { background: D.bord, color: '#fff', borderColor: D.bord },
    ink:   { background: 'transparent', color: D.ink, borderColor: D.ink },
    hair:  { background: 'transparent', color: D.bord, borderColor: D.bord },
    ghost: { background: 'transparent', color: '#fff', borderColor: 'rgba(255,255,255,.45)' },
    gold:  { background: 'transparent', color: D.bordDeep, borderColor: D.gold },
    link:  { background: 'transparent', color: D.bord, borderColor: 'transparent', padding:0 },
  };
  return (
    <span onClick={onClick} style={{ ...base, ...kinds[kind], ...(style||{}) }}>
      {children}
    </span>
  );
}

function DChip({ children, active, onClick, tone='light', style }) {
  return (
    <span onClick={onClick} style={{
      fontFamily: D.sans, fontSize: 10, letterSpacing: '.24em', textTransform: 'uppercase', fontWeight: 600,
      padding: '9px 16px', cursor: 'pointer',
      border: `1px solid ${active ? D.bord : (tone==='dark' ? 'rgba(255,255,255,.3)' : D.line)}`,
      background: active ? D.bord : 'transparent',
      color: active ? '#fff' : (tone==='dark' ? 'rgba(255,255,255,.85)' : D.ink),
      transition: 'all .3s cubic-bezier(0.2,0.8,0.2,1)',
      ...style,
    }}>{children}</span>
  );
}

function formatVND(n) { return n.toLocaleString('vi-VN') + '₫'; }

// ── Occasion model ────────────────────────────────────────────────────────
const OCCASIONS = [
  { id:'engagement', t:'Lễ hỏi',   s:'Của bạn, của em, hoặc của chính anh',           img:'assets/photos/editorial_02.jpg', tone:D.bord,    n:34 },
  { id:'gala',       t:'Gala',     s:'Nơi máy quay sẽ tìm anh',                        img:'assets/photos/editorial_04.jpg', tone:D.inkSoft, n:22 },
  { id:'boardroom',  t:'Hội nghị', s:'Nơi quý này được đặt trên bàn',                   img:'assets/photos/editorial_05.jpg', tone:'#2A3D2E', n:18 },
  { id:'wedding',    t:'Lễ cưới',  s:'Của chính bạn — tại bàn thờ',                     img:'assets/photos/editorial_06.jpg', tone:D.bordDeep,n:12 },
  { id:'premiere',   t:'Khai mạc', s:'Cocktail. Một buổi ra mắt. Một lời chúc.',        img:'assets/photos/editorial_07.jpg', tone:'#3E1318', n:28 },
  { id:'dinner',     t:'Bữa tối',  s:'Nhỏ. Quan trọng. Không biên bản.',                img:'assets/photos/editorial_01.jpg', tone:'#8B6E4A', n:41 },
];

// ── Products ──────────────────────────────────────────────────────────────
const GARMENTS = [
  { id:'berkeley', name:'Berkeley',  sub:'Xám than',       mill:'Holland & Sherry · 240gr', occ:['engagement','boardroom','gala'], events:['le-hoi','phong-van','tot-nghiep','gala'],              price:2800000, days:4, next:'3 Thg 5',  img:'assets/photos/product_01.jpg', images:['assets/photos/product_01.jpg','assets/photos/product_02.jpg'], sizes:['M','L','XL'],     badge:null,             desc:'Worsted ba mảnh, cho căn phòng nơi sự chú ý lặng lẽ là tiền tệ.' },
  { id:'mayfair',  name:'Mayfair',   sub:'Đen đêm',        mill:'Scabal · 260gr',            occ:['gala','premiere','wedding'],     events:['gala','dam-cuoi','da-tiec','ky-niem'],                price:3200000, days:4, next:'11 Thg 5', img:'assets/photos/product_03.jpg', images:['assets/photos/product_03.jpg','assets/photos/product_04.jpg'], sizes:['S','M','L'],     badge:'ĐƯỢC ƯA CHUỘNG', desc:'Tuxedo cắt sắc đủ để máy quay tìm bạn.' },
  { id:'bordeaux', name:'Bordeaux',  sub:'Nhung rượu',      mill:'Dormeuil · 340gr',          occ:['gala','premiere'],               events:['gala','ky-niem','dam-cuoi','da-tiec'],                price:3600000, days:4, next:'9 Thg 5',  img:'assets/photos/product_04.jpg', images:['assets/photos/product_04.jpg','assets/photos/product_05.jpg'], sizes:['M','L'],         badge:'MỚI',            desc:'Dinner jacket, cho căn phòng ngoảnh lại khi bạn bước vào.' },
  { id:'saigon',   name:'Saigon',    sub:'Linen ngà',       mill:'Loro Piana · 190gr',        occ:['dinner','premiere'],             events:['da-tiec','tiec-cong-ty','ky-niem'],                   price:2400000, days:4, next:'7 Thg 5',  img:'assets/photos/product_02.jpg', images:['assets/photos/product_02.jpg','assets/photos/product_01.jpg'], sizes:['S','M','L','XL'],badge:null,             desc:'Áo khoác mùa hè cho buổi tối ngoài vườn.' },
  { id:'hanoi',    name:'Hanoi',     sub:'Tweed thông',     mill:'VBC · 310gr',               occ:['boardroom','dinner'],            events:['phong-van','tot-nghiep','tiec-cong-ty','le-hoi'],     price:2600000, days:4, next:'15 Thg 5', img:'assets/photos/product_05.jpg', images:['assets/photos/product_05.jpg','assets/photos/product_06.jpg'], sizes:['M','L'],         badge:null,             desc:'Đường may thôn quê, cho căn phòng có lò sưởi.' },
  { id:'cannes',   name:'Cannes',    sub:'Camel cashmere',  mill:'Loro Piana · 220gr',        occ:['premiere','dinner'],             events:['ky-niem','da-tiec','tot-nghiep'],                     price:2900000, days:4, next:'6 Thg 5',  img:'assets/photos/product_06.jpg', images:['assets/photos/product_06.jpg','assets/photos/product_03.jpg'], sizes:['S','M'],         badge:'CÒN 2 BỘ',      desc:'Áo khoác cashmere cho đoạn dạo đầu.' },
];

// ── Active occasion session state ─────────────────────────────────────────
const OCC_KEY_D = 'f2f-d-active-occ';
function readActiveOccD() { try { return localStorage.getItem(OCC_KEY_D) || null; } catch { return null; } }
function setActiveOccD(id) {
  try { if (id) localStorage.setItem(OCC_KEY_D, id); else localStorage.removeItem(OCC_KEY_D); } catch {}
  window.dispatchEvent(new CustomEvent('f2f:d-occ-change', { detail:{ id } }));
}

// ── Nav — axial, heraldic lockup centered ────────────────────────────────
function DNav({ page, go }) {
  const tabs = [
    ['occasions', 'Sự kiện'],
    ['collection','Tủ đồ'],
    ['story',     'Câu chuyện 87%'],
    ['account',   'Tủ của tôi'],
  ];
  return (
    <div data-f2f-nav="true" style={{ background:D.paper }}>
      {/* Top strip — bordeaux, very thin */}
      <div style={{ background: D.bord, color: '#fff', padding:'7px 44px',
        display:'flex', justifyContent:'space-between', alignItems:'center',
        fontFamily:D.sans, fontSize:9, letterSpacing:'.36em', textTransform:'uppercase', fontWeight:600 }}>
        <span style={{ opacity:.85 }}>· Một sự kiện, một bộ vest — không cần cả tủ đồ ·</span>
        <span style={{ display:'flex', gap:22, alignItems:'center' }}>
          <span style={{ opacity:.85 }}>VI</span>
          <span style={{ opacity:.4 }}>EN</span>
          <span style={{ opacity:.3 }}>·</span>
          <span style={{ cursor:'pointer' }} onClick={()=>go('showroom')}>Ghé 142 Lê Thánh Tôn →</span>
        </span>
      </div>

      {/* Main row — three columns, centered heraldic lockup */}
      <div style={{ padding:'22px 44px', borderBottom:`1px solid ${D.line}`,
        display:'grid', gridTemplateColumns:'1fr auto 1fr', alignItems:'center', gap:24 }}>

        {/* Left tabs */}
        <div style={{ display:'flex', gap:30, fontFamily:D.sans, fontSize:10, letterSpacing:'.28em', textTransform:'uppercase', fontWeight:600 }}>
          {tabs.slice(0,3).map(([k,l])=>(
            <span key={k} onClick={()=>go(k)} style={{
              cursor:'pointer', color: page===k ? D.bord : D.ink,
              paddingBottom:4, borderBottom: page===k ? `1px solid ${D.bord}` : '1px solid transparent',
              transition:'color .2s',
            }}>{l}</span>
          ))}
        </div>

        {/* Center — F·2·F serif monogram flanked by hairlines */}
        <div onClick={()=>go('home')} style={{ cursor:'pointer', display:'flex', alignItems:'center', gap:14 }}>
          <span style={{ width:36, height:1, background:D.lineBord }}/>
          <div style={{ fontFamily:D.serif, fontSize:38, fontWeight:300, letterSpacing:'.14em', color:D.ink, lineHeight:1 }}>
            F<span style={{ fontStyle:'italic', color:D.bord, fontSize:26, margin:'0 3px' }}>·2·</span>F
          </div>
          <span style={{ width:36, height:1, background:D.lineBord }}/>
        </div>

        {/* Right — account + CTA */}
        <div style={{ display:'flex', gap:22, alignItems:'center', justifyContent:'flex-end', fontFamily:D.sans, fontSize:10, letterSpacing:'.28em', textTransform:'uppercase', fontWeight:600 }}>
          <span onClick={()=>go('account')} style={{ cursor:'pointer', color: page==='account' ? D.bord : D.ink }}>
            Tủ của tôi
          </span>
          <DBtn kind="bord" size="sm" onClick={()=>go('occasions')}>Chọn bộ vest</DBtn>
        </div>
      </div>
    </div>
  );
}

// ── Sticky breadcrumb ────────────────────────────────────────────────────
function DStickyBreadcrumb({ page, go }) {
  const [occId, setOccId] = React.useState(readActiveOccD());
  const [open, setOpen]   = React.useState(false);
  const [visible, setVisible] = React.useState(false);

  React.useEffect(() => {
    const h = (e) => setOccId(e.detail?.id || readActiveOccD());
    window.addEventListener('f2f:d-occ-change', h);
    return () => window.removeEventListener('f2f:d-occ-change', h);
  }, []);

  const suppressed = page === 'home' || page === 'occasions' || page === 'story' || page === 'confirm';
  const shouldShow = !!occId && !suppressed;

  React.useEffect(() => {
    if (shouldShow) { const t = setTimeout(() => setVisible(true), 40); return () => clearTimeout(t); }
    setVisible(false);
  }, [shouldShow]);

  React.useEffect(() => {
    if (!open) return;
    const h = () => setOpen(false);
    window.addEventListener('click', h);
    return () => window.removeEventListener('click', h);
  }, [open]);

  if (!shouldShow) return null;
  const occ = OCCASIONS.find(o => o.id === occId);
  if (!occ) return null;

  return (
    <div style={{
      position:'sticky', top:0, zIndex:40,
      background:D.paper, borderBottom:`1px solid ${D.line}`,
      transform: visible ? 'translateY(0)' : 'translateY(-100%)',
      transition:'transform .45s cubic-bezier(0.2,0.8,0.2,1)',
    }}>
      <div style={{ height:2, background:`linear-gradient(to right, transparent, ${D.bord} 20%, ${D.bord} 80%, transparent)` }}/>
      <div style={{ maxWidth:1440, margin:'0 auto', padding:'13px 44px',
        display:'flex', alignItems:'center', gap:24, justifyContent:'space-between' }}>
        <div style={{ display:'flex', alignItems:'center', gap:14, flex:1, minWidth:0 }}>
          <DLabel>Phiên của bạn ·</DLabel>
          <span style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:17, color:D.inkSoft, whiteSpace:'nowrap' }}>
            đang xem đồ cho
          </span>
          <span style={{ display:'inline-flex', alignItems:'center', gap:10,
            background:D.paper, border:`1px solid ${D.bord}`, padding:'6px 14px', whiteSpace:'nowrap' }}>
            <span style={{ width:6, height:6, borderRadius:'50%', background:occ.tone }}/>
            <span style={{ fontFamily:D.serif, fontSize:17, color:D.bord, lineHeight:1 }}>{occ.t}</span>
            <span style={{ fontFamily:D.sans, fontSize:9, color:D.stone, letterSpacing:'.22em', fontWeight:600 }}>· {occ.n} BỘ</span>
          </span>
          <span style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:15, color:D.stone, whiteSpace:'nowrap', overflow:'hidden', textOverflow:'ellipsis' }}>
            — {occ.s.toLowerCase()}
          </span>
        </div>
        <div style={{ display:'flex', alignItems:'center', gap:18, flexShrink:0 }}>
          <div style={{ position:'relative' }} onClick={(e)=>e.stopPropagation()}>
            <button onClick={()=>setOpen(v=>!v)}
              style={{ background:'transparent', border:'none', cursor:'pointer',
                fontFamily:D.sans, fontSize:10, letterSpacing:'.26em', color:D.ink,
                fontWeight:600, textTransform:'uppercase', padding:'6px 0',
                display:'flex', alignItems:'center', gap:8 }}>
              Đổi sự kiện
              <span style={{ fontSize:11, transform: open?'rotate(180deg)':'none', transition:'transform .2s' }}>▾</span>
            </button>
            {open && (
              <div style={{ position:'absolute', right:0, top:'calc(100% + 10px)',
                background:D.paper, border:`1px solid ${D.bord}`, minWidth:300, zIndex:100,
                boxShadow:'0 18px 48px rgba(28,21,18,.14)' }}>
                <div style={{ padding:'12px 16px', borderBottom:`1px solid ${D.lineSoft}`, background:D.paperAlt }}>
                  <DLabel>Đổi sang sự kiện khác</DLabel>
                </div>
                {OCCASIONS.map(o=>(
                  <div key={o.id} onClick={()=>{ setActiveOccD(o.id); setOpen(false); if (page==='collection') go('collection', { occ:o.id }); }}
                    style={{ padding:'12px 16px', cursor:'pointer',
                      display:'flex', alignItems:'center', justifyContent:'space-between', gap:12,
                      background: o.id===occId ? D.paperAlt : 'transparent',
                      borderBottom:`1px solid ${D.lineSoft}` }}
                    onMouseEnter={(e)=>{ if (o.id!==occId) e.currentTarget.style.background=D.paperAlt; }}
                    onMouseLeave={(e)=>{ if (o.id!==occId) e.currentTarget.style.background='transparent'; }}>
                    <div style={{ display:'flex', alignItems:'center', gap:12 }}>
                      <span style={{ width:7, height:7, borderRadius:'50%', background:o.tone }}/>
                      <div>
                        <div style={{ fontFamily:D.serif, fontSize:16, color:D.ink, lineHeight:1.1 }}>{o.t}</div>
                        <div style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:12, color:D.stone, marginTop:2 }}>{o.s}</div>
                      </div>
                    </div>
                    <span style={{ fontFamily:D.sans, fontSize:9, color:D.stone, letterSpacing:'.22em', fontWeight:600 }}>{o.n}</span>
                  </div>
                ))}
                <div onClick={()=>{ setActiveOccD(null); setOpen(false); go('home'); }}
                  style={{ padding:'12px 16px', cursor:'pointer', background:D.paperAlt,
                    fontFamily:D.sans, fontSize:10, letterSpacing:'.26em', color:D.bord, fontWeight:700, textTransform:'uppercase' }}>
                  ← Bỏ chọn, về trang chủ
                </div>
              </div>
            )}
          </div>
          <div style={{ width:1, height:18, background:D.line }}/>
          <DBtn kind="bord" size="sm" onClick={()=>go('booking', { occ:occId })}>
            Giữ chỗ thử →
          </DBtn>
        </div>
      </div>
    </div>
  );
}

// ── Ticket — heraldic frame, bordeaux line ────────────────────────────────
function DTicket({ code='F2F·MMXXVI·AQ·81', garment='Berkeley · Xám than', mill='Holland & Sherry · 240gr · Size 52',
  wear='3 – 6 Thg 5, 2026', fitting='2 Thg 5 · 15:30 · Phòng vest', total='4.300.000₫', status='confirmed', ghost }) {
  const stamps = {
    confirmed: { t:'ĐÃ XÁC NHẬN', c:D.bord },
    fitting:   { t:'CHỜ THỬ ĐỒ',   c:D.gold },
    worn:      { t:'ĐÃ MẶC',        c:D.stone },
    returned:  { t:'ĐÃ TRẢ',        c:D.stone },
  }[status] || {t:status,c:D.bord};
  return (
    <div style={{ background:D.paper, border:`1px solid ${D.bord}`, position:'relative', fontFamily:D.sans,
      opacity: ghost ? .6 : 1, filter: ghost ? 'saturate(.3)' : 'none' }}>
      {/* inner hairline frame */}
      <div style={{ position:'absolute', inset:6, border:`1px solid ${D.lineBord}`, pointerEvents:'none' }}/>
      {/* perforation notches */}
      <div style={{ position:'absolute', left:-9, top:'50%', transform:'translateY(-50%)', width:18, height:18, borderRadius:'50%', background:D.paperAlt, border:`1px solid ${D.bord}` }}/>
      <div style={{ position:'absolute', right:-9, top:'50%', transform:'translateY(-50%)', width:18, height:18, borderRadius:'50%', background:D.paperAlt, border:`1px solid ${D.bord}` }}/>
      <div style={{ display:'grid', gridTemplateColumns:'1fr auto', position:'relative', zIndex:1 }}>
        <div style={{ padding:'34px 38px', borderRight:`1px dashed ${D.bord}` }}>
          <div style={{ display:'flex', justifyContent:'space-between', alignItems:'flex-start', marginBottom:24 }}>
            <div>
              <div style={{ fontFamily:D.sans, fontSize:9, letterSpacing:'.32em', color:D.bord, fontWeight:700 }}>Un billet · F · 2 · F</div>
              <div style={{ fontFamily:D.serif, fontSize:32, color:D.ink, lineHeight:1.1, marginTop:8, letterSpacing:'-.01em' }}>{garment}</div>
              <div style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:13, color:D.stone, marginTop:4 }}>{mill}</div>
            </div>
            <div>
              <div style={{ border:`1.5px solid ${stamps.c}`, color:stamps.c, padding:'7px 14px',
                fontSize:9, letterSpacing:'.28em', fontWeight:700, transform:'rotate(-3deg)', display:'inline-block' }}>
                {stamps.t}
              </div>
            </div>
          </div>
          <div style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:22 }}>
            <div>
              <DLabel>Ngày mặc</DLabel>
              <div style={{ fontFamily:D.serif, fontSize:19, color:D.ink, marginTop:4 }}>{wear}</div>
            </div>
            <div>
              <DLabel>Thử đồ</DLabel>
              <div style={{ fontFamily:D.serif, fontSize:19, color:D.ink, marginTop:4 }}>{fitting}</div>
            </div>
          </div>
        </div>
        <div style={{ padding:'34px 28px', background:D.paperAlt, display:'flex', flexDirection:'column', justifyContent:'space-between', minWidth:180 }}>
          <div>
            <DLabel>Mã</DLabel>
            <div style={{ fontFamily:D.sans, fontSize:11, color:D.ink, marginTop:4, lineHeight:1.4, letterSpacing:'.08em' }}>{code}</div>
          </div>
          <DSeal size={44} style={{ alignSelf:'center', marginTop:16 }}/>
          <div style={{ marginTop:16 }}>
            <DLabel>Tổng</DLabel>
            <div style={{ fontFamily:D.serif, fontSize:22, color:D.bord, marginTop:2 }}>{total}</div>
          </div>
        </div>
      </div>
    </div>
  );
}

// ── Footer — gallery/colophon, white primary ─────────────────────────────
function DFooter({ go }) {
  return (
    <footer style={{ background: D.paper, color: D.ink, position:'relative', overflow:'hidden', borderTop:`1px solid ${D.line}` }}>
      {/* Long label strip, bordeaux accents */}
      <div style={{ padding:'20px 72px', display:'flex', justifyContent:'space-between', alignItems:'center',
        fontFamily:D.sans, fontSize:9, letterSpacing:'.38em', color:D.bord, fontWeight:700, textTransform:'uppercase',
        borderBottom:`1px solid ${D.lineBord}` }}>
        <span style={{ display:'flex', alignItems:'center', gap:14 }}>
          <span style={{ width:28, height:1, background:D.bord }}/>
          Colophon · Tập. I
        </span>
        <span style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:14, color:D.stone, letterSpacing:'.02em', textTransform:'none', fontWeight:400 }}>
          Fabric to Fit — Une maison du soir.
        </span>
        <span>10.7769° N · 106.7009° E</span>
      </div>

      {/* Top centerpiece — axial seal + motto */}
      <div style={{ padding:'88px 60px 56px', textAlign:'center', maxWidth:900, margin:'0 auto' }}>
        <div style={{ display:'flex', alignItems:'center', justifyContent:'center', gap:20, margin:'0 auto 28px' }}>
          <span style={{ width:48, height:1, background:D.lineBord }}/>
          <div style={{ fontFamily:D.serif, fontSize:56, fontWeight:300, letterSpacing:'.14em', color:D.ink, lineHeight:1 }}>
            F<span style={{ fontStyle:'italic', color:D.bord, fontSize:38, margin:'0 4px' }}>·2·</span>F
          </div>
          <span style={{ width:48, height:1, background:D.lineBord }}/>
        </div>
        <div style={{ fontFamily:D.serif, fontSize:48, fontWeight:300, color:D.ink, marginTop:0, letterSpacing:'-.025em', lineHeight:1.1 }}>
          Taillé à Saïgon,<br/>
          <span style={{ fontStyle:'italic', color:D.bord }}>anno MMXXVI</span>.
        </div>
        <div style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:18, color:D.stone, marginTop:20, lineHeight:1.55, maxWidth:520, margin:'20px auto 0' }}>
          Một ngôi nhà của những buổi tối — nơi vải đến trước, người đến sau.
        </div>
      </div>

      {/* 3-col spread */}
      <div style={{ maxWidth:1280, margin:'0 auto', padding:'40px 72px 72px',
        display:'grid', gridTemplateColumns:'1.1fr 1fr 1fr', gap:64, alignItems:'flex-start',
        borderTop:`1px solid ${D.line}` }}>

        {/* Col 1 — Tập II teaser */}
        <div>
          <DLabel style={{ marginBottom:18 }}>Sắp ra mắt</DLabel>
          <div style={{ display:'flex', alignItems:'baseline', gap:18, marginBottom:14 }}>
            <div style={{ fontFamily:D.serif, fontWeight:200, fontSize:84, color:D.bord, lineHeight:.9, letterSpacing:'-.03em' }}>II</div>
            <div>
              <div style={{ fontFamily:D.sans, fontSize:9, letterSpacing:'.32em', color:D.bord, fontWeight:700 }}>Thu 2026</div>
              <div style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:22, color:D.ink, marginTop:2, lineHeight:1.25 }}>Sau giờ làm.</div>
            </div>
          </div>
          <div style={{ fontFamily:D.serif, fontSize:15, color:D.stone, lineHeight:1.65, maxWidth:320 }}>
            Tủ đồ cho những buổi tối sau 6 giờ — cocktail, khai mạc, phòng hát.
          </div>
          <div style={{ marginTop:22, display:'flex', gap:10, alignItems:'center' }}>
            <input placeholder="Email của bạn" style={{ flex:1, padding:'11px 14px', border:`1px solid ${D.line}`, background:D.paperAlt, fontFamily:D.serif, fontStyle:'italic', fontSize:14, color:D.ink, outline:'none' }}/>
            <DBtn kind="bord" size="sm">Đăng ký →</DBtn>
          </div>
        </div>

        {/* Col 2 — Sitemap */}
        <div>
          <DLabel style={{ marginBottom:18 }}>Mục lục</DLabel>
          <div style={{ display:'flex', flexDirection:'column', gap:26 }}>
            {[
              ['— Khám phá',   [['Theo sự kiện','occasions'], ['Tủ đồ','collection'], ['Tập. I · Xuân/Hạ','story']]],
              ['— Ngôi nhà',   [['Câu chuyện 87%','story'], ['Master tailor','story'], ['Ghé xưởng','showroom']]],
              ['— Tài khoản',  [['Tủ của tôi','account'], ['Lịch fitting','account'], ['Đăng nhập','account']]],
            ].map(([title, items])=>(
              <div key={title}>
                <div style={{ fontFamily:D.sans, fontSize:9, letterSpacing:'.32em', color:D.bord, fontWeight:700, marginBottom:12 }}>
                  {title}
                </div>
                {items.map(([label, route])=>(
                  <div key={label} onClick={()=>go(route)} style={{ fontFamily:D.serif, fontSize:19, color:D.ink,
                    padding:'6px 0', cursor:'pointer', lineHeight:1.3, transition:'color .2s',
                    display:'flex', alignItems:'center', gap:10 }}
                    onMouseEnter={e=>{ e.currentTarget.style.color = D.bord; e.currentTarget.querySelector('span').style.opacity='1'; e.currentTarget.querySelector('span').style.transform='translateX(0)'; }}
                    onMouseLeave={e=>{ e.currentTarget.style.color = D.ink; e.currentTarget.querySelector('span').style.opacity='0'; e.currentTarget.querySelector('span').style.transform='translateX(-4px)'; }}>
                    {label}
                    <span style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:15, color:D.bord, opacity:0, transform:'translateX(-4px)', transition:'all .2s' }}>→</span>
                  </div>
                ))}
              </div>
            ))}
          </div>
        </div>

        {/* Col 3 — address with mini map */}
        <div>
          <DLabel style={{ marginBottom:18 }}>Ghé xưởng</DLabel>
          <div style={{ position:'relative', background:D.paperAlt, aspectRatio:'4/3', border:`1px solid ${D.line}`, overflow:'hidden' }}>
            <svg width="100%" height="100%" viewBox="0 0 600 450" preserveAspectRatio="xMidYMid slice" style={{ position:'absolute', inset:0 }}>
              <rect width="600" height="450" fill={D.paperAlt}/>
              <path d="M 470 0 Q 420 120 480 220 Q 540 320 490 450 L 600 450 L 600 0 Z" fill={D.bord} opacity="0.08"/>
              <path d="M 470 0 Q 420 120 480 220 Q 540 320 490 450" stroke={D.bord} strokeWidth="0.8" fill="none" opacity="0.4" strokeDasharray="3 4"/>
              {[60,130,200,270,340,410].map(y=>(<line key={'h'+y} x1="0" y1={y} x2="470" y2={y} stroke={D.ink} strokeWidth="0.4" opacity="0.14"/>))}
              {[70,160,250,340,430].map(x=>(<line key={'v'+x} x1={x} y1="0" x2={x} y2="450" stroke={D.ink} strokeWidth="0.4" opacity="0.14"/>))}
              <line x1="0" y1="270" x2="470" y2="270" stroke={D.bord} strokeWidth="1.4" opacity="0.85"/>
              {[[160,130,90,70],[250,60,90,70],[70,200,80,60],[340,200,90,60],[160,340,90,70]].map(([x,y,w,h], i)=>(
                <rect key={i} x={x} y={y} width={w} height={h} fill={D.ink} opacity="0.05"/>
              ))}
              <text x="10" y="266" fontFamily="Commissioner, sans-serif" fontSize="9" letterSpacing="2" fill={D.bord} fontWeight="700">LÊ THÁNH TÔN</text>
              <text x="484" y="30" fontFamily="Cormorant Garamond, serif" fontSize="13" fill={D.bord} fontStyle="italic" opacity="0.7">Sông Sài Gòn</text>
              <circle cx="250" cy="130" r="2.5" fill={D.stone}/>
              <text x="258" y="134" fontFamily="Commissioner, sans-serif" fontSize="7" fill={D.stone}>Đức Bà</text>
              <g transform="translate(250, 270)">
                <circle r="34" fill={D.bord} opacity="0.08"/>
                <circle r="22" fill={D.bord} opacity="0.14"/>
                <path d="M0 -28 C -11 -28 -18 -18 -18 -10 C -18 2 -8 8 0 22 C 8 8 18 2 18 -10 C 18 -18 11 -28 0 -28 Z"
                  fill={D.bord} stroke={D.paper} strokeWidth="1.4"/>
                <circle cx="0" cy="-12" r="5" fill={D.gold}/>
              </g>
            </svg>
          </div>
          <div style={{ padding:'22px 24px', background:D.paper, border:`1px solid ${D.bord}`, borderTop:'none' }}>
            <div style={{ fontFamily:D.serif, fontSize:26, color:D.ink, lineHeight:1.1 }}>142 Lê Thánh Tôn</div>
            <div style={{ fontFamily:D.serif, fontStyle:'italic', fontSize:14, color:D.stone, marginTop:4 }}>
              Phường Bến Nghé, Quận 1 · Tp. HCM
            </div>
            <div style={{ display:'grid', gridTemplateColumns:'1fr 1fr', gap:18, marginTop:18, paddingTop:14, borderTop:`1px dashed ${D.line}` }}>
              <div>
                <DLabel>Giờ mở</DLabel>
                <div style={{ fontFamily:D.serif, fontSize:13, color:D.ink, marginTop:3, lineHeight:1.4 }}>T3 — T7<br/>10h — 20h</div>
              </div>
              <div>
                <DLabel>Đưa đón</DLabel>
                <div style={{ fontFamily:D.serif, fontSize:13, color:D.ink, marginTop:3, lineHeight:1.4 }}>Miễn phí<br/>bán kính 3km</div>
              </div>
            </div>
            <div style={{ display:'flex', gap:8, marginTop:16 }}>
              <DBtn kind="bord" size="sm" fullWidth>Chỉ đường →</DBtn>
              <DBtn kind="hair" size="sm" fullWidth>Zalo</DBtn>
            </div>
          </div>
        </div>
      </div>

      {/* Gold hairline */}
      <div style={{ maxWidth:1440, margin:'0 auto', padding:'0 72px' }}>
        <div style={{ height:1, background:`linear-gradient(90deg, transparent, ${D.gold}66 18%, ${D.gold}66 82%, transparent)` }}/>
      </div>

      {/* Base row */}
      <div style={{ maxWidth:1440, margin:'0 auto', padding:'24px 72px 36px',
        display:'grid', gridTemplateColumns:'1fr auto 1fr', alignItems:'center', gap:20,
        fontFamily:D.sans, fontSize:9, letterSpacing:'.28em', color:D.stone, fontWeight:600, textTransform:'uppercase' }}>
        <span style={{ display:'flex', alignItems:'center', gap:16 }}>
          <span>© MMXXVI · F·2·F · Tp. HCM</span>
          <span style={{ color:D.line }}>·</span>
          <span style={{ display:'flex', gap:14 }}>
            {['Instagram','Facebook','Zalo'].map(s=>(
              <span key={s} style={{ cursor:'pointer', transition:'color .2s' }}
                onMouseEnter={e=>e.currentTarget.style.color=D.bord}
                onMouseLeave={e=>e.currentTarget.style.color=D.stone}>{s}</span>
            ))}
          </span>
        </span>
        <div style={{ display:'flex', alignItems:'center', gap:16 }}>
          <span style={{ width:36, height:1, background:D.lineBord }}/>
          <div style={{ fontFamily:D.serif, fontSize:56, fontWeight:300, letterSpacing:'.14em', color:D.ink, lineHeight:1, textTransform:'none' }}>
            F<span style={{ fontStyle:'italic', color:D.bord, fontSize:38, margin:'0 4px' }}>·2·</span>F
          </div>
          <span style={{ width:36, height:1, background:D.lineBord }}/>
        </div>
        <span style={{ textAlign:'right' }}>Điều khoản · Riêng tư · Hoàn trả</span>
      </div>
    </footer>
  );
}

Object.assign(window, {
  D, toRoman, DEyebrow, DLabel, DRule, DDivider, DSeal, DBtn, DChip,
  DNav, DFooter, DTicket, DStickyBreadcrumb,
  setActiveOccD, readActiveOccD,
  OCCASIONS, GARMENTS, formatVND,
});
