// OpenStudio.jsx — landing page for the Holiday Open Studio, Sunday December 13, 2026
// Shareable at drurybynum.com/open-studio (and #/open-studio). Not in the nav.
const OpenStudio = ({ onNav, onOpen }) => {
  const { Reveal, Card, VisitButton, STUDIO } = window;

  const EVENT = {
    title:'Holiday Open Studio — Drury Bynum & Jamie',
    start:'20261213T120000', end:'20261213T170000', tz:'America/New_York',
    endsAt:new Date('2026-12-13T17:00:00-05:00'),
    place:'Parkdale Studios, 3500 Parkdale Ave, Studios 132 & 133, Baltimore, MD',
  };
  const isPast = Date.now() > EVENT.endsAt.getTime();
  const gcal = 'https://calendar.google.com/calendar/render?action=TEMPLATE'
    + '&text=' + encodeURIComponent(EVENT.title)
    + '&dates=' + EVENT.start + '/' + EVENT.end
    + '&ctz=' + EVENT.tz
    + '&location=' + encodeURIComponent(EVENT.place)
    + '&details=' + encodeURIComponent('Wine, snacks and the newest paintings. Studios 132 & 133. https://www.drurybynum.com/open-studio');

  const newest = ['lodger', 'vigil', 'consonance', 'vesper'].map(window.workById).filter(Boolean);

  const facts = [
    { k:'When',  v:'Sunday, December 13', s:'Noon – 5pm' },
    { k:'Where', v:'3500 Parkdale Ave',   s:'Studios 132 & 133 · Baltimore' },
    { k:'What',  v:'Wine, snacks, paintings', s:'Free · open to the public' },
  ];

  return (
    <div className="os">
      {isPast && (
        <div className="band-earth" style={{padding:'14px 0'}}>
          <div className="wrap meta" style={{color:'var(--veil)', display:'flex', gap:16, flexWrap:'wrap', alignItems:'center', justifyContent:'space-between'}}>
            <span>This open studio has wrapped. Thank you to everyone who came through the door.</span>
            <a onClick={() => onNav('visit')} style={{cursor:'pointer', borderBottom:'1px solid var(--veil)'}}>Schedule a private visit →</a>
          </div>
        </div>
      )}

      {/* hero */}
      <section className="band-void os-hero">
        <div className="wrap os-hero-grid">
          <div className="os-hero-copy">
            <div className="kicker-row" style={{marginBottom:28}}>
              <span className="flare-dot"></span>
              <span className="eyebrow on-dark">Holiday open studio · Parkdale Studios</span>
            </div>
            <div className="os-date" aria-hidden="true">
              <span>12</span><span className="os-date-dot"></span><span>13</span>
            </div>
            <h1 className="os-h1">
              One Sunday afternoon,<br/>two studios, <em>one long room.</em>
            </h1>
            <p className="lead on-dark" style={{maxWidth:520, marginTop:22}}>
              December light in an old mill building turns gold around three o’clock and gives up
              completely by a quarter to five. Come see the studio in both.
            </p>
            {!isPast && (
              <div style={{display:'flex', gap:22, flexWrap:'wrap', alignItems:'center', marginTop:34}}>
                <a className="btn btn-flare" href={gcal} target="_blank" rel="noreferrer">Add to calendar →</a>
                <a className="btn btn-ghost-veil" href={STUDIO.mapsUrl} target="_blank" rel="noreferrer">Get directions</a>
              </div>
            )}
          </div>
          <figure className="os-hero-fig">
            <img src="images/Juniper house011_websize.jpeg"
                 alt="Jamie and Drury in the sunlit Parkdale studio, Jamie leaning on a green step stool and Drury seated in a rattan chair" />
            <figcaption className="meta on-dark">Jamie and Drury at Parkdale · photo @liv.phare</figcaption>
          </figure>
        </div>
      </section>

      {/* facts strip */}
      <section className="band-ink">
        <div className="wrap os-facts">
          {facts.map(f => (
            <div key={f.k} className="os-fact">
              <div className="meta" style={{color:'var(--flare)', textTransform:'uppercase', letterSpacing:'0.14em'}}>{f.k}</div>
              <div className="os-fact-v">{f.v}</div>
              <div className="meta on-dark">{f.s}</div>
            </div>
          ))}
        </div>
      </section>

      {/* the invitation + map */}
      <section className="section band-veil" style={{'--sp':'96px'}}>
        <div className="wrap rg-2col" style={{display:'grid', gridTemplateColumns:'1.05fr 0.95fr', gap:72, alignItems:'start'}}>
          <Reveal>
            <div className="eyebrow" style={{marginBottom:18}}>The invitation</div>
            <p className="os-pull">Escape the mall madness and duck into a cozy afternoon studio hideaway.</p>
            <p className="body" style={{marginTop:22}}>
              On Sunday, December 13, from noon to 5, Jamie and I would love to have you at our studios for
              wine, snacks and the newest paintings. The whole building at 3500 Parkdale Avenue is open to
              the public that day.
            </p>
            <p className="body" style={{marginTop:16}}>
              Our studios, 132 and 133, sit across the hall from each other and become one long room when both
              doors are open. Mine has the paintings. Hers has the couch. Most people end up using both.
            </p>
            <p className="body" style={{marginTop:16}}>Come for ten minutes or stay the afternoon. Bring someone.</p>
          </Reveal>
          <Reveal delay={80}>
            <figure>
              <img src="images/ParkdaleOpenHouse_2025_MAP.jpeg"
                   alt="Illustrated map of the 3500 Parkdale Ave building: 2nd and 3rd floor studios via the blue doors and elevator, 1st floor studios entrance around the side"
                   style={{width:'100%', aspectRatio:'1 / 1', objectFit:'cover', border:'1px solid var(--ink-line)'}} />
              <figcaption className="meta" style={{marginTop:12, display:'flex', justifyContent:'space-between', gap:12, flexWrap:'wrap'}}>
                <span>Finding us · first-floor studios, entrance around the side</span>
                <a href={STUDIO.mapsUrl} target="_blank" rel="noreferrer" style={{color:'var(--flare)'}}>Open in Maps →</a>
              </figcaption>
            </figure>
          </Reveal>
        </div>
      </section>

      {/* on the walls */}
      <section className="section band-ink" style={{'--sp':'96px'}}>
        <div className="wrap">
          <div style={{display:'flex', justifyContent:'space-between', alignItems:'end', gap:24, flexWrap:'wrap', marginBottom:40}}>
            <div>
              <div className="kicker-row" style={{marginBottom:16}}>
                <span className="flare-dot"></span><span className="eyebrow on-dark">On the walls</span>
              </div>
              <h2 style={{fontFamily:'var(--font-display)', fontWeight:900, color:'var(--veil)',
                          fontSize:'clamp(26px,3vw,42px)', letterSpacing:'-0.02em', lineHeight:1}}>
                The newest Seraphic Veil paintings
              </h2>
            </div>
            <p className="meta on-dark" style={{maxWidth:340}}>
              Four panels from 2026, 36 × 48 inches each. Click any one for details.
            </p>
          </div>
          <div className="gal os-gal" style={{'--cols':4}}>
            {newest.map(w => <Card key={w.id} work={w} onOpen={onOpen} />)}
          </div>
        </div>
      </section>

      {/* can't make it */}
      <section className="section band-veil" style={{'--sp':'80px', textAlign:'center'}}>
        <div className="wrap" style={{maxWidth:720}}>
          <div className="eyebrow" style={{marginBottom:16}}>{isPast ? 'Missed it?' : 'Can’t make the 13th?'}</div>
          <h2 style={{fontFamily:'var(--font-display)', fontWeight:900, fontSize:'clamp(26px,3vw,40px)',
                      letterSpacing:'-0.02em', lineHeight:1.05, marginBottom:18}}>
            The studio keeps other hours too.
          </h2>
          <p className="body dim" style={{marginBottom:30}}>
            Book a private visit for another day and the paintings will be out when you get there.
          </p>
          <div style={{display:'flex', gap:22, justifyContent:'center', flexWrap:'wrap', alignItems:'center'}}>
            <VisitButton className="btn btn-ink" />
            <button className="btn btn-ghost-ink" onClick={() => onNav('series/seraphic-veil')}>See the whole series</button>
          </div>
        </div>
      </section>
    </div>
  );
};
Object.assign(window, { OpenStudio });
