/**
 * Products catalog (alg-prd) — industry-led products listing.
 * Detail pages continue to use products-v2.css.
 */

html:has(body.page-template-products_page) {
  scroll-behavior: smooth;
}

  /* ---------- template ---------- */
  .alg-prd {
    --navy: #0e2742; --blue: #3b7ddd; --blue-d: #2a6aa8; --ink: #122a40;
    --muted: #5a6578; --line: #e6edf5; --soft: #f4f8fd; --white: #fff;
    --radius: 22px; --shadow: 0 12px 32px rgb(30 90 150 / .10);
    --shadow-lg: 0 24px 60px rgb(14 39 66 / .16);
    --font: "Manrope", "Plus Jakarta Sans", system-ui, sans-serif;
    font-family: var(--font); color: var(--ink); line-height: 1.6;
    -webkit-font-smoothing: antialiased;
  }
  .alg-prd *, .alg-prd *::before, .alg-prd *::after { box-sizing: border-box; }
  .alg-prd .wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }
  .alg-prd h1, .alg-prd h2, .alg-prd h3 { color: var(--navy); line-height: 1.15; margin: 0; letter-spacing: -.02em; text-wrap: balance; }
  .alg-prd p { margin: 0; }
  .alg-prd a { color: inherit; }
  .alg-prd :focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; border-radius: 8px; }

  /* hero */
  .alg-prd .hero {
    position: relative; overflow: hidden; isolation: isolate;
    padding: clamp(56px, 9vw, 112px) 0 clamp(48px, 7vw, 88px);
    background:
      radial-gradient(60% 80% at 85% 10%, rgb(59 125 221 / .18), transparent 60%),
      radial-gradient(50% 60% at 0% 100%, rgb(14 39 66 / .08), transparent 70%),
      var(--soft);
  }
  .alg-prd .hero::after { /* faint grid */
    content: ""; position: absolute; inset: 0; z-index: -1; opacity: .5;
    background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(70% 70% at 70% 30%, #000, transparent 75%);
  }
  .alg-prd .eyebrow {
    display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
    background: var(--white); border: 1px solid var(--line); color: var(--blue-d);
    font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  }
  .alg-prd .eyebrow::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); box-shadow: 0 0 0 4px rgb(59 125 221 / .2); }
  .alg-prd .hero h1 { margin-top: 20px; font-size: clamp(34px, 5.4vw, 60px); font-weight: 800; max-width: 16ch; }
  .alg-prd .hero h1 em { font-style: normal; background: linear-gradient(90deg, var(--blue), #6aa6f0); -webkit-background-clip: text; background-clip: text; color: transparent; }
  .alg-prd .hero .lede { margin-top: 18px; max-width: 58ch; font-size: clamp(16px, 1.6vw, 19px); color: var(--muted); }
  .alg-prd .hero .actions { margin-top: 30px; display: flex; flex-wrap: wrap; gap: 12px; }

  /* buttons */
  .alg-prd .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
    font: 700 15px/1 var(--font); text-decoration: none; cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease;
  }
  .alg-prd .btn svg { width: 16px; height: 16px; transition: transform .2s ease; }
  .alg-prd .btn:hover svg { transform: translateX(3px); }
  .alg-prd .btn-primary { background: var(--navy); color: var(--white); box-shadow: 0 8px 20px rgb(14 39 66 / .25); }
  .alg-prd .btn-primary:hover { background: #163a60; transform: translateY(-2px); }
  .alg-prd .btn-ghost { background: var(--white); color: var(--navy); border-color: var(--line); }
  .alg-prd .btn-ghost:hover { border-color: var(--blue); color: var(--blue-d); }
  .alg-prd .btn-sm { min-height: 40px; padding: 0 16px; font-size: 14px; }

  /* section heads */
  .alg-prd section.block { padding: clamp(56px, 8vw, 96px) 0 0; }
  .alg-prd .sec-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 16px 32px; margin-bottom: 32px; }
  .alg-prd .sec-head h2 { font-size: clamp(26px, 3.2vw, 36px); font-weight: 800; }
  .alg-prd .sec-head p { color: var(--muted); max-width: 52ch; }
  .alg-prd .kicker { display: block; margin-bottom: 8px; color: var(--blue-d); font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }

  /* product grid */
  .alg-prd .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 24px; }
  .alg-prd .card {
    --accent: var(--blue);
    position: relative; display: flex; flex-direction: column; gap: 18px;
    padding: 28px; border-radius: var(--radius); background: var(--white);
    border: 1px solid var(--line); box-shadow: 0 1px 2px rgb(14 39 66 / .04);
    transition: transform .3s cubic-bezier(.2,.8,.2,1), box-shadow .3s ease, border-color .3s ease;
  }
  .alg-prd .card::before { /* accent bar */
    content: ""; position: absolute; inset: 0 0 auto; height: 4px; border-radius: var(--radius) var(--radius) 0 0;
    background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, white));
    transform: scaleX(0); transform-origin: left; transition: transform .4s ease;
  }
  .alg-prd .card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
  .alg-prd .card:hover::before { transform: scaleX(1); }
  .alg-prd .card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
  .alg-prd .icon {
    display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px;
    color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, white);
  }
  .alg-prd .icon svg { width: 28px; height: 28px; }
  .alg-prd .tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
  .alg-prd .tag { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
  .alg-prd .tag-new { background: #fff6d6; color: #8a6a00; border-color: #f3df94; }
  .alg-prd .card h3 { font-size: 22px; font-weight: 800; }
  .alg-prd .card .sub { margin-top: 4px; color: var(--accent); font-weight: 700; font-size: 14px; }
  .alg-prd .card .desc { color: var(--muted); font-size: 15px; }
  .alg-prd .feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14.5px; }
  .alg-prd .feats li { display: flex; gap: 10px; align-items: flex-start; }
  .alg-prd .feats li::before {
    content: ""; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 50%;
    background: color-mix(in srgb, var(--accent) 14%, white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232a6aa8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12l5 5L20 7'/%3E%3C/svg%3E") center / 11px no-repeat;
  }
  .alg-prd .card-foot { margin-top: auto; padding-top: 18px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 10px; }
  .alg-prd .card-foot .btn { flex: 1 1 auto; }

  /* featured (wide) card for the creative product */
  .alg-prd .card.wide { grid-column: 1 / -1; display: grid; grid-template-columns: 1.1fr 1fr; gap: 32px; align-items: center; padding: clamp(24px, 4vw, 40px); overflow: hidden; }
  .alg-prd .card.wide .alg-prd-card-body { display: flex; flex-direction: column; gap: 18px; }
  .alg-prd .card.wide .card-foot { border-top: 0; padding-top: 6px; }
  .alg-prd .canvas-art {
    position: relative; aspect-ratio: 4 / 3; border-radius: 18px; overflow: hidden;
    background: #fffaf3; border: 1px solid #f2e6d6;
  }
  .alg-prd .canvas-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
  .alg-prd .canvas-art .stroke { stroke-dasharray: 900; stroke-dashoffset: 900; animation: alg-draw 2.6s .3s cubic-bezier(.6,.1,.3,1) forwards; }
  .alg-prd .canvas-art .stroke:nth-of-type(2) { animation-delay: .9s; }
  .alg-prd .canvas-art .stroke:nth-of-type(3) { animation-delay: 1.5s; }
  .alg-prd .swatches { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: rgb(255 255 255 / .9); box-shadow: var(--shadow); }
  .alg-prd .swatches i { width: 18px; height: 18px; border-radius: 50%; display: block; }
  @keyframes alg-draw { to { stroke-dashoffset: 0; } }
  @media (max-width: 820px) { .alg-prd .card.wide { grid-template-columns: 1fr; } .alg-prd .canvas-art { order: -1; } }

  /* open-source cross-link */
  .alg-prd .xlink {
    margin-top: clamp(56px, 8vw, 96px);
    display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px 28px;
    padding: clamp(24px, 4vw, 36px); border-radius: var(--radius);
    background: var(--navy); color: #c9d6e6; position: relative; overflow: hidden;
  }
  .alg-prd .xlink::after { content: ""; position: absolute; width: 360px; height: 360px; right: -120px; top: -180px; border-radius: 50%; background: radial-gradient(circle, rgb(59 125 221 / .45), transparent 70%); }
  .alg-prd .xlink .code { font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; color: #8fd0a8; background: rgb(255 255 255 / .06); border: 1px solid rgb(255 255 255 / .12); padding: 14px 16px; border-radius: 12px; white-space: nowrap; }
  .alg-prd .xlink h2 { color: var(--white); font-size: clamp(20px, 2.4vw, 26px); }
  .alg-prd .xlink p { margin-top: 6px; }
  .alg-prd .xlink .btn { position: relative; z-index: 1; background: var(--white); color: var(--navy); }
  .alg-prd .xlink .btn:hover { transform: translateY(-2px); }
  @media (max-width: 760px) { .alg-prd .xlink { grid-template-columns: 1fr; } .alg-prd .xlink .code { justify-self: start; } }

  /* closing CTA */
  .alg-prd .cta { padding: clamp(56px, 8vw, 96px) 0; }
  .alg-prd .cta-box {
    text-align: center; padding: clamp(36px, 6vw, 64px) 20px; border-radius: 28px;
    background: linear-gradient(135deg, var(--soft), #e9f2fd); border: 1px solid var(--line);
  }
  .alg-prd .cta-box h2 { font-size: clamp(26px, 3.4vw, 38px); font-weight: 800; }
  .alg-prd .cta-box p { margin: 12px auto 26px; max-width: 52ch; color: var(--muted); }

  /* entrance — scoped class avoids theme .reveal / .is-visible conflict */
  @media (prefers-reduced-motion: no-preference) {
    .alg-prd .alg-prd-reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s ease, transform .6s cubic-bezier(.2,.8,.2,1); }
    .alg-prd .alg-prd-reveal.in { opacity: 1; transform: none; }
  }
  @media (prefers-reduced-motion: reduce) {
    .alg-prd *, .alg-prd *::before { transition: none !important; animation: none !important; }
    .alg-prd .canvas-art .stroke { stroke-dashoffset: 0; }
  }
