/* Skytech Wireframe System v2 — descriptive grey placeholders, no fake imagery.
   Visual vocabulary:
   - Pure grayscale. No brand color. Placeholder type only.
   - Grey boxes with descriptive text where imagery will go.
   - No dot-grid "fake formations" — those were confusing, replaced with honest descriptions.
   - Type: system-ui / Georgia (for display). Will be overridden by brand later.
*/

const WFPage = ({ children, label }) => (
  <div data-screen-label={label} style={{
    background: '#fafaf9',
    color: '#1a1a1a',
    minHeight: '100%',
    fontFamily: "ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif",
    fontSize: 15,
    lineHeight: 1.55,
  }}>{children}</div>
);

const WFContainer = ({ children, width = 1160, style = {} }) => (
  <div style={{ maxWidth: width, margin: '0 auto', padding: '0 32px', ...style }}>{children}</div>
);

const WFSection = ({ children, label, pad = '80px 0', bg = 'transparent', border = 'top' }) => (
  <section style={{
    padding: pad,
    background: bg,
    borderTop: border === 'top' || border === 'both' ? '1px solid #e5e5e2' : 'none',
    borderBottom: border === 'both' ? '1px solid #e5e5e2' : 'none',
    position: 'relative',
  }}>
    {label && <SectionLabel>{label}</SectionLabel>}
    {children}
  </section>
);

const SectionLabel = ({ children }) => (
  <div style={{
    position: 'absolute',
    top: 8,
    right: 16,
    fontSize: 10,
    letterSpacing: '0.12em',
    textTransform: 'uppercase',
    color: '#a3a39e',
    fontFamily: 'ui-monospace, Menlo, monospace',
  }}>{children}</div>
);

/* ── PLACEHOLDER: grey box + descriptive text. No fake imagery. ── */
const WFImage = ({ description, size, kind = 'image', aspect, style = {} }) => (
  <div style={{
    aspectRatio: aspect,
    background: '#e5e5e2',
    border: '1px solid #d4d4d0',
    borderRadius: 2,
    display: 'flex',
    flexDirection: 'column',
    padding: '24px 28px',
    position: 'relative',
    minHeight: aspect ? undefined : 220,
    ...style,
  }}>
    <div style={{
      fontSize: 10,
      letterSpacing: '0.14em',
      textTransform: 'uppercase',
      color: '#6b6b66',
      fontFamily: 'ui-monospace, Menlo, monospace',
      marginBottom: 14,
      display: 'flex',
      justifyContent: 'space-between',
    }}>
      <span>[ {kind.toUpperCase()} PLACEHOLDER ]</span>
      {size && <span>{size}</span>}
    </div>
    <div style={{
      fontSize: 14,
      color: '#3a3a36',
      lineHeight: 1.55,
      fontStyle: 'italic',
      maxWidth: '58ch',
    }}>{description}</div>
  </div>
);

