// Direction 6 — ATELIER
// Boutique luxury dark. Rich palette, sophisticated editorial typography,
// gold accents, cinematic mood. References: Le bon, Pinkas Designs,
// Truhlárna Luxury, Reform Copenhagen. Vibe: high-end luxury kitchen boutique.
//
// Distinct from Mistr (which is bold-dark walnut+copper bento):
//   - Forest green / burgundy base (NOT walnut)
//   - Champagne gold accent (NOT copper)
//   - Cinematic fullbleed hero with classical center-aligned serif heading
//   - "Manifesto" filozofie section
//   - Collections 2-col alternating (NOT bento grid)
//   - Vertical roman numeral process (I, II, III, IV)
//   - "Atelier visit" premium CTA

const _mixA = (hex, target, amount) => {
  const h = hex.replace('#', '');
  const t = target.replace('#', '');
  const r = Math.round(parseInt(h.slice(0, 2), 16) * (1 - amount) + parseInt(t.slice(0, 2), 16) * amount);
  const g = Math.round(parseInt(h.slice(2, 4), 16) * (1 - amount) + parseInt(t.slice(2, 4), 16) * amount);
  const b = Math.round(parseInt(h.slice(4, 6), 16) * (1 - amount) + parseInt(t.slice(4, 6), 16) * amount);
  return '#' + [r, g, b].map(x => x.toString(16).padStart(2, '0')).join('');
};

// Hardcoded — Atelier je dark luxury s champagne gold. NE pull z BRAND.palette.
const atelierTokens = {
  bg: '#1E3128',
  bgAlt: '#162519',
  bgLight: '#2A4434',
  paper: '#F2EBDC',
  paperSoft: '#F2EBDCCC',
  paperMuted: '#F2EBDC88',
  gold: '#D4A862',          // champagne gold (hardcoded)
  goldSoft: _mixA('#D4A862', '#1E3128', 0.5),
  goldGlow: '#D4A862',
  brand: '#D4A862',
  rule: '#F2EBDC24',
  ruleStrong: '#F2EBDC48',
};

const aDisplay = (size, italic = false) => ({
  fontFamily: '"Cormorant Garamond", "Playfair Display", Georgia, serif',
  fontWeight: 500, fontSize: size,
  fontStyle: italic ? 'italic' : 'normal',
  lineHeight: size > 56 ? 1.04 : 1.18,
  letterSpacing: '-0.015em',
  margin: 0,
});
const aLabel = {
  fontFamily: '"Inter", -apple-system, sans-serif',
  fontSize: 11, letterSpacing: '.28em', textTransform: 'uppercase',
  fontWeight: 500,
};
const aBody = {
  fontFamily: '"Inter", -apple-system, sans-serif',
  fontSize: 15, lineHeight: 1.7, fontWeight: 300,
};

// ============================================================================
// DESKTOP — 1440 wide
// ============================================================================
const AtelierDesktop = () => {
  const t = atelierTokens;
  return (
    <div style={{
      width: 1440, fontFamily: '"Inter", -apple-system, sans-serif',
      color: t.paper, background: t.bg,
    }}>
      <AtelierNav t={t} />
      <AtelierHero t={t} />
      <AtelierManifesto t={t} />
      <AtelierCollections t={t} />
      <AtelierProcess t={t} />
      <AtelierVisit t={t} />
      <AtelierFooter t={t} />
    </div>
  );
};

// ── NAV — minimal monogram + gold underline ───────────────────────────────
const AtelierNav = ({ t }) => (
  <nav style={{
    display: 'flex', alignItems: 'center', justifyContent: 'space-between',
    padding: '40px 80px',
    borderBottom: `1px solid ${t.rule}`,
  }}>
    <div style={{ display: 'flex', alignItems: 'center', gap: 20 }}>
      <img src={BRAND.logoPath} alt={BRAND.name} style={{ height: 48, width: 'auto', filter: 'brightness(0) invert(1)', opacity: 0.95 }} />
      <div style={{ height: 32, width: 1, background: t.rule }} />
      <div style={{ ...aLabel, color: t.gold }}>
        {BRAND.location || 'Atelier'}{BRAND.since ? ` — Est. ${BRAND.since}` : ''}
      </div>
    </div>
    <div style={{ display: 'flex', gap: 48, fontSize: 13, fontWeight: 400, letterSpacing: '0.08em', textTransform: 'uppercase' }}>
      {['Filosofie', 'Realizace', 'Atelier', 'Návštěva'].map(l => (
        <a key={l} href="#" style={{ color: t.paperSoft, textDecoration: 'none' }}>{l}</a>
      ))}
    </div>
    <a href={`tel:${BRAND.phone}`} style={{ ...aLabel, color: t.gold, textDecoration: 'none' }}>
      {BRAND.phoneDisplay}
    </a>
  </nav>
);

