// components/enterprise.el - Enterprise section.
// Four capability cards + "Who I work with" box + how-it-works steps.

extern fn el_section(attrs: String, children: String) -> String
extern fn el_div(attrs: String, children: String) -> String
extern fn el_span(attrs: String, children: String) -> String
extern fn el_h2(attrs: String, text: String) -> String
extern fn el_h3(attrs: String, text: String) -> String
extern fn el_p(attrs: String, children: String) -> String
extern fn el_a(href: String, attrs: String, children: String) -> String
extern fn el_form(attrs: String, children: String) -> String
extern fn el_label(for_id: String, attrs: String, children: String) -> String
extern fn el_input(type_attr: String, attrs: String) -> String
extern fn el_textarea(attrs: String, value: String) -> String
extern fn el_button(attrs: String, label: String) -> String
extern fn el_script_src(src: String, defer_load: Bool) -> String

fn enterprise_cap_cards() -> String {
    let card1: String = el_div(
        "class=\"enterprise-cap card-dark reveal\"",
        el_h3("class=\"display-md\"", "Private deployment") +
        el_div("class=\"enterprise-cap-rule\"", "") +
        el_p("class=\"enterprise-cap-body\"", "Run entirely on your infrastructure. Air-gapped. No data leaves your network. Every employee gets their own Neuron instance - your company&#39;s institutional knowledge stays inside your walls.")
    )
    let card2: String = el_div(
        "class=\"enterprise-cap card-dark reveal\" style=\"transition-delay:130ms\"",
        el_h3("class=\"display-md\"", "Institutional memory") +
        el_div("class=\"enterprise-cap-rule\"", "") +
        el_p("class=\"enterprise-cap-body\"", "When an employee leaves, their expertise doesn&#39;t. Their memory persists - their patterns, their domain knowledge, their reasoning - available to the team they built it with.")
    )
    let card3: String = el_div(
        "class=\"enterprise-cap card-dark reveal\" style=\"transition-delay:260ms\"",
        el_h3("class=\"display-md\"", "Team intelligence") +
        el_div("class=\"enterprise-cap-rule\"", "") +
        el_p("class=\"enterprise-cap-body\"", "Shared knowledge packages and cross-instance coordination. The collective intelligence of your organization compounds the same way an individual&#39;s does.")
    )
    let card4: String = el_div(
        "class=\"enterprise-cap card-dark reveal\" style=\"transition-delay:390ms\"",
        el_h3("class=\"display-md\"", "Compliance architecture") +
        el_div("class=\"enterprise-cap-rule\"", "") +
        el_p("class=\"enterprise-cap-body\"", "Custom on-device storage. No cloud database with your data. SOC 2 alignment built into the data model. ExternalSecret-based secrets management. Audit logs at every layer.")
    )
    el_div("class=\"enterprise-grid\"", card1 + card2 + card3 + card4)
}

fn enterprise_how_it_works() -> String {
    let step1: String = el_div(
        "",
        el_p("class=\"ent-step-num\"", "01") +
        el_p("class=\"ent-step-title\"", "Express interest") +
        el_p("class=\"ent-step-body\"", "Send me a note. I review every inquiry myself - no sales funnel, no SDR. If it&#39;s a fit, I respond directly.")
    )
    let step2: String = el_div(
        "",
        el_p("class=\"ent-step-num\"", "02") +
        el_p("class=\"ent-step-title\"", "Scoped deployment") +
        el_p("class=\"ent-step-body\"", "I work with your team to scope a private deployment - on your infrastructure, in your network, with your security requirements.")
    )
    let step3: String = el_div(
        "",
        el_p("class=\"ent-step-num\"", "03") +
        el_p("class=\"ent-step-title\"", "Per-seat licensing") +
        el_p("class=\"ent-step-body\"", "Annual per-seat pricing with a volume floor. Custom SLA available. The full Agreement is published before any conversation starts.")
    )
    el_div(
        "class=\"ent-how-row\"",
        el_div(
            "class=\"ent-how-label\"",
            el_h3("class=\"display-md\" style=\"font-size:1.25rem\"", "How it works")
        ) +
        el_div("class=\"ent-steps\"", step1 + step2 + step3)
    )
}