/* Coverage map — simple geographic indicator, stylized grey shapes (not real cartography) */
const CoverageMap = ({ height = 320 }) => (
  <div style={{
    background: '#e5e5e2',
    border: '1px solid #d4d4d0',
    height,
    position: 'relative',
    overflow: 'hidden',
  }}>
    <div style={{
      position: 'absolute',
      top: 14,
      left: 18,
      fontSize: 10,
      letterSpacing: '0.14em',
      textTransform: 'uppercase',
      color: '#6b6b66',
      fontFamily: 'ui-monospace, Menlo, monospace',
      zIndex: 2,
    }}>[ MAP PLACEHOLDER · SERVICE AREA ]</div>

    <svg viewBox="0 0 400 240" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%' }}>
      {/* AB/BC outline — stylized, not accurate */}
      <path d="M 40 40 L 200 40 L 200 210 L 40 210 Z" fill="#d4d4d0" stroke="#a3a39e" strokeWidth="1" />
      <path d="M 200 40 L 360 40 L 360 210 L 200 210 Z" fill="#ededea" stroke="#a3a39e" strokeWidth="1" />
      {/* Coverage shaded region */}
      <path d="M 80 40 L 200 40 L 280 40 L 280 140 L 200 140 L 80 140 Z"
        fill="#1a1a1a" fillOpacity="0.12" stroke="#1a1a1a" strokeWidth="1.2" strokeDasharray="3 2" />
      {/* Provincial border label */}
      <text x="200" y="225" textAnchor="middle" fontSize="9" fontFamily="ui-monospace,monospace" fill="#6b6b66">AB / BC border</text>
      {/* Grande Prairie marker */}
      <circle cx="170" cy="92" r="5" fill="#1a1a1a" />
      <circle cx="170" cy="92" r="10" fill="none" stroke="#1a1a1a" strokeWidth="1" />
      <text x="180" y="90" fontSize="11" fontFamily="ui-sans-serif,system-ui" fill="#1a1a1a" fontWeight="600">Grande Prairie</text>
      <text x="180" y="104" fontSize="9" fontFamily="ui-monospace,monospace" fill="#6b6b66">HQ</text>
      {/* Region labels */}
      <text x="120" y="70" fontSize="10" fontFamily="ui-sans-serif,system-ui" fill="#3a3a36">NORTHERN ALBERTA</text>
      <text x="230" y="70" fontSize="10" fontFamily="ui-sans-serif,system-ui" fill="#3a3a36">NORTHEASTERN BC</text>
      <text x="200" y="125" textAnchor="middle" fontSize="9" fontFamily="ui-sans-serif,system-ui" fill="#6b6b66" fontStyle="italic">Peace Region</text>
    </svg>
  </div>
);

/* Site-plan schematic — kept for Safety page (this is a genuine diagram, not a fake photo) */
const SitePlanDiagram = ({ height = 320 }) => (
  <div style={{
    width: '100%', height, position: 'relative',
    background: '#fcfcfb',
    border: '1px solid #d4d4d0',
    backgroundImage: 'linear-gradient(#eeeeea 1px, transparent 1px), linear-gradient(90deg, #eeeeea 1px, transparent 1px)',
    backgroundSize: '20px 20px',
  }}>
    <div style={{
      position: 'absolute', top: 10, left: 14,
      fontSize: 10, letterSpacing: '0.14em', textTransform: 'uppercase',
      color: '#6b6b66', fontFamily: 'ui-monospace, Menlo, monospace',
    }}>[ SITE-PLAN SCHEMATIC · NOT A PHOTO ]</div>
    <svg viewBox="0 0 400 240" style={{ position: 'absolute', inset: 0, width: '100%', height: '100%' }}>
      <rect x="20" y="20" width="360" height="200" fill="none" stroke="#a3a39e" strokeWidth="1" strokeDasharray="4 3" />
      <rect x="140" y="40" width="140" height="100" fill="#f4f4f0" stroke="#1a1a1a" strokeWidth="1.2" />
      <text x="210" y="95" textAnchor="middle" fontSize="10" fontFamily="ui-monospace,monospace" fill="#1a1a1a">FLIGHT BOX</text>
      <rect x="110" y="15" width="200" height="150" fill="none" stroke="#6b6b66" strokeWidth="1" strokeDasharray="2 2" />
      <text x="310" y="25" fontSize="8" fontFamily="ui-monospace,monospace" fill="#6b6b66">SAFETY BUFFER</text>
      <rect x="60" y="170" width="280" height="40" fill="none" stroke="#1a1a1a" strokeWidth="1" />
      <text x="200" y="195" textAnchor="middle" fontSize="10" fontFamily="ui-monospace,monospace" fill="#1a1a1a">AUDIENCE AREA</text>
      <circle cx="50" cy="130" r="5" fill="#1a1a1a" />
      <text x="50" y="148" textAnchor="middle" fontSize="8" fontFamily="ui-monospace,monospace" fill="#1a1a1a">GCS</text>
      {[0, 1, 2, 3].map(i => <circle key={i} cx={160 + i * 25} cy={125} r={3} fill="none" stroke="#1a1a1a" />)}
      <text x="210" y="160" textAnchor="middle" fontSize="8" fontFamily="ui-monospace,monospace" fill="#6b6b66">Launch pads</text>
    </svg>
  </div>
);

