// brand1518.jsx — "1518 / 1518.coffee" rebrand exploration
// Concept: the dose is the name — 15 g drip, 18 g espresso.
// Reuses the Ember system. Needs shared, onb-shared, brew-data, brew-timer,
// coll-data, coll-shared, share-photo, share-data.

// ── Logo / wordmark treatments ──────────────────────────────
// A · inline serif wordmark "1518"
function Logo1518({ size=40, color, weight=500 }){
  const P = useP();
  return (
    <span className="serif tnum" style={{ fontSize:size, fontWeight:weight, letterSpacing:'0.01em',
      color: color || P.ink, lineHeight:1, display:'inline-block' }}>1518</span>
  );
}
// B · split "15·18" with a hairline + tiny method labels
function Logo1518Split({ scale=1, color, labels=true }){
  const P = useP(); const c = color || P.ink;
  const N = ({ children }) => <span className="serif tnum" style={{ fontSize:34*scale, fontWeight:500, color:c, lineHeight:1 }}>{children}</span>;
  return (
    <div style={{ display:'inline-flex', alignItems:'center', gap:12*scale }}>
      <div style={{ textAlign:'center' }}>
        <N>15</N>
        {labels && <div className="sans" style={{ fontSize:7*scale, letterSpacing:'0.22em', color:P.stone, marginTop:4*scale }}>DRIP</div>}
      </div>
      <div style={{ width:1, height:30*scale, background:P.line }} />
      <div style={{ textAlign:'center' }}>
        <N>18</N>
        {labels && <div className="sans" style={{ fontSize:7*scale, letterSpacing:'0.22em', color:P.stone, marginTop:4*scale }}>ESPRESSO</div>}
      </div>
    </div>
  );
}
// C · stacked ratio monogram in a ring (15 over 18)
function Mark1518({ size=72, color, ring=true }){
  const P = useP(); const c = color || P.sage;
  return (
    <div style={{ width:size, height:size, borderRadius:'50%', position:'relative', flexShrink:0,
      border: ring ? `1.5px solid ${c}` : 'none', display:'flex', flexDirection:'column',
      alignItems:'center', justifyContent:'center', gap:size*0.02 }}>
      <span className="serif tnum" style={{ fontSize:size*0.30, fontWeight:600, color:P.ink, lineHeight:1 }}>15</span>
      <div style={{ width:size*0.42, height:1, background:c }} />
      <span className="serif tnum" style={{ fontSize:size*0.30, fontWeight:600, color:P.ink, lineHeight:1 }}>18</span>
    </div>
  );
}

// ════════════════════════════════════════════════════════════
// SPLASH
// ════════════════════════════════════════════════════════════
function Splash1518(){
  const P = useP();
  return (
    <Screen pad="0">
      <div style={{ position:'absolute', inset:0, display:'flex', flexDirection:'column', alignItems:'center', justifyContent:'center' }}>
        {/* soft glow */}
        <div style={{ position:'absolute', top:'42%', left:'50%', transform:'translate(-50%,-50%)', width:360, height:360, borderRadius:'50%',
          background:`radial-gradient(circle, ${P.sageSoft}33 0%, transparent 68%)`, filter:'blur(6px)' }} />
        <div style={{ position:'relative', textAlign:'center' }}>
          <div className="serif tnum" style={{ fontSize:108, fontWeight:500, color:P.ink, letterSpacing:'0.02em', lineHeight:1 }}>1518</div>
          <div style={{ display:'flex', alignItems:'center', justifyContent:'center', gap:12, marginTop:18 }}>
            <span style={{ width:26, height:1, background:P.line }} />
            <span className="sans" style={{ fontSize:11.5, letterSpacing:'0.32em', color:P.stone, fontWeight:600 }}>COFFEE</span>
            <span style={{ width:26, height:1, background:P.line }} />
          </div>
        </div>
        <div style={{ position:'absolute', bottom:54, textAlign:'center' }}>
          <div className="serif" style={{ fontStyle:'italic', fontSize:16, color:P.stone }}>Fifteen for drip. Eighteen for espresso.</div>
        </div>
      </div>
    </Screen>
  );
}

