/* ==========================================================================
   WIZKET — ai.css · AI Automation page, "One becomes a thousand" scene
   Reuses the shared scene kit from website.css (ws-stage, hero, HUD, step copy).
   js/ai.js builds the hero with ghost cursors, scrubs the human task, draws the
   swarm on a canvas and runs the autopilot ending.
   The app window is a screen (dark in both themes); the stage follows the theme.
   Prefix: ai-
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Hero extras
   -------------------------------------------------------------------------- */
html.js .ai-after { opacity: 0; transform: translateY(12px); transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out); }
html.js .ws-hero.is-in .ai-after { opacity: 1; transform: none; }
html.js .ws-hero.is-in .ai-after:last-child { transition-delay: 0.12s; }
.ws-hero__big .ai-ch { display: inline-block; will-change: transform; }
.ai .ws-hero__big { z-index: 3; }   /* the letters are carried by cursors: keep them above everything */
.cta.is-ghost { background-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 6px var(--accent-soft); }

/* the swarm canvas (Clone): fades out under the copy column */
.ai-swarm {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.18) 30%, #000 52%);
  mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0.18) 30%, #000 52%);
}

/* --------------------------------------------------------------------------
   2. The window (logical 640 × 400, scaled by ai.js)
   -------------------------------------------------------------------------- */