fn enterprise_inquiry_form() -> String {
    let field_style: String = "font-family:var(--body);font-size:0.9rem;font-weight:300;color:var(--t1);background:#fff;border:1px solid rgba(0,82,160,.22);padding:0.7rem 0.9rem;outline:none;border-radius:0;-webkit-appearance:none;width:100%;box-sizing:border-box"
    let label_style: String = "font-family:var(--body);font-size:0.7rem;font-weight:500;letter-spacing:0.08em;text-transform:uppercase;color:var(--t3)"

    let field_name: String = el_div(
        "style=\"display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-name", "style=\"" + label_style + "\"", "Name") +
        el_input("text", "id=\"ent-name\" name=\"name\" required placeholder=\"Your name\" style=\"" + field_style + "\"")
    )
    let field_email: String = el_div(
        "style=\"display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-email", "style=\"" + label_style + "\"", "Work email") +
        el_input("email", "id=\"ent-email\" name=\"email\" required placeholder=\"you@company.com\" style=\"" + field_style + "\"")
    )
    let field_company: String = el_div(
        "style=\"display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-company", "style=\"" + label_style + "\"", "Organization") +
        el_input("text", "id=\"ent-company\" name=\"company\" required placeholder=\"Company or organization name\" style=\"" + field_style + "\"")
    )
    let field_size: String = el_div(
        "style=\"display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-size", "style=\"" + label_style + "\"", "Team size") +
        "<select id=\"ent-size\" name=\"size\" required style=\"" + field_style + ";cursor:pointer\">" +
        "<option value=\"\">Select&hellip;</option>" +
        "<option value=\"2-10\">2&#8211;10 people</option>" +
        "<option value=\"11-50\">11&#8211;50 people</option>" +
        "<option value=\"51-200\">51&#8211;200 people</option>" +
        "<option value=\"201-500\">201&#8211;500 people</option>" +
        "<option value=\"500+\">500+ people</option>" +
        "</select>"
    )
    let field_use: String = el_div(
        "style=\"grid-column:1/-1;display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-use", "style=\"" + label_style + "\"", "What do you want to use Neuron for?") +
        el_textarea("id=\"ent-use\" name=\"use_case\" required rows=\"3\" placeholder=\"Describe your intended use case - be specific.\" style=\"" + field_style + ";resize:vertical\"", "")
    )
    let filter_msg_secondary: String = el_p("id=\"ent-filter-msg-secondary\" style=\"display:none;font-family:var(--body);font-size:0.875rem;font-weight:300;color:rgba(0,82,160,.75);line-height:1.65;padding:0.75rem 1rem;background:rgba(0,82,160,.04);border-left:2px solid rgba(0,82,160,.3)\"",
        "I review these personally. I&#39;ll consider it - but I want to be direct with you: if headcount reduction is in the picture at all, even as a secondary outcome, your chances here are low. That&#39;s not a negotiating position. It&#39;s how I built this and what I&#39;m willing to support."
    )
    let filter_msg_yes: String = el_p("id=\"ent-filter-msg-yes\" style=\"display:none;font-family:var(--body);font-size:0.875rem;font-weight:300;color:#c0392b;line-height:1.65;padding:0.75rem 1rem;background:rgba(192,57,43,.05);border-left:2px solid rgba(192,57,43,.4)\"",
        "Neuron isn&#39;t the right fit here. I built this to expand what people can do, not to replace them. If that changes, I&#39;m here."
    )
    let field_headcount: String = el_div(
        "style=\"grid-column:1/-1;display:flex;flex-direction:column;gap:0.4rem\"",
        el_label("ent-headcount", "style=\"" + label_style + "\"", "Is reducing headcount a primary goal of this deployment?") +
        "<select id=\"ent-headcount\" name=\"headcount\" required onchange=\"entHeadcountChange(this.value)\" style=\"" + field_style + ";cursor:pointer\">" +
        "<option value=\"\">Select&hellip;</option>" +
        "<option value=\"no\">No - making our team more capable</option>" +
        "<option value=\"secondary\">It&#39;s a secondary factor, not the primary goal</option>" +
        "<option value=\"yes\">Yes - replacing roles with automation</option>" +
        "</select>" +
        filter_msg_secondary +
        filter_msg_yes
    )
    let error_div: String = el_div("id=\"ent-form-error\" style=\"grid-column:1/-1;display:none;font-family:var(--body);font-size:0.875rem;color:#c0392b;padding:0.75rem 1rem;background:rgba(192,57,43,.05);border-left:2px solid rgba(192,57,43,.4)\"", "")
    let submit_div: String = el_div(
        "style=\"grid-column:1/-1\"",
        el_button("type=\"submit\" id=\"ent-submit\" style=\"font-family:var(--body);font-size:0.75rem;font-weight:600;letter-spacing:0.12em;text-transform:uppercase;background:var(--navy);color:#fff;border:none;padding:0.95rem 2rem;cursor:pointer;transition:background .2s\"",
            "Send inquiry &#8594;"
        )
    )

    let success_div: String = el_div(
        "id=\"enterprise-success\" style=\"display:none;padding:2rem;background:rgba(0,82,160,.04);border-left:3px solid var(--navy)\"",
        el_p("style=\"font-family:var(--head);font-size:1.25rem;font-weight:500;color:var(--t1);margin-bottom:0.5rem\"", "Received.") +
        el_p("style=\"font-family:var(--body);font-weight:300;font-size:0.9375rem;color:var(--t2);line-height:1.8\"",
            "I review these personally. If it&#39;s a fit, I&#39;ll respond directly to your email - usually within a few days."
        )
    )

    el_div(
        "style=\"margin-top:3rem;padding-top:2.5rem;border-top:1px solid var(--border)\"",
        el_p("class=\"label\" style=\"margin-bottom:0.75rem;font-size:0.65rem\"", "Express interest") +
        el_p("style=\"font-family:var(--body);font-weight:300;font-size:0.9rem;color:var(--t2);line-height:1.75;margin-bottom:2rem\"",
            "I review every inquiry myself. Fill this out honestly - the questions are a filter, not a formality."
        ) +
        el_form("id=\"enterprise-form\" class=\"ent-inquiry-form\"",
            field_name + field_email + field_company + field_size + field_use + field_headcount + error_div + submit_div
        ) +
        success_div
    )
}