/* ── TEXT + UI ── */
const WFH1 = ({ children, style = {} }) => (
  <h1 style={{
    fontFamily: 'Georgia, "Times New Roman", serif',
    fontWeight: 400,
    fontSize: 'clamp(32px, 4.6vw, 58px)',
    lineHeight: 1.08,
    letterSpacing: '-0.01em',
    margin: 0,
    color: '#1a1a1a',
    textWrap: 'balance',
    ...style,
  }}>{children}</h1>
);

const WFH2 = ({ children, style = {} }) => (
  <h2 style={{
    fontFamily: 'Georgia, "Times New Roman", serif',
    fontWeight: 400,
    fontSize: 'clamp(24px, 2.6vw, 34px)',
    lineHeight: 1.18,
    letterSpacing: '-0.005em',
    margin: 0,
    color: '#1a1a1a',
    textWrap: 'balance',
    ...style,
  }}>{children}</h2>
);

const WFEyebrow = ({ children }) => (
  <div style={{
    fontSize: 11, letterSpacing: '0.18em', textTransform: 'uppercase',
    color: '#6b6b66', fontFamily: 'ui-monospace, Menlo, monospace',
    marginBottom: 16,
  }}>{children}</div>
);

const WFLede = ({ children, style = {} }) => (
  <p style={{ fontSize: 18, lineHeight: 1.55, color: '#3a3a36', margin: 0, maxWidth: '62ch', ...style }}>{children}</p>
);

const WFBody = ({ children, style = {} }) => (
  <p style={{ fontSize: 15, lineHeight: 1.65, color: '#3a3a36', margin: 0, maxWidth: '62ch', ...style }}>{children}</p>
);

const WFButton = ({ children, primary, onClick, style = {} }) => (
  <button onClick={onClick} style={{
    display: 'inline-flex', alignItems: 'center', gap: 10,
    padding: '13px 22px',
    background: primary ? '#1a1a1a' : 'transparent',
    color: primary ? '#fafaf9' : '#1a1a1a',
    border: '1px solid #1a1a1a',
    borderRadius: 0, fontFamily: 'inherit', fontSize: 14, fontWeight: 500,
    letterSpacing: '0.01em', cursor: 'pointer', textDecoration: 'none',
    ...style,
  }}>
    {children} <span style={{ fontSize: 16, lineHeight: 1 }}>→</span>
  </button>
);

const WFLink = ({ children, onClick, style = {} }) => (
  <a onClick={e => { e.preventDefault(); onClick && onClick(); }} href="#" style={{
    color: '#1a1a1a', textDecoration: 'none',
    borderBottom: '1px solid #1a1a1a', paddingBottom: 2,
    fontSize: 14, display: 'inline-flex', alignItems: 'center', gap: 6,
    ...style,
  }}>{children} <span style={{ fontSize: 14 }}>→</span></a>
);