// ════════════════════════════════════════════════════════════
// WELCOME — the name reveal
// ════════════════════════════════════════════════════════════
function Welcome1518(){
  const P = useP();
  const Dose = ({ n, unit, k, label, sub }) => (
    <div style={{ flex:1, textAlign:'center' }}>
      <div style={{ display:'flex', alignItems:'baseline', justifyContent:'center', gap:3 }}>
        <span className="serif tnum" style={{ fontSize:64, fontWeight:500, color:P.ink, lineHeight:0.9 }}>{n}</span>
        <span className="sans" style={{ fontSize:14, color:P.stone, fontWeight:600 }}>{unit}</span>
      </div>
      <Eyebrow color={P.sageDeep} style={{ marginTop:12 }}>{label}</Eyebrow>
      <div className="sans" style={{ fontSize:12, color:P.stoneLt, marginTop:5 }}>{sub}</div>
    </div>
  );
  return (
    <Screen pad="0">
      <div style={{ position:'absolute', inset:0, display:'flex', flexDirection:'column', padding:'78px 30px 32px' }}>
        <div style={{ flexShrink:0, textAlign:'center' }}>
          <Eyebrow color={P.sage}>Welcome to</Eyebrow>
          <div style={{ marginTop:14 }}><Logo1518 size={56} /></div>
        </div>

        <div style={{ flex:1, minHeight:0, display:'flex', flexDirection:'column', justifyContent:'center' }}>
          <div className="serif" style={{ fontSize:25, lineHeight:1.22, color:P.ink, textAlign:'center', letterSpacing:'-0.01em' }}>
            A name you can taste.
          </div>
          <div className="serif" style={{ fontStyle:'italic', fontSize:16, lineHeight:1.5, color:P.stone, textAlign:'center', marginTop:12, padding:'0 6px' }}>
            The two doses every great cup begins with.
          </div>

          {/* the two doses */}
          <div style={{ display:'flex', alignItems:'stretch', marginTop:36 }}>
            <Dose n="15" unit="g" label="Drip" sub="Pour-over & filter" />
            <div style={{ width:1, background:P.line, margin:'6px 0' }} />
            <Dose n="18" unit="g" label="Espresso" sub="Shots & milk" />
          </div>
          <div className="sans" style={{ fontSize:12.5, color:P.stoneLt, textAlign:'center', marginTop:30, lineHeight:1.5 }}>
            Whatever you brew, <span style={{ color:P.ink, fontWeight:600 }}>1518</span> remembers it —
            <br/>every bag, every pour, every cup worth chasing.
          </div>
        </div>

        <div style={{ flexShrink:0 }}>
          <PrimaryBtn label="Make it mine" icon="arrow" onClick={()=>{}} />
          <div className="sans" style={{ fontSize:12.5, color:P.stoneLt, textAlign:'center', marginTop:14 }}>
            Already with us? <span style={{ color:P.sageDeep, fontWeight:600 }}>Sign in</span>
          </div>
        </div>
      </div>
    </Screen>
  );
}

// ════════════════════════════════════════════════════════════
// SIGN UP — wordmark in place of Bloom
// ════════════════════════════════════════════════════════════
function SignUp1518(){
  const P = useP();
  return (
    <Screen pad="0">
      <div style={{ position:'absolute', inset:0, display:'flex', flexDirection:'column', padding:'76px 26px 30px' }}>
        <div style={{ flexShrink:0 }}>
          <Mark1518 size={52} />
          <div className="serif" style={{ fontSize:28, lineHeight:1.12, color:P.ink, marginTop:20 }}>Make a home<br/>for your coffee.</div>
          <div className="serif" style={{ fontStyle:'italic', fontSize:16, color:P.stone, marginTop:9 }}>
            One account keeps every bag, recipe and rating in sync.
          </div>
        </div>
        <div style={{ flex:1 }} />
        <div style={{ display:'flex', flexDirection:'column', gap:11, flexShrink:0 }}>
          <AuthBtn kind="apple" onClick={()=>{}} />
          <AuthBtn kind="google" onClick={()=>{}} />
          <AuthBtn kind="email" onClick={()=>{}} />
          <div className="sans" style={{ fontSize:11, lineHeight:1.5, color:P.stoneLt, textAlign:'center', marginTop:8, padding:'0 10px' }}>
            By continuing you agree to 1518’s <span style={{ color:P.stone, textDecoration:'underline' }}>Terms</span> &amp; <span style={{ color:P.stone, textDecoration:'underline' }}>Privacy</span>.
          </div>
        </div>
      </div>
    </Screen>
  );
}

