---
import BaseLayout from '../layouts/BaseLayout.astro';

interface UseCase {
  name: string;
  title: string;
  description: string;
  outcomes: string[];
  icon: string;
  num: string;
}

const useCases: UseCase[] = [
  {
    name: 'design-to-print',
    title: 'Design-to-print pipeline',
    description:
      'Describe what you want in plain language or upload a sketch. Kiln generates the 3D model, validates printability, optimizes orientation, and sends it to your printer — one conversation from idea to physical object.',
    outcomes: [
      'Text-to-3D and image-to-3D generation with automatic printability analysis',
      'Material-aware design intelligence that adapts geometry for your chosen filament',
      'End-to-end pipeline: describe, generate, validate, slice, print, monitor',
    ],
    icon: '🎨',
    num: '01',
  },
  {
    name: 'printability-analysis',
    title: 'Printability analysis and optimization',
    description:
      'Catch problems before they waste filament. Kiln analyzes models for structural risks, overhang issues, thin walls, and support requirements — then suggests fixes or applies them automatically.',
    outcomes: [
      'Structural risk scoring and load-bearing analysis before printing',
      'Automatic orientation optimization to minimize supports and maximize strength',
      'Wall thickness validation and mesh repair for manifold geometry',
    ],
    icon: '🔍',
    num: '02',
  },
  {
    name: 'multi-part-assembly',
    title: 'Multi-part assembly design',
    description:
      'Design objects that are too large for a single build plate, or that require multiple materials. Kiln plans the split, generates assembly-ready parts with alignment features, and sequences the prints.',
    outcomes: [
      'Automatic splitting of oversized models into printable components',
      'Assembly planning with connector geometry and alignment guides',
      'Multi-material print coordination across AMS slots or multiple printers',
    ],
    icon: '🧩',
    num: '03',
  },
  {
    name: 'cost-estimation',
    title: 'Cost estimation and budgeting',
    description:
      'Know the cost before you commit. Kiln estimates material consumption, print time, and electricity for local jobs — or compares quotes from third-party fulfillment providers for outsourced production.',
    outcomes: [
      'Per-print material weight, time, and cost breakdown',
      'Side-by-side comparison of local printing vs. third-party fulfillment quotes',
      'Project-level cost tracking across multiple prints and materials',
    ],
    icon: '📊',
    num: '04',
  },
  {
    name: 'print-farms',
    title: 'Print farm automation',
    description:
      'Coordinate dozens of printers with queueing, routing, and failure recovery so operators spend less time babysitting machines and more time shipping parts.',
    outcomes: [
      'Priority scheduling across a mixed-firmware fleet',
      'Automated retries and reroutes when a printer fails',
      'Centralized telemetry for progress, temperatures, and health',
    ],
    icon: '🏭',
    num: '05',
  },
  {
    name: 'agent-prototyping',
    title: 'AI agent rapid prototyping',
    description:
      'Let agents move from prompt to physical part by discovering models, slicing for the target printer, and launching monitored jobs with safety guardrails.',
    outcomes: [
      'Reusable command pipelines for repeated prototype cycles',
      '800 MCP capabilities and 221 CLI commands for full workflow control',
      'REST API, CLI, and MCP interfaces for custom agent integrations',
    ],
    icon: '🤖',
    num: '06',
  },
  {
    name: 'fulfillment-routing',
    title: 'Third-party fulfillment routing',
    description:
      'When local printers are overloaded or you need professional-grade materials, Kiln searches third-party fulfillment providers and routes orders — without changing your workflow.',
    outcomes: [
      'Compare local cost versus third-party fulfillment quotes in one flow',
      'Route orders to external providers from the same Kiln interface',
      'Kiln orchestrates the workflow; the provider remains merchant of record',
    ],
    icon: '☁️',
    num: '07',
  },
  {
    name: 'education-labs',
    title: 'Education and research labs',
    description:
      'Run shared fabrication environments with safer default controls, role-aware operation, and repeatable setup for student or research teams.',
    outcomes: [
      'Constrain dangerous operations with tool tiers and safety limits',
      'Standardize setup across semester resets and staff changes',
      'Document print histories and job outcomes for reproducibility',
    ],
    icon: '🔬',
    num: '08',
  },
  {
    name: 'marketplace-creators',
    title: 'Model discovery and maker businesses',
    description:
      'Search third-party model marketplaces, generate original designs, validate printability, and go from idea to finished product with integrated tooling.',
    outcomes: [
      'Search MyMiniFactory, Cults3D, and Thingiverse (deprecated) from one interface',
      'Generate, validate, and orient designs before wasting material',
      'Automate repetitive print-and-ship workflows',
    ],
    icon: '🛒',
    num: '09',
  },
  {
    name: 'iterating-on-a-design',
    title: 'Iterating on a design without losing track',
    description:
      'You designed a coaster. You want to try three emboss depths, a thinner base, and a textured rim — but you don’t want to lose the original. Kiln branches your design the same way git branches your code. Print each variant, record what happened, merge the winner back to main, sign a release, and print with confidence.',
    outcomes: [
      'Branch in parallel — experimental changes never touch your proven version',
      'Three-way mesh merge at the geometry level (Z-levels, pockets, bounding box) — conflicts mean something real',
      'Sign a release with an Ed25519 signature; anyone can verify later that the mesh hasn’t changed',
      'Cross-branch A/B correlates print outcomes with design changes across branches',
      'Cherry-pick a single modification across branches, conflict-aware',
    ],
    icon: '🌿',
    num: '10',
  },
];

