---
/**
 * Animated Image Pipeline diagram.
 * Shows: Upload (S3) → Queue (images) → Worker (2x2 variant grid) → Upload CDN
 * Worker contains a 2x2 grid of image variants that fill in sequentially.
 */
---

<div class="ip-wrap">
  <!-- Desktop horizontal layout -->
  <div class="ip-flow">
    <!-- Node 1: Upload S3 -->
    <div class="ip-node ip-n1">
      <div class="ip-icon">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
          <polyline points="17 8 12 3 7 8"/>
          <line x1="12" y1="3" x2="12" y2="15"/>
        </svg>
      </div>
      <span class="ip-label">Upload</span>
      <span class="ip-sublabel">S3</span>
    </div>

    <!-- Connector 1 -->
    <div class="ip-conn">
      <div class="ip-line"></div>
      <div class="ip-arrow"></div>
      <div class="ip-dot ip-d1"></div>
    </div>

    <!-- Node 2: Queue -->
    <div class="ip-node ip-n2">
      <div class="ip-icon">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/>
          <line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>
        </svg>
      </div>
      <span class="ip-label">Queue</span>
      <span class="ip-sublabel">images</span>
    </div>

    <!-- Connector 2 -->
    <div class="ip-conn">
      <div class="ip-line"></div>
      <div class="ip-arrow"></div>
      <div class="ip-dot ip-d2"></div>
    </div>

    <!-- Node 3: Worker (hero, wider) -->
    <div class="ip-node ip-n3 ip-hero">
      <div class="ip-glow"></div>
      <div class="ip-icon ip-icon-active">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
          <circle cx="8.5" cy="8.5" r="1.5"/>
          <polyline points="21 15 16 10 5 21"/>
        </svg>
      </div>
      <span class="ip-label">Worker</span>
      <!-- 2x2 variant grid -->
      <div class="ip-grid">
        <div class="ip-variant ip-var-1">
          <div class="ip-var-fill ip-fill-purple"></div>
          <span class="ip-var-label">thumb</span>
          <span class="ip-var-size">150px</span>
        </div>
        <div class="ip-variant ip-var-2">
          <div class="ip-var-fill ip-fill-cyan"></div>
          <span class="ip-var-label">card</span>
          <span class="ip-var-size">400px</span>
        </div>
        <div class="ip-variant ip-var-3">
          <div class="ip-var-fill ip-fill-green"></div>
          <span class="ip-var-label">full</span>
          <span class="ip-var-size">1200px</span>
        </div>
        <div class="ip-variant ip-var-4">
          <div class="ip-var-fill ip-fill-orange"></div>
          <span class="ip-var-label">og</span>
          <span class="ip-var-size">1200px</span>
        </div>
      </div>
    </div>

    <!-- Connector 3 -->
    <div class="ip-conn">
      <div class="ip-line"></div>
      <div class="ip-arrow"></div>
      <div class="ip-dot ip-d3"></div>
    </div>

    <!-- Node 4: Upload CDN -->
    <div class="ip-node ip-n4">
      <div class="ip-icon ip-icon-green">
        <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/>
          <path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>
        </svg>
      </div>
      <span class="ip-label">Upload</span>
      <span class="ip-sublabel">CDN</span>
    </div>
  </div>

  <!-- Mobile vertical layout -->
  <div class="ip-vertical">
    <div class="ip-vrow">
      <div class="ip-vicon">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
          <polyline points="17 8 12 3 7 8"/><line x1="12" y1="3" x2="12" y2="15"/>
        </svg>
      </div>
      <div><span class="ip-vlabel">Upload</span><span class="ip-vsub">S3 origin</span></div>
    </div>
    <div class="ip-vconn"><div class="ip-vline"></div><div class="ip-vdot ip-vd1"></div></div>

    <div class="ip-vrow">
      <div class="ip-vicon">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <line x1="8" y1="6" x2="21" y2="6"/><line x1="8" y1="12" x2="21" y2="12"/><line x1="8" y1="18" x2="21" y2="18"/>
          <line x1="3" y1="6" x2="3.01" y2="6"/><line x1="3" y1="12" x2="3.01" y2="12"/><line x1="3" y1="18" x2="3.01" y2="18"/>
        </svg>
      </div>
      <div><span class="ip-vlabel">Queue</span><span class="ip-vsub">images</span></div>
    </div>
    <div class="ip-vconn"><div class="ip-vline"></div><div class="ip-vdot ip-vd2"></div></div>

    <div class="ip-vrow ip-vhero">
      <div class="ip-vicon ip-vicon-pink">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <rect x="3" y="3" width="18" height="18" rx="2" ry="2"/>
          <circle cx="8.5" cy="8.5" r="1.5"/>
          <polyline points="21 15 16 10 5 21"/>
        </svg>
      </div>
      <div class="ip-vworker-info">
        <span class="ip-vlabel">Worker</span>
        <div class="ip-vgrid">
          <span class="ip-vtag ip-vtag-purple">thumb 150px</span>
          <span class="ip-vtag ip-vtag-cyan">card 400px</span>
          <span class="ip-vtag ip-vtag-green">full 1200px</span>
          <span class="ip-vtag ip-vtag-orange">og 1200px</span>
        </div>
      </div>
    </div>
    <div class="ip-vconn"><div class="ip-vline"></div><div class="ip-vdot ip-vd3"></div></div>

    <div class="ip-vrow">
      <div class="ip-vicon ip-vicon-green">
        <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <polyline points="22 12 16 12 14 15 10 15 8 12 2 12"/>
          <path d="M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z"/>
        </svg>
      </div>
      <div><span class="ip-vlabel">Upload CDN</span><span class="ip-vsub">All variants</span></div>
    </div>
  </div>