// ── HERO — cinematic fullbleed with classical center heading ──────────────
const AtelierHero = ({ t }) => (
  <section style={{ position: 'relative', height: 820, overflow: 'hidden' }}>
    <Img src={BRAND.heroPhoto} alt="" tone={t.goldSoft} style={{ position: 'absolute', inset: 0 }} />
    <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(30,49,40,0.55) 0%, rgba(30,49,40,0.85) 100%)' }} />
    <div style={{
      position: 'absolute', inset: 0,
      display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center',
      textAlign: 'center', padding: '0 120px',
    }}>
      <div style={{ ...aLabel, color: t.gold, marginBottom: 32 }}>
        {BRAND.since ? `— Est. ${BRAND.since} —` : '— Atelier —'}
      </div>
      <h1 style={{ ...aDisplay(96), color: t.paper, marginBottom: 24, maxWidth: 1100 }}>
        Vyrábíme <span style={{ ...aDisplay(96, true), color: t.gold }}>prostory,</span> ne&nbsp;nábytek.
      </h1>
      <div style={{ width: 64, height: 1, background: t.gold, margin: '32px auto' }} />
      <p style={{
        fontFamily: '"Cormorant Garamond", serif',
        fontStyle: 'italic', fontSize: 22, color: t.paperSoft,
        maxWidth: 680, lineHeight: 1.5, fontWeight: 400,
      }}>
        Každá kuchyně, každá skříň, každý interiér&nbsp;— odpověď na otázku, kterou jsme Vám položili. Bez kompromisů, bez subdodávek.
      </p>
      <div style={{ marginTop: 48, display: 'flex', gap: 24 }}>
        <a href="#realizace" style={{
          padding: '18px 36px', background: t.gold, color: t.bg,
          textDecoration: 'none', fontSize: 12, fontWeight: 600,
          letterSpacing: '0.16em', textTransform: 'uppercase',
        }}>
          Naše realizace
        </a>
        <a href="#navsteva" style={{
          padding: '18px 36px', background: 'transparent', color: t.paper,
          textDecoration: 'none', fontSize: 12, fontWeight: 500,
          letterSpacing: '0.16em', textTransform: 'uppercase',
          border: `1px solid ${t.ruleStrong}`,
        }}>
          Návštěva ateliéru
        </a>
      </div>
    </div>
  </section>
);

// ── MANIFESTO — centered editorial copy ────────────────────────────────────
const AtelierManifesto = ({ t }) => (
  <section style={{ padding: '160px 80px', borderBottom: `1px solid ${t.rule}` }}>
    <div style={{ maxWidth: 880, margin: '0 auto', textAlign: 'center' }}>
      <div style={{ ...aLabel, color: t.gold, marginBottom: 32 }}>I — Filosofie</div>
      <h2 style={{ ...aDisplay(56), color: t.paper, marginBottom: 48, lineHeight: 1.15 }}>
        Žádná kuchyně se nepodobá té&nbsp;druhé. <br />
        <span style={{ ...aDisplay(56, true), color: t.gold }}>Stejně jako Vaše představy.</span>
      </h2>
      <div style={{ width: 48, height: 1, background: t.gold, margin: '40px auto' }} />
      <p style={{ fontFamily: '"Cormorant Garamond", serif', fontStyle: 'italic', fontSize: 22, color: t.paperSoft, lineHeight: 1.6, fontWeight: 400, marginBottom: 24 }}>
        Pracujeme s&nbsp;dřevem, jako sochař pracuje s&nbsp;kamenem — pomalu, pečlivě, s&nbsp;respektem k&nbsp;materiálu.
      </p>
      <p style={{ ...aBody, fontSize: 16, color: t.paperSoft, maxWidth: 680, margin: '0 auto', lineHeight: 1.8 }}>
        Vyrábíme limitované série — kuchyně, skříně a interiéry pro klienty, kteří vědí, co chtějí. Konzultace, návrh, výroba i montáž — vše ve vlastní dílně{BRAND.location ? ` v ${BRAND.location}` : ''}.
      </p>
    </div>
  </section>
);