// ════════════════════════════════════════════════════════════
// HOME — rebranded header
// ════════════════════════════════════════════════════════════
function Home1518(){
  const P = useP();
  const Card = ({ icon, title, sub, primary }) => (
    <div style={{ position:'relative', borderRadius:20, overflow:'hidden', border:'1px solid '+(primary?P.sage:P.line),
      background: primary?'transparent':P.card, padding:'18px', display:'flex', alignItems:'center', gap:15 }}>
      {primary && <div style={{ position:'absolute', inset:0, background:`radial-gradient(120% 100% at 100% 50%, ${P.sageSoft}1f, transparent 60%)` }} />}
      <div style={{ position:'relative', width:46, height:46, borderRadius:13, flexShrink:0, background:primary?P.sage:P.cardSunk, color:primary?'#1C1611':P.sage,
        display:'flex', alignItems:'center', justifyContent:'center' }}><Icon name={icon} size={23} stroke={1.8} /></div>
      <div style={{ position:'relative', flex:1 }}>
        <div className="serif" style={{ fontSize:19, color:P.ink, lineHeight:1.05 }}>{title}</div>
        <div className="sans" style={{ fontSize:12.5, color:P.stone, marginTop:3 }}>{sub}</div>
      </div>
      <span style={{ position:'relative', color:primary?P.sageDeep:P.stoneLt, display:'flex' }}><Icon name="arrow" size={18} /></span>
    </div>
  );
  return (
    <Screen pad="0">
      <div style={{ position:'absolute', inset:0, display:'flex', flexDirection:'column', padding:'70px 24px 26px' }}>
        <div style={{ flexShrink:0 }}>
          <div style={{ display:'flex', justifyContent:'space-between', alignItems:'center' }}>
            <Logo1518 size={26} />
            <div style={{ display:'flex', alignItems:'center', gap:10 }}>
              <div style={{ display:'flex', alignItems:'center', gap:6, height:32, padding:'0 12px 0 10px', borderRadius:20, background:P.card, border:'1px solid '+P.line }}>
                <Flame size={15} /><span className="sans tnum" style={{ fontSize:13, fontWeight:700, color:P.ink }}>{SHARE.dayStreak}</span>
              </div>
              <div style={{ width:40, height:40, borderRadius:'50%', background:P.card, border:'1px solid '+P.line,
                display:'flex', alignItems:'center', justifyContent:'center', color:P.sageDeep, fontFamily:SERIF, fontSize:17 }}>M</div>
            </div>
          </div>
          <Eyebrow color={P.sage} style={{ marginTop:24 }}>Tuesday, June 2</Eyebrow>
          <div className="serif" style={{ fontSize:30, lineHeight:1.1, color:P.ink, marginTop:8 }}>Good evening, Maya.</div>
          <div className="serif" style={{ fontStyle:'italic', fontSize:16.5, color:P.stone, marginTop:7 }}>What are you brewing today?</div>
        </div>
        <div style={{ flex:1, minHeight:0, display:'flex', flexDirection:'column', justifyContent:'center', gap:13, marginTop:18 }}>
          <Card icon="v60" title="Brew a coffee" sub="A guided pour, tuned to your taste" primary />
          <Card icon="other" title="Scan a bag" sub="Identify a new coffee & add it to your shelf" />
        </div>
        <div style={{ flexShrink:0, display:'flex', gap:6, padding:'6px', background:P.cardSunk, border:'1px solid '+P.line, borderRadius:19 }}>
          <div style={{ flex:1, display:'flex', alignItems:'center', justifyContent:'center', gap:9, padding:'13px 0', borderRadius:15, background:P.sage, color:'#1C1611' }}>
            <Icon name="home" size={20} stroke={2.1} /><span className="sans" style={{ fontSize:13.5, fontWeight:700 }}>Home</span></div>
          <div style={{ flex:1, display:'flex', alignItems:'center', justifyContent:'center', gap:9, padding:'13px 0', borderRadius:15, color:P.stoneLt }}>
            <Icon name="grid" size={20} stroke={1.8} /><span className="sans" style={{ fontSize:13.5, fontWeight:600 }}>Codex</span></div>
        </div>
      </div>
    </Screen>
  );
}

