/* ═══ Agents on the work grid ══════════════════════════════════════════════
   Homepage isometric plane (#wipStage / #wipIso). AI agents ride the one-cell
   gutters between screens, come in and leave through the grid's fade, select a
   screen, say what they're doing and ask for review. Ben's green cursor comes in
   off the rails and approves it, and the screen changes. Layers are built by
   components/iso-agents.js, desktop with a fine pointer only.
   Prototype: explorations/iso-agents.html (03 Review loop). */
.wip-stage {
  --ag-ink: #0E0D0B;
  --ag-on-ink: #FFFFFF;
  --ag-paper: #FFFFFF;
  --ag-ok: var(--accent-green, #1B8E45);
  --ag-top: #5A5650;                /* agent block: lit top, two side tones, visor */
  --ag-side: #35322E;
  --ag-side-2: #1B1A18;
  --ag-visor: #F4F2EE;
}
[data-theme="dark"] .wip-stage {
  --ag-ink: #F4F2EE;
  --ag-on-ink: #0E0D0B;
  --ag-paper: #181716;
  --ag-top: #FFFFFF;
  --ag-side: #DEDBD5;
  --ag-side-2: #C8C4BD;
  --ag-visor: #0E0D0B;
}
.wip-stage.ag-off .ag-plane, .wip-stage.ag-off .ag-screen { display: none; }

/* In-plane layers share the grid's box (-7…25 × -6…21 cells), so the grid's own radial mask fades them */
.ag-plane {
  position: absolute; left: calc(var(--cell) * -7); top: calc(var(--cell) * -6);
  width: calc(var(--cell) * 32); height: calc(var(--cell) * 27);
  overflow: visible; pointer-events: none;
}
.ag-plane--under {
  transform: translateZ(1px);
  -webkit-mask-image: radial-gradient(closest-side, #000 50%, transparent 100%);
          mask-image: radial-gradient(closest-side, #000 50%, transparent 100%);
}
.ag-plane--over { transform: translateZ(6px); }
.ag-trail { fill: none; stroke: var(--ag-ink); stroke-width: .032; stroke-linejoin: round; opacity: .14; }
.ag-ahead { fill: none; stroke: var(--ag-ink); stroke-width: .036; stroke-linecap: round; stroke-dasharray: .001 .3; opacity: .16; }
.ag-sel { transition: opacity .9s ease; }
.ag-sel.is-fading { opacity: 0; }
.ag-frame { fill: none; stroke: var(--ag-ink); stroke-width: .032; transition: stroke .5s ease; }
.ag-handle { fill: var(--ag-paper); stroke: var(--ag-ink); stroke-width: .024; opacity: 0; transition: opacity .35s ease, stroke .5s ease; }
.ag-sel.has-handles .ag-handle { opacity: 1; }
.ag-sel.is-ok .ag-frame, .ag-sel.is-ok .ag-handle { stroke: var(--ag-ok); }
.ag-ripple { fill: none; stroke: var(--ag-ok); stroke-width: .04; transform-box: fill-box; transform-origin: center; animation: agRipple .8s cubic-bezier(.2,.8,.2,1) forwards; }
@keyframes agRipple { from { transform: scale(.15); opacity: .9; } to { transform: scale(1); opacity: 0; } }

/* Work in progress on a screen: a soft band of light passes over it */
.wip-tile .ag-scan {
  position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .6s ease;
  background: linear-gradient(180deg, transparent 38%, rgba(255,255,255,.34) 50%, transparent 62%) 0 100% / 100% 300% no-repeat;
}
.wip-tile.ag-scanning .ag-scan { opacity: 1; animation: agScan 2.6s cubic-bezier(.45,0,.55,1) infinite; }
@keyframes agScan { from { background-position: 0 100%; } to { background-position: 0 0; } }
/* While you carry a block, the free screen under it lights up as somewhere to drop it */
.wip-tile.ag-drop .ag-scan { opacity: 1; animation: none; transition: none; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 4px var(--ag-ok); }
.wip-tile img.ag-swap { z-index: 2; opacity: 0; transition: opacity 1.4s ease; }
.wip-tile img.ag-swap.is-in { opacity: 1; }

/* Upright layer: cursors stand up off the plane, placed from its projection. It sits under the
   stage fog (.wip-stage::after, z-index 2), so cursors come in through the same fade as the grid. */
.ag-screen { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.ag-cur { position: absolute; left: 0; top: 0; opacity: 0; will-change: transform, opacity; }
.ag-arrow { position: absolute; left: -2px; top: -2px; width: 18px; height: 18px; overflow: visible; filter: drop-shadow(0 1px 1.5px rgba(14,13,11,.22)); transform-origin: 2px 2px; }
.ag-arrow path { fill: var(--ag-ink); stroke: var(--ag-paper); stroke-width: 1.4; stroke-linejoin: round; }
.ag-tag {
  position: absolute; left: 13px; top: 17px; display: flex; align-items: center;
  padding: 6px 10px 6px 8px; border-radius: 999px; background: var(--ag-ink); color: var(--ag-on-ink);
  font: 500 12px/1 var(--sans, 'Satoshi', -apple-system, BlinkMacSystemFont, sans-serif); letter-spacing: 0; white-space: nowrap;
  box-shadow: 0 4px 12px -4px rgba(14,13,11,.3);
  /* Hidden while an agent travels; it pops out of the cursor as the agent nears its screen */
  opacity: 0; transform: translate(-4px, -4px) scale(.88); transform-origin: 0 0;
  transition: opacity .3s ease, transform .5s cubic-bezier(.2,.8,.2,1);
}
.ag-cur.is-labelled .ag-tag, .ag-cur--ben .ag-tag { opacity: 1; transform: none; }
.ag-status { width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; opacity: .5; transition: background .4s ease, opacity .4s ease; }
.ag-cur.is-working .ag-status { opacity: 1; animation: agPulse 1.2s ease-in-out infinite; }
.ag-cur.is-approved .ag-status { background: #7BE3A0; opacity: 1; animation: none; }
@keyframes agPulse { 50% { opacity: .3; } }
.ag-task { display: block; width: 0; overflow: hidden; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.ag-task > span { display: inline-block; white-space: nowrap; opacity: .7; transition: opacity .16s ease; }
.ag-task > span::before { content: ""; display: inline-block; width: 1px; height: 10px; margin: 0 8px; vertical-align: -1px; background: var(--ag-on-ink); opacity: .4; }
/* "Thinking": a highlight sweeps through the text while the agent sizes up the screen */
.ag-task > span.is-thinking {
  opacity: 1; color: transparent;
  background-image: linear-gradient(100deg, color-mix(in srgb, var(--ag-on-ink) 40%, transparent) 35%, var(--ag-on-ink) 50%, color-mix(in srgb, var(--ag-on-ink) 40%, transparent) 65%);
  background-size: 250% 100%; -webkit-background-clip: text; background-clip: text;
  animation: agThink 1.6s linear infinite;
}
@keyframes agThink { from { background-position: 100% 0; } to { background-position: 0 0; } }
/* Agent block: a 14px cube in the plane's own isometric angle, standing on its ground point.
   iso-agents.js moves .ag-bot-body (lift, heading + spin, somersault) and scales the shadow. */
.ag-bot-iso { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transform: rotateX(55deg) rotateZ(-45deg); }
.ag-bot-shadow { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 5px; background: rgba(14,13,11,.3); filter: blur(2.5px); }
.ag-bot-body { position: absolute; left: 0; top: 0; transform-style: preserve-3d; }
.ag-face {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px;
  background: var(--ag-side); -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.ag-face--top    { transform: translateZ(7px); background: var(--ag-top); transition: background .4s ease; }
.ag-face--bottom { transform: rotateY(180deg) translateZ(7px); }
.ag-face--front  { transform: rotateX(-90deg) translateZ(7px); }
.ag-face--back   { transform: rotateX(90deg) translateZ(7px); }
.ag-face--left   { transform: rotateY(-90deg) translateZ(7px); background: var(--ag-side-2); }
.ag-face--right  { transform: rotateY(90deg) translateZ(7px); background: var(--ag-side-2); }
.ag-face--front::after { content: ""; position: absolute; left: 3px; right: 3px; top: 5.5px; height: 3px; border-radius: 2px; background: var(--ag-visor); transition: background .4s ease; }
.ag-bot.is-approved .ag-face--top { background: var(--ag-ok); }
.ag-bot.is-approved .ag-face--front::after { background: #7BE3A0; }
.ag-bot .ag-tag { left: 15px; top: -24px; }
/* The coin a block earns when you give it a job: pops out over its head, flips as it rises, fades */
.ag-coin {
  position: absolute; left: -8px; top: -48px; width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 34% 28%, #FFF4BF 0 16%, #F6C84A 42%, #D6961C 100%);
  box-shadow: inset 0 0 0 1.5px rgba(255,248,214,.6), inset 0 -2px 0 rgba(150,96,10,.35), 0 3px 6px -1px rgba(14,13,11,.28);
  animation: agCoin 1.15s cubic-bezier(.2,.8,.25,1) forwards;
}
.ag-coin svg { width: 9px; height: auto; fill: rgba(128,80,6,.72); }
@keyframes agCoin {
  0%   { transform: translateY(14px) scale(.4) rotateY(0deg); opacity: 0; }
  14%  { opacity: 1; }
  55%  { transform: translateY(-12px) scale(1) rotateY(540deg); opacity: 1; }
  78%  { transform: translateY(-16px) scale(1) rotateY(720deg); opacity: 1; }
  100% { transform: translateY(-20px) scale(.9) rotateY(720deg); opacity: 0; }
}
.ag-cur--ben .ag-arrow path { fill: var(--ag-ok); stroke: #FFFFFF; }
.ag-cur--ben .ag-tag { background: var(--ag-ok); color: #FFFFFF; padding-left: 10px; }
.ag-cur--ben .ag-status { display: none; }
.ag-cur.is-click .ag-arrow { animation: agClick .32s ease; }
@keyframes agClick { 40% { transform: scale(.82); } }

@media (prefers-reduced-motion: reduce) {
  .wip-tile.ag-scanning .ag-scan { animation: none; background-position: 0 50%; }
  .ag-task, .ag-sel, .ag-handle, .ag-tag { transition: none; }
  .ag-task > span.is-thinking { animation: none; background-position: 50% 0; }
}