// ── COLLECTIONS — 2-col alternating rich editorial ─────────────────────────
const AtelierCollections = ({ t }) => {
  const cats = CATEGORIES.length > 0 ? CATEGORIES.slice(0, 4) : [
    { id: 'kuchyne', label: 'Kuchyně' },
    { id: 'skrine', label: 'Skříně' },
    { id: 'interiery', label: 'Interiéry' },
    { id: 'dvere', label: 'Dveře' },
  ];
  const heros = BRAND.heroPhotos && BRAND.heroPhotos.length ? BRAND.heroPhotos : [BRAND.heroPhoto];
  return (
    <section id="realizace" style={{ padding: '160px 80px', background: t.bgAlt, borderBottom: `1px solid ${t.rule}` }}>
      <div style={{ textAlign: 'center', marginBottom: 96 }}>
        <div style={{ ...aLabel, color: t.gold, marginBottom: 20 }}>II — Realizace</div>
        <h2 style={{ ...aDisplay(56), color: t.paper, maxWidth: 720, margin: '0 auto' }}>
          Vybrané <span style={{ ...aDisplay(56, true), color: t.gold }}>kolekce.</span>
        </h2>
      </div>
      <div style={{ display: 'flex', flexDirection: 'column', gap: 120 }}>
        {cats.map((c, i) => {
          const reverse = i % 2 === 1;
          return (
            <div key={c.id} style={{
              display: 'grid',
              gridTemplateColumns: '1fr 1fr',
              gap: 80, alignItems: 'center',
              direction: reverse ? 'rtl' : 'ltr',
            }}>
              <div style={{ direction: 'ltr', position: 'relative', aspectRatio: '4/5', overflow: 'hidden' }}>
                <Img src={c.img || heros[i % heros.length]} alt={c.label} tone={t.goldSoft} style={{ position: 'absolute', inset: 0 }} />
                <div style={{
                  position: 'absolute', bottom: 24, left: 24,
                  background: t.bg, padding: '12px 20px',
                  ...aLabel, color: t.gold,
                }}>
                  Kolekce {String(i + 1).padStart(2, '0')}
                </div>
              </div>
              <div style={{ direction: 'ltr', padding: reverse ? '0 0 0 24px' : '0 24px 0 0' }}>
                <div style={{ ...aLabel, color: t.gold, marginBottom: 16 }}>
                  0{i + 1} · {(c.label || '').split(' ')[0]}
                </div>
                <h3 style={{ ...aDisplay(44), color: t.paper, marginBottom: 24 }}>
                  {c.label}
                </h3>
                <p style={{ ...aBody, color: t.paperSoft, fontSize: 16, lineHeight: 1.7, marginBottom: 32, maxWidth: 480 }}>
                  {c.short || _atelierCopy(c.id)}
                </p>
                <a href={`#${c.id}`} style={{
                  ...aLabel, color: t.gold, textDecoration: 'none',
                  borderBottom: `1px solid ${t.gold}`, paddingBottom: 6,
                }}>
                  Prohlédnout kolekci →
                </a>
              </div>
            </div>
          );
        })}
      </div>
    </section>
  );
};

const _atelierCopy = (id) => ({
  kuchyne: 'Kuchyně z masivu, dýhy či lakované MDF. Každá zakázka je samostatný projekt — od koncepce přes výběr materiálů po finální montáž.',
  skrine: 'Vestavěné skříně a šatny na míru. Posuvné systémy, bezúchytkový design, vnitřní organizace dle Vašich potřeb.',
  interiery: 'Komplexní řešení interiéru — od kuchyně přes obývací pokoj po pracovnu. Návrh, výroba a montáž v rámci jednoho projektu.',
  dvere: 'Vchodové i interiérové dveře z masivu. Tradiční i moderní design, vždy na míru rámu.',
}[id] || 'Tato kolekce reaguje na specifické zadání klienta. Konzultaci a návrh řešíme individuálně.');