/* ── NAV ── */
const WFNav = ({ currentPage, nav }) => (
  <nav className="wf-site-nav" style={{
    borderBottom: '1px solid #e5e5e2',
    background: '#fafaf9',
    position: 'sticky',
    zIndex: 10,
  }}>
    <WFContainer style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', height: 68 }}>
      <div onClick={() => nav('home')} style={{ cursor: 'pointer', display: 'flex', alignItems: 'center', gap: 10 }}>
        <div style={{
          width: 120, height: 32,
          background: '#e5e5e2',
          border: '1px solid #d4d4d0',
          display: 'flex', alignItems: 'center', justifyContent: 'center',
          fontSize: 9, fontFamily: 'ui-monospace, Menlo, monospace', color: '#6b6b66',
          letterSpacing: '0.1em',
        }}>[ SKYTECH LOGO ]</div>
      </div>
      <div style={{ display: 'flex', gap: 32, alignItems: 'center' }}>
        {[
          ['services', 'Services'],
          ['safety', 'Safety + Compliance'],
          ['portfolio', 'Portfolio'],
        ].map(([key, label]) => (
          <a key={key} onClick={e => { e.preventDefault(); nav(key); }} href="#" style={{
            fontSize: 14,
            color: currentPage === key ? '#1a1a1a' : '#3a3a36',
            textDecoration: 'none',
            borderBottom: currentPage === key ? '1px solid #1a1a1a' : '1px solid transparent',
            paddingBottom: 3,
          }}>{label}</a>
        ))}
        <button onClick={() => nav('contact')} style={{
          padding: '9px 18px', background: '#1a1a1a', color: '#fafaf9',
          border: '1px solid #1a1a1a', borderRadius: 0, fontSize: 13,
          fontFamily: 'inherit', cursor: 'pointer', fontWeight: 500,
        }}>Request a Quote</button>
      </div>
    </WFContainer>
  </nav>
);

const WFFooter = ({ nav }) => (
  <footer style={{ borderTop: '1px solid #e5e5e2', padding: '64px 0 40px', background: '#f4f4f0', marginTop: 80 }}>
    <WFContainer>
      <div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr 1fr 1fr', gap: 48, marginBottom: 56 }}>
        <div>
          <div style={{
            width: 140, height: 34, marginBottom: 20,
            background: '#e5e5e2', border: '1px solid #d4d4d0',
            display: 'flex', alignItems: 'center', justifyContent: 'center',
            fontSize: 9, fontFamily: 'ui-monospace, Menlo, monospace', color: '#6b6b66',
            letterSpacing: '0.1em',
          }}>[ SKYTECH LOGO ]</div>
          <p style={{ fontSize: 13, color: '#6b6b66', margin: 0, maxWidth: 340, lineHeight: 1.6 }}>
            Skytech Drone Light Shows Ltd.<br />
            Drone light shows across Northern Alberta and Northeastern BC, including the Peace Region.<br /><br />
            Based in Grande Prairie, Alberta.
          </p>
        </div>
        <FooterCol title="Site">
          <FooterLink onClick={() => nav('home')}>Home</FooterLink>
          <FooterLink onClick={() => nav('services')}>Services</FooterLink>
          <FooterLink onClick={() => nav('safety')}>Safety + Compliance</FooterLink>
          <FooterLink onClick={() => nav('portfolio')}>Portfolio</FooterLink>
          <FooterLink onClick={() => nav('contact')}>Contact</FooterLink>
        </FooterCol>
        <FooterCol title="Contact">
          <div style={{ fontSize: 14, color: '#1a1a1a' }}>matt@skytechdroneshows.com</div>
          <div style={{ fontSize: 14, color: '#1a1a1a' }}>david@skytechdroneshows.com</div>
          <div style={{ fontSize: 13, color: '#6b6b66', marginTop: 6 }}>Grande Prairie, Alberta</div>
        </FooterCol>
        <FooterCol title="Compliance">
          <div style={{ fontSize: 13, color: '#3a3a36', lineHeight: 1.6 }}>SFOC-RPAS authorized</div>
          <div style={{ fontSize: 13, color: '#3a3a36', lineHeight: 1.6 }}>NAV Canada coordinated</div>
          <div style={{ fontSize: 13, color: '#3a3a36', lineHeight: 1.6 }}>NAICS 711190</div>
        </FooterCol>
      </div>
      <div style={{
        borderTop: '1px solid #d4d4d0', paddingTop: 24,
        display: 'flex', justifyContent: 'space-between',
        fontSize: 11, color: '#8a8a85',
        fontFamily: 'ui-monospace, Menlo, monospace', letterSpacing: '0.05em',
      }}>
        <span>© 2026 SKYTECH DRONE LIGHT SHOWS LTD.</span>
        <span>GRANDE PRAIRIE, AB · SERVING NORTHERN ALBERTA + NORTHEASTERN BC</span>
      </div>
    </WFContainer>
  </footer>
);