.ai-rig {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 50%;
  width: 640px;
  height: 400px;
  margin: -200px 0 0 -320px;
  pointer-events: none;
  will-change: transform;
}
.ai-win {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  overflow: hidden;
  background: #0f1417;
  border: 1px solid rgba(255, 255, 255, 0.09);
  box-shadow: 0 50px 100px -40px rgba(0, 0, 0, 0.75), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  color: #dfe6ea;
  font-family: var(--font-body);
}
.ai-win p { margin: 0; }
.ai-win__bar { display: flex; align-items: center; gap: 7px; height: 40px; padding: 0 16px; flex-shrink: 0; background: #151c20; border-bottom: 1px solid rgba(255, 255, 255, 0.06); }
.ai-win__bar i { width: 10px; height: 10px; border-radius: 50%; background: #ff5f57; }
.ai-win__bar i:nth-child(2) { background: #febc2e; }
.ai-win__bar i:nth-child(3) { background: #28c840; }
.ai-win__bar span { margin-left: 12px; font: 600 13px/1 var(--font-body); color: #9aa6ad; }
.ai-win__timer { margin-left: auto; padding: 5px 9px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); font: 600 12px/1 ui-monospace, Consolas, monospace; color: #fff; }
.ai-win__body { position: relative; flex: 1; display: grid; grid-template-columns: 42% 1fr; min-height: 0; }

.ai-inbox { position: relative; padding: 14px 12px; border-right: 1px solid rgba(255, 255, 255, 0.06); background: #121a1e; }
.ai-inbox__h, .ai-crm__h { margin-bottom: 10px !important; font: 700 11px/1 var(--font-body); letter-spacing: 0.18em; text-transform: uppercase; color: #6c7a82; }
.ai-mail { display: grid; gap: 4px; margin-bottom: 7px; padding: 10px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font: 500 12px/1.2 var(--font-body); color: #9aa6ad; transition: background-color 0.3s; }
.ai-mail b { font-weight: 700; color: #e6ecef; }
.ai-mail.is-new { box-shadow: inset 3px 0 0 #5fb3c4; }
.ai-mail.is-open { background: rgba(95, 179, 196, 0.16); }
.ai-read {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #1a2329;
  border: 1px solid rgba(255, 255, 255, 0.07);
  font: 500 13px/1.45 var(--font-body);
  color: #c8d1d6;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s var(--ease-out), transform 0.4s var(--ease-out);
}
.ai-win.is-read .ai-read { opacity: 1; transform: none; }
.ai-read u { text-decoration: none; color: #fff; font-weight: 700; }
.ai-read mark { padding: 0 2px; border-radius: 3px; background: transparent; color: #fff; font-weight: 700; transition: background-color 0.2s; }
.ai-read mark.is-sel { background: #2f6bff; }

.ai-crm { display: grid; align-content: start; gap: 9px; padding: 14px 16px; }
.ai-f { display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 10px; font: 600 11.5px/1 var(--font-body); color: #7d8a91; }
.ai-f > i {
  display: flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font: 500 13px/1.3 var(--font-body);
  font-style: normal;
  color: #fff;
  white-space: pre-wrap;
}
.ai-f > i.is-focus { border-color: #5fb3c4; box-shadow: 0 0 0 3px rgba(95, 179, 196, 0.18); }
.ai-f--tall { align-items: start; }
.ai-f--tall > i { min-height: 74px; align-items: flex-start; padding-top: 9px; }
.ai-chips { display: flex; gap: 6px; }
.ai-chips em { padding: 8px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); font: 600 11.5px/1 var(--font-body); font-style: normal; color: #9aa6ad; transition: background-color 0.25s, color 0.25s; }
.ai-chips em.is-on { background: #5fb3c4; color: #0f1417; }
.ai-save { justify-self: end; margin-top: 2px; padding: 10px 20px; border-radius: 999px; background: #e6ecef; color: #0f1417; font: 700 13px/1 var(--font-body); transition: background-color 0.25s, transform 0.2s; }
.ai-save.is-done { background: #2ecc71; color: #fff; }

/* the human's path, drawn after the task */
.ai-path { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.ai-path path { fill: none; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
/* the recorded path: a march of glowing dots over a faint dashed rail, like data flowing (revealed by the mask path) */
.ai-path [data-ai-path] {
  stroke: var(--accent); stroke-width: 3.4; stroke-dasharray: 0.1 9;
  filter: drop-shadow(0 0 3px rgba(253, 95, 7, 0.9));
  animation: ai-march 0.9s linear infinite;
}
@keyframes ai-march { to { stroke-dashoffset: -9.1; } }
.ai-path__rail { stroke: rgba(253, 95, 7, 0.22); stroke-width: 1; stroke-dasharray: 2 5; opacity: 0; }
.ai-path [data-ai-path-mask] { stroke: #fff; stroke-width: 40; stroke-dasharray: 1; stroke-dashoffset: 1; vector-effect: none; }
/* click points: little target rings */
.ai-path circle { fill: var(--bg); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; opacity: 0; filter: drop-shadow(0 0 4px rgba(253, 95, 7, 0.8)); }
@media (prefers-reduced-motion: reduce) { .ai-path [data-ai-path] { animation: none; } }

.ai-win .gc--human { z-index: 3; width: 22px; height: 22px; }
.ai-card-tag {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 23, 0.72);
  font: 400 64px/1 var(--font-display) !important;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0;
}

/* the recipe strip under the window */
.ai-recipe {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 18px);
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ai;
}
.ai-recipe li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line2);
  font: 600 14px/1 var(--font-body);
  color: var(--text);
  opacity: 0;
  counter-increment: ai;
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}
.ai-recipe li::before { content: counter(ai); font: 400 12px/1 var(--font-display); color: var(--muted); }
.ai-recipe li.is-on { border-color: var(--accent); }
.ai-recipe li.is-on::before { color: var(--accent); }

/* --------------------------------------------------------------------------
   3. Clone counter
   -------------------------------------------------------------------------- */
.ai-count {
  position: absolute;
  z-index: 4;
  right: clamp(60px, 7vw, 120px);
  bottom: clamp(26px, 5vh, 50px);
  display: grid;
  justify-items: end;
  gap: 6px;
  padding: 16px 20px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line2);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.ai-count p { margin: 0; display: flex; align-items: baseline; gap: 12px; }
.ai-count em { font: 600 11px/1 var(--font-body); font-style: normal; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }
.ai-count b { min-width: 5ch; text-align: right; font: 400 clamp(28px, 3vw, 42px)/1 var(--font-display); color: var(--text); font-variant-numeric: tabular-nums; }
.ai-count p:first-child b { color: var(--accent); }
.ai-count small { font: 500 10.5px/1.3 var(--font-body); color: var(--muted); }

/* --------------------------------------------------------------------------
   4. Autopilot: badge, orbit, coffee
   -------------------------------------------------------------------------- */
.ai-badge {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 230px;
  height: 230px;
  margin: -115px 0 0 -115px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.ai-badge__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), rgba(253, 95, 7, 0.1), var(--accent));
  -webkit-mask: radial-gradient(circle, transparent 104px, #000 106px);
  mask: radial-gradient(circle, transparent 104px, #000 106px);
  animation: ai-spin 6s linear infinite;
  filter: drop-shadow(0 0 18px rgba(253, 95, 7, 0.6));
}
.ai-badge__core {
  position: absolute;
  inset: 18px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, #2a3338, #11171a 75%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.08), 0 30px 60px -20px rgba(0, 0, 0, 0.7), 0 0 60px rgba(253, 95, 7, 0.25);
  color: #fff;
  text-align: center;
}
.ai-badge__core b { font: 400 34px/1 var(--font-display); letter-spacing: 0.03em; text-transform: uppercase; }
.ai-badge__core em { font: 700 12px/1 var(--font-body); font-style: normal; letter-spacing: 0.24em; text-transform: uppercase; color: #2ecc71; }
.ai-orbit { position: absolute; inset: -46px; }
.ai-orbit i {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line2);
  font: 600 12px/1 var(--font-body);
  font-style: normal;
  color: var(--text);
  white-space: nowrap;
  translate: -50% -50%;
}
.ai-orbit i:nth-child(1) { transform: translate(0, -160px); }
.ai-orbit i:nth-child(2) { transform: translate(190px, -30px); }
.ai-orbit i:nth-child(3) { transform: translate(0, 160px); }
.ai-orbit i:nth-child(4) { transform: translate(-190px, 30px); }
.ai-orbit i { animation: ai-bob 3.2s ease-in-out infinite alternate; }
.ai-orbit i:nth-child(2) { animation-delay: -0.8s; }
.ai-orbit i:nth-child(3) { animation-delay: -1.6s; }
.ai-orbit i:nth-child(4) { animation-delay: -2.4s; }
@keyframes ai-bob { to { translate: -50% calc(-50% - 8px); } }
@keyframes ai-spin { to { rotate: 360deg; } }

/* coffee cup (CSS only) */
.ai-cup {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 40px;
  margin: -20px 0 0 -23px;
  border-radius: 4px 4px 14px 14px;
  background: linear-gradient(180deg, #f2f1ed, #cfd3d6);
  box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
}
.ai-cup::after { content: ""; position: absolute; right: -14px; top: 8px; width: 14px; height: 18px; border: 4px solid #cfd3d6; border-left: 0; border-radius: 0 10px 10px 0; }
.ai-cup::before { content: ""; position: absolute; left: 5px; right: 5px; top: 4px; height: 6px; border-radius: 3px; background: #6b4a35; }
.ai-cup i { position: absolute; bottom: 100%; width: 4px; height: 18px; border-radius: 4px; background: var(--muted); opacity: 0; }
.ai-cup i:nth-child(1) { left: 10px; }
.ai-cup i:nth-child(2) { left: 20px; }
.ai-cup i:nth-child(3) { left: 30px; }
.ai-cup.is-hot i { animation: ai-steam 1.8s ease-in-out infinite; }
.ai-cup.is-hot i:nth-child(2) { animation-delay: 0.4s; }
.ai-cup.is-hot i:nth-child(3) { animation-delay: 0.8s; }
@keyframes ai-steam { 0% { transform: translateY(6px) scaleY(0.5); opacity: 0; } 40% { opacity: 0.7; } 100% { transform: translateY(-16px) scaleY(1); opacity: 0; } }
.ai-hand2 { z-index: 4; left: 50%; top: 50%; opacity: 0; visibility: hidden; }

/* --------------------------------------------------------------------------
   5. Small screens
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .ai-swarm { -webkit-mask-image: linear-gradient(180deg, #000 55%, rgba(0, 0, 0, 0.15) 75%); mask-image: linear-gradient(180deg, #000 55%, rgba(0, 0, 0, 0.15) 75%); }
  .ai-count { right: auto; left: 50%; bottom: auto; top: calc(var(--nav-top) + var(--nav-h) + 10px); translate: -50% 0; padding: 10px 14px; grid-auto-flow: column; gap: 14px; justify-items: center; }
  .ai-count small { display: none; }
  .ai-count p { flex-direction: column; align-items: center; gap: 4px; }
  .ai-count em { font-size: 9.5px; letter-spacing: 0.12em; white-space: nowrap; }
  .ai-count b { font-size: 26px; min-width: 0; text-align: center; }
}