// ── PROCESS — vertical roman numeral timeline ──────────────────────────────
const AtelierProcess = ({ t }) => (
  <section style={{ padding: '160px 80px', borderBottom: `1px solid ${t.rule}` }}>
    <div style={{ textAlign: 'center', marginBottom: 96 }}>
      <div style={{ ...aLabel, color: t.gold, marginBottom: 20 }}>III — Proces</div>
      <h2 style={{ ...aDisplay(56), color: t.paper, maxWidth: 720, margin: '0 auto' }}>
        Cesta od&nbsp;představy <span style={{ ...aDisplay(56, true), color: t.gold }}>k&nbsp;realitě.</span>
      </h2>
    </div>
    <div style={{ maxWidth: 880, margin: '0 auto', display: 'flex', flexDirection: 'column', gap: 64 }}>
      {[
        ['I', 'Konzultace', 'Sejdeme se u Vás nebo v našem ateliéru. Posloucháme, ptáme se, dotýkáme se materiálů. Nic se neslibuje, nic se neplatí.'],
        ['II', 'Návrh', 'Vizualizace, půdorys, výběr materiálů a finální cenová kalkulace. V této fázi máme čas — návrh ladíme spolu, dokud Vám nesedne.'],
        ['III', 'Výroba', 'V naší dílně. Bez subdodávek, bez polotovarů. Každý kus prochází našima rukama.'],
        ['IV', 'Montáž', 'Přijedeme, namontujeme, uklidíme po sobě. Záruka 5 let na výrobu, doživotní vztah.'],
      ].map(([num, title, body]) => (
        <div key={num} style={{ display: 'grid', gridTemplateColumns: '120px 1fr', gap: 48, paddingBottom: 64, borderBottom: `1px solid ${t.rule}` }}>
          <div style={{
            ...aDisplay(72, true), color: t.gold,
            textAlign: 'center', lineHeight: 1,
          }}>
            {num}
          </div>
          <div>
            <h3 style={{ ...aDisplay(32), color: t.paper, marginBottom: 16 }}>{title}</h3>
            <p style={{ ...aBody, fontSize: 16, color: t.paperSoft, lineHeight: 1.7, maxWidth: 560 }}>
              {body}
            </p>
          </div>
        </div>
      ))}
    </div>
  </section>
);

// ── VISIT — premium "atelier visit" CTA with cinematic photo ──────────────
const AtelierVisit = ({ t }) => (
  <section id="navsteva" style={{
    padding: '160px 80px', background: t.bgAlt,
    position: 'relative', overflow: 'hidden', borderBottom: `1px solid ${t.rule}`,
  }}>
    <div style={{ position: 'relative', zIndex: 2, textAlign: 'center', maxWidth: 880, margin: '0 auto' }}>
      <div style={{ ...aLabel, color: t.gold, marginBottom: 32 }}>IV — Návštěva</div>
      <h2 style={{ ...aDisplay(72), color: t.paper, marginBottom: 32 }}>
        Navštivte <span style={{ ...aDisplay(72, true), color: t.gold }}>atelier.</span>
      </h2>
      <p style={{ ...aBody, fontSize: 18, color: t.paperSoft, marginBottom: 48, lineHeight: 1.7, maxWidth: 640, margin: '0 auto 48px' }}>
        Sejdeme se ve vaší domácnosti, na stavbě, nebo v naší dílně{BRAND.location ? ` v ${BRAND.location}` : ''}. Konzultace
        i&nbsp;první návrh jsou zdarma, bez závazků.
      </p>
      <a href={`tel:${BRAND.phone}`} style={{
        display: 'inline-block', padding: '24px 48px',
        background: t.gold, color: t.bg,
        textDecoration: 'none', fontSize: 12, fontWeight: 600,
        letterSpacing: '0.18em', textTransform: 'uppercase',
      }}>
        Domluvit návštěvu — {BRAND.phoneDisplay}
      </a>
    </div>
  </section>
);

// ── FOOTER — minimalist dark, gold links ───────────────────────────────────
const AtelierFooter = ({ t }) => (
  <footer style={{ padding: '80px 80px 40px', background: t.bg }}>
    <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr', gap: 80, marginBottom: 64 }}>
      <div>
        <img src={BRAND.logoPath} alt={BRAND.name} style={{ height: 60, width: 'auto', filter: 'brightness(0) invert(1)', opacity: 0.95, marginBottom: 24 }} />
        <p style={{ ...aBody, color: t.paperSoft, fontSize: 14, maxWidth: 360 }}>
          {BRAND.tagline || 'Atelier pro nábytek a interiéry na míru.'}
        </p>
      </div>
      <div>
        <div style={{ ...aLabel, color: t.gold, marginBottom: 20 }}>Kontakt</div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12, fontSize: 14 }}>
          <a href={`tel:${BRAND.phone}`} style={{ color: t.paperSoft, textDecoration: 'none' }}>{BRAND.phoneDisplay}</a>
          <a href={`mailto:${BRAND.email}`} style={{ color: t.paperSoft, textDecoration: 'none' }}>{BRAND.email}</a>
          <div style={{ color: t.paperMuted }}>{BRAND.address || BRAND.location || ''}</div>
        </div>
      </div>
      <div>
        <div style={{ ...aLabel, color: t.gold, marginBottom: 20 }}>Atelier</div>
        <div style={{ display: 'flex', flexDirection: 'column', gap: 12, fontSize: 14 }}>
          {['Filosofie', 'Realizace', 'Proces', 'Návštěva'].map(l => (
            <a key={l} href="#" style={{ color: t.paperSoft, textDecoration: 'none' }}>{l}</a>
          ))}
        </div>
      </div>
    </div>
    <div style={{ paddingTop: 32, borderTop: `1px solid ${t.rule}`, display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 11, color: t.paperMuted, letterSpacing: '0.08em', textTransform: 'uppercase' }}>
      <div>© {BRAND.name} {BRAND.since ? `· Est. ${BRAND.since}` : ''}</div>
      <div>{BRAND.domain || ''}</div>
    </div>
  </footer>
);

