/* 3D scenes for the «Ճարտարապետություն» page — pure CSS 3D (no libraries). Scenes keep a dark «screen» in both themes. */
@property --spin { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --h { syntax: "<length>"; inherits: true; initial-value: 0px; }

/* ───────── hero layout ───────── */
.a3-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: center; }
.a3-hero .ar-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1150px) { .a3-hero { grid-template-columns: 1fr; } }

/* ───────── constellation ───────── */
.a3-scene { position: relative; height: 470px; border-radius: 20px; overflow: hidden; perspective: 1100px; isolation: isolate;
  border: 1px solid var(--y-25); background: radial-gradient(ellipse at 50% 58%, #2a1f05 0%, #0b0b0f 46%, #050609 100%); }
.a3-stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; }
.a3-cam { position: absolute; inset: 0; transform-style: preserve-3d; transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .3s ease-out; }
.a3-world { position: absolute; left: 50%; top: 60%; width: 0; height: 0; transform-style: preserve-3d; transform: rotateX(64deg); }
.a3-spin { position: absolute; transform-style: preserve-3d; transform: rotateZ(var(--spin)); animation: a3-spin 60s linear infinite; }
@keyframes a3-spin { to { --spin: 360deg; } }
.a3-ring { position: absolute; border-radius: 50%; transform: translate(-50%, -50%); }
.a3-ring.r1 { width: 230px; height: 230px; border: 1px solid #ffd00055; box-shadow: 0 0 40px #ffd00022 inset; }
.a3-ring.r2 { width: 380px; height: 380px; border: 1px solid #ffd00066; box-shadow: 0 0 30px #ffd0001f; }
.a3-ring.r3 { width: 520px; height: 520px; border: 1px dashed #ffd00030; }
.a3-beam { position: absolute; left: 0; top: -1px; width: 190px; height: 2px; transform-origin: 0 50%; transform: rotateZ(var(--a));
  background: linear-gradient(90deg, #ffd000aa, #ffd00018); }
.a3-beam:not(.on) { opacity: .3; }
.a3-beam i { position: absolute; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: #ffe680; box-shadow: 0 0 12px 2px #ffd000;
  animation: a3-packet 2.6s linear infinite; animation-delay: var(--d); }
.a3-beam:not(.on) i { display: none; }
@keyframes a3-packet { 0% { left: 182px; opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { left: 0; opacity: 0; } }
.a3-sat { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transform: rotateZ(var(--a)) translateX(190px); }
.a3-bill { position: absolute; left: 0; top: 0; transform-origin: 0 0; white-space: nowrap;
  transform: rotateZ(calc(-1 * (var(--a, 0deg) + var(--spin)))) rotateX(-64deg) translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 12px 9px; border-radius: 14px; text-align: center;
  background: #0b0d12e6; border: 1px solid var(--y-30); box-shadow: 0 10px 30px #000a, 0 0 0 1px #ffd0000d inset; }
.a3-bill b { font-size: 13px; font-weight: 500; color: #fff; } .a3-bill small { font-size: 10px; color: var(--w55); }
.a3-orb { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: var(--y);
  background: radial-gradient(#ffd00038, #ffd0000a); border: 1px solid var(--y-35); box-shadow: 0 0 18px #ffd00066; }
.a3-orb.sm { width: 28px; height: 28px; }
.a3-ok .a3-orb { animation: a3-pulse 2.4s ease-in-out infinite; }
@keyframes a3-pulse { 50% { box-shadow: 0 0 28px 4px #ffd00088; } }
.a3-warn { opacity: .55; border-color: var(--line2); } .a3-warn .a3-orb { color: var(--w55); border-color: var(--line2); box-shadow: none; background: #ffffff0a; }
/* core cube (stands on the orbit plane, spins) */
.a3-core { position: absolute; left: -36px; top: -36px; width: 72px; height: 72px; transform-style: preserve-3d; animation: a3-cube 16s linear infinite; }
@keyframes a3-cube { to { transform: rotateZ(360deg); } }
.a3-cf { position: absolute; inset: 0; display: grid; place-items: center; font: 600 8px/1 var(--mono); letter-spacing: .2em; color: #000;
  background: linear-gradient(135deg, #ffd000ee, #ff9a3ccc); border: 1px solid #ffe680; box-shadow: 0 0 30px #ffd00088; }
.a3-cf-t { transform: translateZ(72px); background: linear-gradient(135deg, #fff1a6, #ffd000); }
.a3-cf-d { transform: translateZ(0); opacity: .4; }
.a3-cf-f { transform-origin: 50% 100%; transform: rotateX(-90deg); }
.a3-cf-b { transform-origin: 50% 0; transform: rotateX(90deg); }
.a3-cf-l { transform-origin: 0 50%; transform: rotateY(-90deg); background: linear-gradient(135deg, #e0a800, #b8661f); }
.a3-cf-r { transform-origin: 100% 50%; transform: rotateY(90deg); background: linear-gradient(135deg, #e0a800, #b8661f); }
/* vertical mast to the human gate */
.a3-mast { position: absolute; left: -1px; top: 0; width: 2px; height: 110px; transform-origin: top; transform: translateZ(72px) rotateX(90deg);
  background: linear-gradient(#8ab4ff, #8ab4ff00); background-size: 100% 200%; animation: a3-up 1.6s linear infinite; }
@keyframes a3-up { from { background-position: 0 100%; } to { background-position: 0 -100%; } }
.a3-human { position: absolute; left: 0; top: 0; transform-style: preserve-3d; transform: translateZ(196px); }
.a3-human-card { border-color: #8ab4ff66; } .a3-human-card .a3-orb { color: #8ab4ff; border-color: #8ab4ff66; background: #8ab4ff1a; box-shadow: 0 0 22px #8ab4ff66; }
.a3-legend { position: absolute; left: 14px; right: 14px; bottom: 12px; display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--w55); }
.a3-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.a3-legend i.ok { background: var(--y); box-shadow: 0 0 8px var(--y); } .a3-legend i.warn { background: var(--w40); } .a3-legend i.hu { background: #8ab4ff; }
.a3-hint { margin-left: auto; color: var(--w40); }

/* ───────── layer stack (RAG city → code → agents → human) ───────── */
.a3-layers { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 20px; align-items: center; }
@media (max-width: 1000px) { .a3-layers { grid-template-columns: 1fr; } }
.a3-stackwrap { position: relative; height: 560px; border-radius: 20px; overflow: hidden; perspective: 1500px; border: 1px solid var(--line2);
  background: radial-gradient(ellipse at 50% 70%, #1d1405 0%, #08090d 55%, #050609 100%); }
.a3-stack { position: absolute; left: 50%; top: 66%; width: 440px; height: 260px; margin: -130px 0 0 -220px; transform-style: preserve-3d;
  transform: rotateX(calc(57deg + var(--rx, 0deg))) rotateZ(calc(-40deg + var(--ry, 0deg))); transition: transform .3s ease-out; }
.a3-plane { position: absolute; inset: 0; transform-style: preserve-3d; transform: translateZ(calc(var(--i) * 86px)); border-radius: 18px;
  transition: transform .4s cubic-bezier(.2, .7, .2, 1), box-shadow .4s; }
.a3-plane:hover, .a3-plane.hot { transform: translateZ(calc(var(--i) * 86px + 22px)); }
.a3-p-rag { background: linear-gradient(135deg, #ff9a3c22, #ff9a3c08); border: 1px solid #ff9a3c88; box-shadow: 0 0 60px #ff9a3c22; }
.a3-p-code { background: linear-gradient(135deg, #ffd0001f, #ffd00006); border: 1px solid #ffd00088; }
.a3-p-agents { background: linear-gradient(135deg, #5fd4c41c, #5fd4c405); border: 1px solid #5fd4c488; }
.a3-p-human { background: linear-gradient(135deg, #8ab4ff22, #8ab4ff06); border: 1px solid #8ab4ff88; }
.a3-plane.hot, .a3-plane:hover { box-shadow: 0 0 70px #ffd00055; }
.a3-plabel { position: absolute; left: 16px; top: 12px; display: flex; flex-direction: column; gap: 2px; }
.a3-plabel b { font-size: 17px; font-weight: 500; color: #fff; text-shadow: 0 0 14px #000, 0 0 2px #000; }
.a3-plabel small { font-size: 11.5px; color: var(--w75); text-shadow: 0 0 8px #000; }
.a3-city { position: absolute; left: 34px; right: 34px; top: 62px; bottom: 28px; display: grid; grid-template-columns: repeat(6, 1fr);
  gap: 12px; place-items: center; transform-style: preserve-3d; }
.a3-tower { position: relative; width: 22px; height: 22px; transform-style: preserve-3d; animation: a3-rise 1.6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes a3-rise { from { --h: 0px; } }
.a3-tower span { position: absolute; }
.a3-tower .tp { inset: 0; transform: translateZ(var(--h)); background: #ffd36b; box-shadow: 0 0 12px #ffb34799; }
.a3-tower .fr { left: 0; top: 100%; width: 100%; height: var(--h); transform-origin: top; transform: rotateX(90deg); background: linear-gradient(#ff9a3c, #b5561a); }
.a3-tower .sd { left: 100%; top: 0; width: var(--h); height: 100%; transform-origin: left; transform: rotateY(-90deg); background: linear-gradient(90deg, #8a3f12, #c9701f); }
.a3-slabs { position: absolute; left: 26px; right: 26px; top: 58px; bottom: 20px; display: flex; flex-wrap: wrap; gap: 8px; align-content: center;
  justify-content: center; transform-style: preserve-3d; }
.a3-slab { font: 10px/1 var(--mono); padding: 7px 9px; border-radius: 8px; color: #fff; background: #ffd00026; border: 1px solid #ffd00080;
  transform: translateZ(10px); box-shadow: 0 6px 0 -1px #ffd0003a; }
.a3-pins { position: absolute; left: 30px; right: 30px; top: 64px; bottom: 26px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  place-items: center; transform-style: preserve-3d; }
.a3-pin { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px; font-size: 11px; color: var(--w75);
  background: #ffffff0a; border: 1px solid var(--line2); transform: translateZ(12px); }
.a3-pin.on { color: #fff; border-color: #5fd4c4aa; background: #5fd4c422; box-shadow: 0 0 18px #5fd4c455; }
.a3-pin.on svg { color: #5fd4c4; }
.a3-gates { position: absolute; inset: 60px 30px 30px; display: flex; gap: 14px; align-items: center; justify-content: center; transform-style: preserve-3d; }
.a3-gatechip { display: flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 12px; font: 600 12px/1 var(--mono); color: #000;
  background: linear-gradient(135deg, #b9d0ff, #8ab4ff); transform: translateZ(16px); box-shadow: 0 0 24px #8ab4ff88; }
.a3-pillar { position: absolute; width: 2px; height: 86px; transform-origin: top; transform: rotateX(90deg);
  background: linear-gradient(#ffd00000, #ffd000, #ffd00000); background-size: 100% 60%; background-repeat: no-repeat; animation: a3-climb 2.2s linear infinite; }
.a3-pillar.p1 { left: 14px; top: 14px; } .a3-pillar.p2 { right: 14px; top: 14px; } .a3-pillar.p3 { left: 14px; top: calc(100% - 14px); }
.a3-pillar.p4 { right: 14px; top: calc(100% - 14px); animation-delay: 1.1s; }
@keyframes a3-climb { from { background-position: 0 -60%; } to { background-position: 0 160%; } }
.a3-leg { display: flex; flex-direction: column; gap: 10px; }
.a3-legi { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--card);
  cursor: default; transition: border-color .2s, transform .2s; }
.a3-legi:hover { border-color: var(--y-35); transform: translateX(4px); }
.a3-legi b { font-size: 14px; font-weight: 500; } .a3-legi p { margin: 4px 0 0; font-size: 12.5px; color: var(--w75); line-height: 1.6; }
.a3-dot { flex-shrink: 0; width: 12px; height: 12px; margin-top: 4px; border-radius: 4px; }
.a3-dot-rag { background: #ff9a3c; box-shadow: 0 0 10px #ff9a3c; } .a3-dot-code { background: var(--y); box-shadow: 0 0 10px var(--y); }
.a3-dot-agents { background: #5fd4c4; box-shadow: 0 0 10px #5fd4c4; } .a3-dot-human { background: #8ab4ff; box-shadow: 0 0 10px #8ab4ff; }

/* ───────── rules carousel ───────── */
.a3-carousel { position: relative; height: 380px; perspective: 1300px; border-radius: 20px; overflow: hidden; border: 1px solid var(--line2);
  background: radial-gradient(ellipse at 50% 50%, #191306 0%, #07080c 60%); }
.a3-wheel { position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform-style: preserve-3d; animation: a3-wheel 44s linear infinite; }
.a3-carousel:hover .a3-wheel { animation-play-state: paused; }
@keyframes a3-wheel { from { transform: translateZ(-90px) rotateX(-6deg) rotateY(0deg); } to { transform: translateZ(-90px) rotateX(-6deg) rotateY(-360deg); } }
.a3-rule { position: absolute; left: -110px; top: -95px; width: 220px; min-height: 190px; padding: 16px; border-radius: 16px; display: flex; flex-direction: column; gap: 8px;
  background: #0c0e13ee; border: 1px solid var(--y-30); box-shadow: 0 0 40px #ffd0001a;
  transform: rotateY(calc(var(--i) * 360deg / var(--n))) translateZ(330px); }
.a3-rule b { font-size: 14px; font-weight: 500; color: var(--y); } .a3-rule p { margin: 0; font-size: 12.5px; color: var(--w80); line-height: 1.6; }

/* ───────── agent flip cards ───────── */
.a3-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.a3-flip { perspective: 1400px; cursor: pointer; outline: none; }
.a3-flip:focus-visible .a3-face { border-color: var(--y); }
.a3-inner { display: grid; height: 100%; transform-style: preserve-3d; transition: transform .9s cubic-bezier(.2, .7, .2, 1); }
.a3-flip:hover:not(.is-flipped) .a3-inner { transform: rotateY(-7deg) rotateX(3deg); }
.a3-flip.is-flipped .a3-inner { transform: rotateY(180deg); }
.a3-face { grid-area: 1 / 1; display: flex; flex-direction: column; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border: 1px solid var(--line2); border-radius: 18px; padding: 16px; background: var(--card2); }
.a3-front { background: linear-gradient(160deg, #ffd0000c, #0000 45%), var(--card2); }
.a3-back { transform: rotateY(180deg); background: linear-gradient(200deg, #8ab4ff12, #0000 45%), #0b0d11; border-color: var(--y-30); }
.a3-face header { display: flex; align-items: center; gap: 12px; }
.a3-face header b { font-size: 16px; font-weight: 500; } .a3-face header small { display: block; font-size: 12px; color: var(--w55); }
.a3-list { margin: 0; padding-left: 18px; font-size: 12px; color: var(--w80); line-height: 1.55; }
.a3-list li::marker { color: var(--y); }
.a3-know { grid-template-columns: 1fr; }
.a3-turn { margin: auto 0 0; padding-top: 12px; display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--y); opacity: .8; }
.ar-st-warn .a3-face { opacity: .9; }

/* ───────── small screens / motion / light theme ───────── */
@media (max-width: 700px) {
  .a3-scene { height: 380px; } .a3-world { transform: rotateX(64deg) scale(.72); }
  .a3-stackwrap { height: 430px; } .a3-stack { transform: rotateX(57deg) rotateZ(-40deg) scale(.72); }
  .a3-carousel { height: auto; perspective: none; overflow: visible; background: none; border: 0; }
  .a3-wheel { position: static; width: auto; height: auto; animation: none; transform: none; display: grid; gap: 10px; }
  .a3-rule { position: static; width: auto; min-height: 0; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .a3-spin, .a3-core, .a3-wheel, .a3-beam i, .a3-mast, .a3-pillar, .a3-ok .a3-orb, .a3-tower { animation: none !important; }
}
.vega-studio.light .a3-face { background: #fff; border-color: #0000001a; }
.vega-studio.light .a3-back { background: linear-gradient(200deg, #8ab4ff1f, #fff 45%); }
.vega-studio.light .a3-face header b, .vega-studio.light .a3-list { color: #1c1914; }
.vega-studio.light .a3-legi { background: #fff; border-color: #0000001a; }
.vega-studio.light .a3-legi p { color: #3b352a; }