// ════════════════════════════════════════════════════════════
// SHARE CARD — 1518.coffee watermark
// ════════════════════════════════════════════════════════════
function Card1518(){
  const P = useP(); const d = SHARE.today;
  return (
    <div style={{ position:'absolute', inset:0, overflow:'hidden', background:P.paper2 }}>
      <div style={{ position:'absolute', inset:0, filter:'saturate(0.72) brightness(0.6)' }}><CupBackdrop seed={1} /></div>
      <div style={{ position:'absolute', inset:0, background:'linear-gradient(to bottom, rgba(14,11,8,0.5) 0%, transparent 32%, transparent 50%, rgba(14,11,8,0.85) 100%)' }} />
      <div style={{ position:'absolute', inset:0, backgroundImage:GRAIN_URL, backgroundSize:'160px 160px', opacity:0.06, mixBlendMode:'soft-light' }} />
      <div style={{ position:'absolute', inset:0, padding:'32px', display:'flex', flexDirection:'column', color:'#F6EFE2' }}>
        {/* header wordmark */}
        <div style={{ display:'flex', alignItems:'center', justifyContent:'space-between' }}>
          <span className="serif tnum" style={{ fontSize:22, fontWeight:600, color:'#F6EFE2', textShadow:'0 1px 8px rgba(0,0,0,0.5)' }}>1518</span>
          <span className="sans" style={{ fontSize:11, letterSpacing:'0.14em', color:'rgba(246,239,226,0.7)', fontWeight:600 }}>{d.date.toUpperCase()}</span>
        </div>
        <div style={{ flex:1 }} />
        <div style={{ display:'flex', gap:3 }}>{[1,2,3,4].map(k=><svg key={k} width="18" height="18" viewBox="0 0 24 24" fill="#F2CE73" style={{ filter:'drop-shadow(0 1px 4px rgba(0,0,0,0.5))' }}><path d="M12 3l2.6 5.6L21 9.3l-4.5 4.3 1.1 6.1L12 17l-5.6 2.7 1.1-6.1L3 9.3l6.4-.7z"/></svg>)}</div>
        <div className="serif" style={{ fontSize:34, lineHeight:1.02, marginTop:14, textShadow:'0 1px 12px rgba(0,0,0,0.5)' }}>{d.coffee}</div>
        <div className="sans" style={{ fontSize:13.5, opacity:0.9, marginTop:8 }}>{d.roaster} · {d.origin} · {d.region}</div>
        <div style={{ display:'flex', gap:8, marginTop:18 }}>
          {d.notes.map(n=>(
            <span key={n} className="sans" style={{ fontSize:12, fontWeight:600, color:'#F2CE73',
              background:'rgba(242,206,115,0.14)', border:'1px solid rgba(242,206,115,0.34)', borderRadius:20, padding:'5px 12px' }}>{n}</span>
          ))}
        </div>
        <div style={{ marginTop:22, paddingTop:16, borderTop:'1px solid rgba(255,255,255,0.16)', display:'flex', alignItems:'center', justifyContent:'space-between' }}>
          <span className="sans" style={{ fontSize:11.5, letterSpacing:'0.16em', textTransform:'uppercase', color:'rgba(246,239,226,0.78)', fontWeight:600 }}>1518.coffee</span>
          <span className="sans tnum" style={{ fontSize:12, color:'rgba(246,239,226,0.78)' }}>{d.method} · {d.dose} · {d.time}</span>
        </div>
      </div>
    </div>
  );
}

Object.assign(window, { Logo1518, Logo1518Split, Mark1518, Splash1518, Welcome1518, SignUp1518, Home1518, Card1518 });