// ============================================================================
// MOBILE
// ============================================================================
const AtelierMobile = () => {
  const t = atelierTokens;
  return (
    <div style={{ width: 390, fontFamily: '"Inter", -apple-system, sans-serif', color: t.paper, background: t.bg, overflow: 'hidden' }}>
      <nav style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', padding: '24px 24px', borderBottom: `1px solid ${t.rule}` }}>
        <img src={BRAND.logoPath} alt={BRAND.name} style={{ height: 40, filter: 'brightness(0) invert(1)', opacity: 0.95 }} />
        {BRAND.since ? <div style={{ ...aLabel, color: t.gold, fontSize: 9 }}>{`Est. ${BRAND.since}`}</div> : null}
      </nav>

      <section style={{ position: 'relative', height: 640, overflow: 'hidden' }}>
        <Img src={BRAND.heroPhoto} alt="" tone={t.goldSoft} style={{ position: 'absolute', inset: 0 }} />
        <div style={{ position: 'absolute', inset: 0, background: 'linear-gradient(180deg, rgba(30,49,40,0.4) 0%, rgba(30,49,40,0.9) 100%)' }} />
        <div style={{ position: 'absolute', inset: 0, padding: '40px 24px', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignItems: 'center', textAlign: 'center' }}>
          <div style={{ ...aLabel, color: t.gold, marginBottom: 24 }}>— Atelier —</div>
          <h1 style={{ ...aDisplay(48), color: t.paper, marginBottom: 24 }}>
            Vyrábíme <span style={{ ...aDisplay(48, true), color: t.gold }}>prostory,</span><br />ne nábytek.
          </h1>
          <div style={{ width: 40, height: 1, background: t.gold, margin: '24px auto' }} />
          <p style={{ fontFamily: '"Cormorant Garamond", serif', fontStyle: 'italic', fontSize: 17, color: t.paperSoft, lineHeight: 1.5, marginBottom: 32, maxWidth: 320 }}>
            Limitované série pro klienty, kteří vědí.
          </p>
        </div>
      </section>

      <section style={{ padding: '64px 24px', textAlign: 'center', borderBottom: `1px solid ${t.rule}` }}>
        <div style={{ ...aLabel, color: t.gold, marginBottom: 16 }}>I — Filosofie</div>
        <h2 style={{ ...aDisplay(34), color: t.paper, marginBottom: 24, lineHeight: 1.15 }}>
          Žádná kuchyně se nepodobá té druhé.
        </h2>
        <p style={{ fontFamily: '"Cormorant Garamond", serif', fontStyle: 'italic', fontSize: 17, color: t.paperSoft, lineHeight: 1.6 }}>
          Pracujeme s dřevem jako sochař s kamenem.
        </p>
      </section>

      <section style={{ padding: '48px 24px', background: t.bgAlt, textAlign: 'center' }}>
        <div style={{ ...aLabel, color: t.gold, marginBottom: 16 }}>Návštěva</div>
        <h2 style={{ ...aDisplay(32), color: t.paper, marginBottom: 32 }}>Domluvit konzultaci.</h2>
        <a href={`tel:${BRAND.phone}`} style={{
          display: 'inline-block', padding: '18px 32px',
          background: t.gold, color: t.bg, textDecoration: 'none',
          fontSize: 12, fontWeight: 600, letterSpacing: '0.16em', textTransform: 'uppercase',
        }}>
          {BRAND.phoneDisplay}
        </a>
      </section>
    </div>
  );
};

Object.assign(window, { AtelierDesktop, AtelierMobile });