const useCasesSchema = {
  '@type': 'CollectionPage',
  name: 'Kiln Use Cases',
  about: {
    '@type': 'Thing',
    name: 'AI-powered 3D printing infrastructure',
  },
  mainEntity: {
    '@type': 'ItemList',
    itemListElement: useCases.map((useCase, index) => ({
      '@type': 'ListItem',
      position: index + 1,
      name: useCase.title,
      description: useCase.description,
    })),
  },
};
---

<BaseLayout
  title="Kiln Use Cases — From Idea to Physical Object with AI"
  description="See how teams use Kiln for design-to-print pipelines, printability analysis, multi-part assembly, cost estimation, print farm automation, and AI prototyping."
  current="use-cases"
  keywords={[
    'kiln use cases',
    'ai 3d printing workflows',
    'text to 3d print',
    'design to print pipeline',
    'printability analysis',
    'print farm software',
    '3d printer ai infrastructure',
  ]}
  schema={useCasesSchema}
>
  <section class="usecases-hero">
    <div class="container">
      <h1>Describe it or draw it. Kiln makes it real.</h1>
      <p class="lead">
        Kiln is the intelligence layer between an idea and a physical object. From text-to-print
        pipelines to fleet automation, Kiln handles every step — design, validation, slicing,
        printing, and monitoring — with safety guardrails built in.
      </p>
    </div>
  </section>

  <section class="usecases-list bordered">
    <div class="container">
      {useCases.map((useCase) => (
        <article class="usecase-row" id={useCase.name}>
          <div class="usecase-left">
            <div class="usecase-meta">
              <span class="usecase-icon">{useCase.icon}</span>
              <span class="usecase-num">{useCase.num}</span>
            </div>
            <h2>{useCase.title}</h2>
          </div>
          <div class="usecase-right">
            <p class="usecase-desc">{useCase.description}</p>
            <ul class="usecase-outcomes">
              {useCase.outcomes.map((outcome) => (
                <li>{outcome}</li>
              ))}
            </ul>
          </div>
        </article>
      ))}
    </div>
  </section>

  <section class="usecases-cta bordered">
    <div class="container">
      <h2>Build your own workflow on top of Kiln</h2>
      <p class="lead">
        Start with the install guide, then use docs and API references to tailor Kiln to your exact
        printer stack and operating model.
      </p>
      <div class="cta-actions">
        <a href="/install" class="btn">Install</a>
        <a href="/docs" class="btn btn-ghost">Documentation</a>
        <a href="/integrations" class="btn btn-ghost">Integrations</a>
      </div>
    </div>
  </section>
</BaseLayout>

<style>
  .usecases-hero {
    text-align: center;
    padding: 96px 0 44px;
  }

  .usecases-hero h1 {
    font-size: clamp(30px, 4.5vw, 46px);
    line-height: 1.15;
    margin-bottom: 14px;
  }

  .usecases-hero .lead {
    max-width: 700px;
    margin: 0 auto;
  }

  .usecases-list {
    padding-top: 0;
    padding-bottom: 0;
  }

  .bordered {
    border-top: 1px solid var(--border);
  }

  /* Each use case row */
  .usecase-row {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 48px;
    padding: 48px 0;
    border-bottom: 1px solid var(--border);
  }

  .usecase-row:last-child {
    border-bottom: none;
  }

  /* Left column */
  .usecase-left {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .usecase-meta {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .usecase-icon {
    font-size: 28px;
    line-height: 1;
  }

  .usecase-num {
    font-size: 13px;
    font-weight: 700;
    font-family: var(--mono);
    color: var(--accent);
    letter-spacing: 0.05em;
  }

  .usecase-left h2 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
  }

  /* Right column */
  .usecase-right {
    padding-top: 4px;
  }

  .usecase-desc {
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 20px;
  }

  .usecase-outcomes {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .usecase-outcomes li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.55;
  }

  .usecase-outcomes li::before {
    content: '✓';
    color: var(--accent);
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
    margin-top: 1px;
  }

  /* CTA */
  .usecases-cta {
    text-align: center;
    padding: 64px 0 96px;
  }

  .usecases-cta h2 {
    font-size: clamp(22px, 3vw, 32px);
    margin-bottom: 12px;
  }

  .usecases-cta .lead {
    margin: 0 auto 28px;
    max-width: 600px;
  }

  .cta-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
  }

  @media (max-width: 768px) {
    .usecase-row {
      grid-template-columns: 1fr;
      gap: 20px;
      padding: 36px 0;
    }

    .usecase-left {
      flex-direction: row;
      align-items: center;
      gap: 16px;
      flex-wrap: wrap;
    }

    .usecase-left h2 {
      font-size: 20px;
    }

    .usecase-right {
      padding-top: 0;
    }
  }

  @media (max-width: 640px) {
    .usecases-hero {
      padding: 64px 0 26px;
    }

    .usecases-cta {
      padding: 44px 0 64px;
    }
  }
</style>