const FooterCol = ({ title, children }) => (
  <div>
    <div style={{
      fontSize: 11, letterSpacing: '0.12em', textTransform: 'uppercase',
      color: '#6b6b66', fontFamily: 'ui-monospace, Menlo, monospace', marginBottom: 14,
    }}>{title}</div>
    <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>{children}</div>
  </div>
);

const FooterLink = ({ children, onClick }) => (
  <a onClick={e => { e.preventDefault(); onClick && onClick(); }} href="#" style={{ fontSize: 14, color: '#1a1a1a', textDecoration: 'none' }}>{children}</a>
);

const CredStrip = () => (
  <div style={{
    display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 0,
    border: '1px solid #e5e5e2', background: '#fff',
  }}>
    {[
      ['SFOC-RPAS', 'Special Flight Operations Certificate for RPAS, every show'],
      ['NAV CANADA', 'NAV Drone coordination and NOTAM filing where required'],
      ['NAICS 711190', 'Performing arts classification'],
      ['LOCAL', 'Based in Grande Prairie · not a touring provider'],
    ].map(([k, v], i) => (
      <div key={k} style={{ padding: '24px 24px', borderRight: i < 3 ? '1px solid #e5e5e2' : 'none' }}>
        <div style={{ fontSize: 11, letterSpacing: '0.14em', textTransform: 'uppercase', fontFamily: 'ui-monospace, Menlo, monospace', color: '#1a1a1a', marginBottom: 8 }}>{k}</div>
        <div style={{ fontSize: 13, color: '#3a3a36', lineHeight: 1.5 }}>{v}</div>
      </div>
    ))}
  </div>
);

const FinalCTA = ({ nav }) => (
  <WFSection label="CLOSING CTA" bg="#1a1a1a" pad="96px 0">
    <WFContainer>
      <div style={{ display: 'grid', gridTemplateColumns: '1.4fr 1fr', gap: 80, alignItems: 'center' }}>
        <div>
          <div style={{ fontSize: 11, letterSpacing: '0.18em', textTransform: 'uppercase', color: '#a3a39e', fontFamily: 'ui-monospace, Menlo, monospace', marginBottom: 16 }}>Request a Quote</div>
          <WFH1 style={{ color: '#fafaf9', marginBottom: 24 }}>
            A drone light show for your event, quoted for your date and location.
          </WFH1>
          <WFLede style={{ color: '#c8c8c4' }}>
            Summer events typically book four to nine months ahead. If your date is sooner, reach out anyway — we will say plainly whether it's workable.
          </WFLede>
        </div>
        <div>
          <button onClick={() => nav('contact')} style={{
            width: '100%', padding: '22px 28px',
            background: '#fafaf9', color: '#1a1a1a',
            border: '1px solid #fafaf9', borderRadius: 0,
            fontSize: 16, fontFamily: 'inherit', fontWeight: 500,
            cursor: 'pointer', textAlign: 'left',
            display: 'flex', justifyContent: 'space-between', alignItems: 'center',
          }}>
            <span>Request a Quote</span>
            <span style={{ fontSize: 20 }}>→</span>
          </button>
          <div style={{ marginTop: 16, fontSize: 12, color: '#a3a39e', fontFamily: 'ui-monospace, Menlo, monospace', letterSpacing: '0.04em' }}>
            matt@skytechdroneshows.com
          </div>
        </div>
      </div>
    </WFContainer>
  </WFSection>
);

Object.assign(window, {
  WFPage, WFContainer, WFSection, SectionLabel,
  WFImage, CoverageMap, SitePlanDiagram,
  WFH1, WFH2, WFEyebrow, WFLede, WFBody, WFButton, WFLink,
  WFNav, WFFooter, CredStrip, FinalCTA,
});