</div>

<style>
  .ip-wrap {
    margin: 1.5rem 0;
    padding: 2rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--sl-color-hairline);
    background: var(--sl-color-bg-sidebar);
    overflow-x: auto;
  }

  :root[data-theme='dark'] .ip-wrap {
    background: rgba(12, 12, 15, 0.8);
    border-color: rgba(255, 255, 255, 0.06);
  }

  .ip-vertical { display: none; }

  /* === Horizontal (desktop) === */
  .ip-flow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    min-width: 680px;
  }

  /* Nodes */
  .ip-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    position: relative;
    animation: ipAppear 0.5s ease-out both;
  }

  .ip-n1 { animation-delay: 0s; }
  .ip-n2 { animation-delay: 0.12s; }
  .ip-n3 { animation-delay: 0.24s; }
  .ip-n4 { animation-delay: 0.48s; }

  @keyframes ipAppear {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .ip-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--sl-color-hairline);
    background: var(--sl-color-bg);
    color: var(--sl-color-gray-3);
    transition: all 0.3s ease;
  }

  :root[data-theme='dark'] .ip-icon {
    background: rgba(17, 17, 22, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .ip-icon-active {
    border-color: #ec4899;
    color: #ec4899;
    animation: ipIconPulse 2.5s ease-in-out infinite;
  }

  :root[data-theme='dark'] .ip-icon-active {
    border-color: #f9a8d4;
    color: #f9a8d4;
  }

  @keyframes ipIconPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(236, 72, 153, 0.15); }
    50% { box-shadow: 0 0 20px rgba(236, 72, 153, 0.35); }
  }

  .ip-icon-green {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
  }

  :root[data-theme='dark'] .ip-icon-green {
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.3);
  }

  /* Hero glow */
  .ip-hero { position: relative; }

  .ip-glow {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 18px;
    background: radial-gradient(ellipse, rgba(236, 72, 153, 0.12) 0%, transparent 70%);
    animation: ipGlow 3s ease-in-out infinite;
    pointer-events: none;
  }

  :root[data-theme='dark'] .ip-glow {
    background: radial-gradient(ellipse, rgba(249, 168, 212, 0.1) 0%, transparent 70%);
  }

  @keyframes ipGlow {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.08); }
  }

  .ip-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sl-color-text);
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
  }

  .ip-sublabel {
    font-size: 0.65rem;
    color: var(--sl-color-gray-3);
    text-align: center;
  }

  /* 2x2 variant grid */
  .ip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    margin-top: 0.2rem;
    width: 160px;
  }

  .ip-variant {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 4px 2px;
    border-radius: 6px;
    border: 1px solid var(--sl-color-hairline);
    background: var(--sl-color-bg);
    position: relative;
    overflow: hidden;
  }

  :root[data-theme='dark'] .ip-variant {
    background: rgba(17, 17, 22, 0.7);
    border-color: rgba(255, 255, 255, 0.06);
  }

  .ip-var-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    opacity: 0.12;
    border-radius: 5px;
  }

  .ip-fill-purple {
    background: #a855f7;
    animation: ipVarFill 3.5s ease-in-out infinite 0s;
  }

  .ip-fill-cyan {
    background: #06b6d4;
    animation: ipVarFill 3.5s ease-in-out infinite 0.6s;
  }

  .ip-fill-green {
    background: #22c55e;
    animation: ipVarFill 3.5s ease-in-out infinite 1.2s;
  }

  .ip-fill-orange {
    background: #f59e0b;
    animation: ipVarFill 3.5s ease-in-out infinite 1.8s;
  }

  :root[data-theme='dark'] .ip-var-fill {
    opacity: 0.18;
  }

  @keyframes ipVarFill {
    0%, 5% { width: 0%; }
    25%, 70% { width: 100%; }
    90%, 100% { width: 0%; }
  }

  .ip-var-label {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--sl-color-text);
    position: relative;
    z-index: 1;
  }

  .ip-var-size {
    font-size: 0.5rem;
    color: var(--sl-color-gray-3);
    font-family: var(--sl-font-mono);
    position: relative;
    z-index: 1;
  }

  .ip-var-1 .ip-var-label { color: #a855f7; }
  .ip-var-2 .ip-var-label { color: #06b6d4; }
  .ip-var-3 .ip-var-label { color: #22c55e; }
  .ip-var-4 .ip-var-label { color: #f59e0b; }

  :root[data-theme='dark'] .ip-var-1 .ip-var-label { color: #c084fc; }
  :root[data-theme='dark'] .ip-var-2 .ip-var-label { color: #22d3ee; }
  :root[data-theme='dark'] .ip-var-3 .ip-var-label { color: #4ade80; }
  :root[data-theme='dark'] .ip-var-4 .ip-var-label { color: #fbbf24; }

  /* Connectors */
  .ip-conn {
    position: relative;
    width: 48px;
    height: 46px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
  }

  .ip-line {
    width: 100%;
    height: 2px;
    background: var(--sl-color-hairline);
  }

  :root[data-theme='dark'] .ip-line {
    background: rgba(255, 255, 255, 0.1);
  }

  .ip-arrow {
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 7px solid var(--sl-color-hairline);
  }

  :root[data-theme='dark'] .ip-arrow {
    border-left-color: rgba(255, 255, 255, 0.1);
  }

  /* Animated dots */
  .ip-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ec4899;
    top: 50%;
    transform: translateY(-50%);
    left: -3px;
    box-shadow: 0 0 8px rgba(236, 72, 153, 0.5);
    animation: ipDotTravel 3.5s ease-in-out infinite;
  }

  :root[data-theme='dark'] .ip-dot {
    background: #f9a8d4;
    box-shadow: 0 0 10px rgba(249, 168, 212, 0.6);
  }

  .ip-d1 { animation-delay: 0s; }
  .ip-d2 { animation-delay: 0.7s; }
  .ip-d3 { animation-delay: 1.4s; }

  @keyframes ipDotTravel {
    0% { left: -3px; opacity: 0; }
    8% { opacity: 1; }
    85% { opacity: 1; }
    100% { left: calc(100% - 3px); opacity: 0; }
  }

  /* === Mobile vertical layout === */
  .ip-vrow {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
  }

  .ip-vhero {
    padding: 0.6rem 0.75rem;
    border-radius: 10px;
    background: rgba(236, 72, 153, 0.04);
    border: 1px solid rgba(236, 72, 153, 0.1);
  }

  :root[data-theme='dark'] .ip-vhero {
    background: rgba(249, 168, 212, 0.04);
    border-color: rgba(249, 168, 212, 0.1);
  }

  .ip-vicon {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--sl-color-hairline);
    background: var(--sl-color-bg);
    color: var(--sl-color-gray-3);
  }

  :root[data-theme='dark'] .ip-vicon {
    background: rgba(17, 17, 22, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
  }

  .ip-vicon-pink { color: #ec4899; border-color: #ec4899; }
  :root[data-theme='dark'] .ip-vicon-pink { color: #f9a8d4; border-color: rgba(249, 168, 212, 0.4); }
  .ip-vicon-green { color: #22c55e; border-color: rgba(34, 197, 94, 0.3); }
  :root[data-theme='dark'] .ip-vicon-green { color: #4ade80; border-color: rgba(74, 222, 128, 0.3); }

  .ip-vlabel {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--sl-color-text);
    display: block;
  }

  .ip-vsub {
    font-size: 0.72rem;
    color: var(--sl-color-gray-3);
    display: block;
  }

  .ip-vworker-info {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
  }

  .ip-vgrid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .ip-vtag {
    font-size: 0.6rem;
    font-weight: 600;
    padding: 0.12rem 0.35rem;
    border-radius: 4px;
  }

  .ip-vtag-purple { background: rgba(168, 85, 247, 0.1); color: #a855f7; }
  .ip-vtag-cyan { background: rgba(6, 182, 212, 0.1); color: #06b6d4; }
  .ip-vtag-green { background: rgba(34, 197, 94, 0.1); color: #22c55e; }
  .ip-vtag-orange { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }

  :root[data-theme='dark'] .ip-vtag-purple { background: rgba(192, 132, 252, 0.1); color: #c084fc; }
  :root[data-theme='dark'] .ip-vtag-cyan { background: rgba(34, 211, 238, 0.1); color: #22d3ee; }
  :root[data-theme='dark'] .ip-vtag-green { background: rgba(74, 222, 128, 0.1); color: #4ade80; }
  :root[data-theme='dark'] .ip-vtag-orange { background: rgba(251, 191, 36, 0.1); color: #fbbf24; }

  .ip-vconn {
    position: relative;
    height: 24px;
    width: 38px;
    display: flex;
    justify-content: center;
  }

  .ip-vline {
    width: 2px;
    height: 100%;
    background: var(--sl-color-hairline);
  }

  :root[data-theme='dark'] .ip-vline {
    background: rgba(255, 255, 255, 0.1);
  }

  .ip-vdot {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ec4899;
    left: 50%;
    transform: translateX(-50%);
    top: -3px;
    box-shadow: 0 0 6px rgba(236, 72, 153, 0.4);
    animation: ipVdot 3.5s ease-in-out infinite;
  }

  :root[data-theme='dark'] .ip-vdot {
    background: #f9a8d4;
    box-shadow: 0 0 8px rgba(249, 168, 212, 0.5);
  }

  .ip-vd1 { animation-delay: 0s; }
  .ip-vd2 { animation-delay: 0.7s; }
  .ip-vd3 { animation-delay: 1.4s; }

  @keyframes ipVdot {
    0% { top: -3px; opacity: 0; }
    8% { opacity: 1; }
    85% { opacity: 1; }
    100% { top: calc(100% - 3px); opacity: 0; }
  }

  /* Responsive */
  @media (max-width: 700px) {
    .ip-flow { display: none; }
    .ip-vertical { display: flex; flex-direction: column; }
    .ip-wrap { padding: 1.25rem 1rem; }
  }
</style>