fn enterprise() -> String {
    let header: String = el_div(
        "class=\"enterprise-header\"",
        el_div(
            "class=\"enterprise-label-row reveal\"",
            el_div("class=\"navy-line-left\" style=\"width:4rem;flex-shrink:0\"", "") +
            el_span("class=\"label\" style=\"color:var(--navy-85)\"", "Enterprise")
        ) +
        el_div(
            "class=\"enterprise-head-row\"",
            el_div(
                "style=\"max-width:28rem\"",
                el_h2(
                    "class=\"display-lg reveal\" style=\"transition-delay:80ms\"",
                    "Enterprise-ready " + el_span("class=\"gold\"", "Q1 2027.")
                ) +
                el_p("class=\"reveal\" style=\"transition-delay:160ms;font-weight:300;font-size:.9375rem;color:var(--t2);line-height:1.7;margin-top:1.25rem\"",
                    "Not an afterthought. Not a future roadmap item. Built into the architecture from the start."
                )
            ) +
            el_div(
                "class=\"reveal\" style=\"transition-delay:240ms;display:flex;flex-direction:column;gap:.75rem;align-items:flex-end\"",
                el_div(
                    "class=\"ent-badge\"",
                    el_span("class=\"ent-badge-dot\"", "") +
                    "Enterprise discussions open now &mdash; launching Q1 2027"
                ) +
                el_p("style=\"font-size:.75rem;color:rgba(0,82,160,.45)\"",
                    "Use the form below &middot; I review every inquiry &middot; I&#39;ll be spending the holidays with my family &mdash; we launch Q1"
                )
            )
        )
    )

    let contact_block: String = el_div(
        "class=\"ent-contact-block reveal\"",
        el_div(
            "class=\"ent-contact-card\"",
            el_p("class=\"ent-contact-role\"", "Sales") +
            el_a("mailto:enterprise@neurontechnologies.ai", "class=\"ent-contact-email\"", "enterprise@neurontechnologies.ai") +
            el_p("class=\"ent-contact-desc\"", "Pricing, deployment options, and enterprise agreements.")
        ) +
        el_div(
            "class=\"ent-contact-card\"",
            el_p("class=\"ent-contact-role\"", "Security") +
            el_a("mailto:security@neurontechnologies.ai", "class=\"ent-contact-email\"", "security@neurontechnologies.ai") +
            el_p("class=\"ent-contact-desc\"", "Vulnerability disclosure, compliance review, and security documentation.")
        )
    )

    let enterprise_box: String = el_div(
        "class=\"enterprise-box reveal\"",
        el_p("class=\"ent-who-label\"", "Who I work with") +
        el_p("class=\"ent-who-body\"", "I am selective. I built Neuron to expand what people can do - not to help organizations eliminate them. If your interest in this technology is primarily about reducing headcount, I am not your vendor. If it&#39;s about making the people you have dramatically more effective, I want to hear from you.") +
        el_p("class=\"ent-who-note\"", "This isn&#39;t a legal hedge. It&#39;s a filter. The Enterprise Agreement makes it binding - but I&#39;m raising it here because I&#39;d rather you know before you reach out.") +
        enterprise_how_it_works() +
        el_div(
            "class=\"ent-terms-row\"",
            el_p("class=\"ent-terms-text\"", "The full Enterprise Agreement is published. Read it before reaching out - no NDA required to evaluate the terms.") +
            el_a("/legal/enterprise-terms", "class=\"ent-terms-link\"", "Read the Enterprise Agreement &#8594;")
        ) +
        enterprise_inquiry_form()
    )

    let style_css: String = ".ent-contact-block {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2.5rem;
  }
  .ent-contact-card {
    padding: 1.5rem;
    border: 1px solid rgba(0,82,160,.18);
    background: rgba(0,82,160,.03);
    display: flex;
    flex-direction: column;
    gap: .4rem;
  }
  .ent-contact-role {
    font-family: var(--body);
    font-size: .65rem;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--navy);
    margin-bottom: .1rem;
  }
  .ent-contact-email {
    font-family: var(--body);
    font-size: .9375rem;
    font-weight: 500;
    color: var(--t1);
    text-decoration: none;
    border-bottom: 1px solid rgba(0,82,160,.25);
    padding-bottom: .1rem;
    transition: border-color 200ms, color 200ms;
    width: fit-content;
  }
  .ent-contact-email:hover { color: var(--navy); border-color: var(--navy); }
  .ent-contact-desc {
    font-family: var(--body);
    font-size: .8125rem;
    font-weight: 300;
    color: var(--t3);
    line-height: 1.55;
    margin-top: .25rem;
  }
  @media (max-width: 600px) {
    .ent-contact-block { grid-template-columns: 1fr; }
  }
  .ent-inquiry-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  @media (max-width: 600px) {
    .ent-inquiry-form { grid-template-columns: 1fr; }
    .ent-inquiry-form > div[style*=\"grid-column:1/-1\"],
    .ent-inquiry-form > div[style*=\"grid-column: 1 / -1\"] { grid-column: 1; }
  }"

    el_section(
        "id=\"enterprise\" aria-label=\"Enterprise\"",
        el_div("class=\"container\"", header + enterprise_cap_cards() + contact_block + enterprise_box) +
        "<style>" + style_css + "</style>" +
        el_script_src("/js/enterprise.js", true)
    )
}
