/* ============================================================
   SynergyOS — frontend/static/css/radial_action_menu.css
   Force-Directed Graph Action Menu (d3-force physics engine)
   Glassmorphic, playful, GPU-only animations (transform/opacity)

   Node position (left/top in px) is written every simulation tick
   directly from JS (radial_action_menu.js) — CSS only owns the
   *visual* layer: entrance pop-in, hover/press scale, glass card
   styling. Position and scale live on separate properties so they
   never fight: left/top for physics, transform for micro-interactions.
   ============================================================ */

.ram-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 40;
}

/* nodes' left/top are px offsets relative to this layer — it must share
   .ram-root's exact origin/size (same as the .ram-center hub, a direct
   .ram-root child) for d3's drag `.container()` coordinates to line up */
.ram-nodes-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.ram-nodes-layer .ram-node { pointer-events: auto; }

/* ── SVG edge layer — soft, rounded "network" connector lines ── */
.ram-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
/* glow comes from a true SVG <filter> (feGaussianBlur+feMerge, defined in JS) applied
   per-path via filter="url(#ram-glow[-spoke])" — only stroke-opacity/width pulse here,
   so the blur itself never needs recomputing per frame */
.ram-edge {
  fill: none;
  stroke: rgba(255, 225, 190, 0.32);
  stroke-width: 4.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: ram-edge-glow-soft 3.2s ease-in-out infinite;
}
.ram-edge.ram-edge-spoke {
  stroke-width: 5.5;
  stroke: rgba(255, 193, 92, 0.4);
  animation: ram-edge-glow-spoke 2.4s ease-in-out infinite;
}
.ram-root.is-open .ram-edge {
  opacity: 1;
  transition-delay: var(--ram-edge-delay, 0ms);
}
@keyframes ram-edge-glow-soft {
  0%, 100% { stroke-opacity: 0.32; stroke-width: 4.5; }
  50%      { stroke-opacity: 0.55; stroke-width: 5; }
}
@keyframes ram-edge-glow-spoke {
  0%, 100% { stroke-opacity: 0.4;  stroke-width: 5.5; }
  50%      { stroke-opacity: 0.65; stroke-width: 6.2; }
}

/* small pulsing dot traveling along spoke edges for a "live data" feel */
.ram-edge-pulse {
  fill: rgba(255, 225, 190, 0.85);
  opacity: 0;
}
.ram-root.is-open .ram-edge-pulse {
  opacity: 1;
  animation: ram-pulse-travel 2.6s linear infinite;
  animation-delay: var(--ram-edge-delay, 0ms);
}
@keyframes ram-pulse-travel {
  0%   { offset-distance: 0%; opacity: 0; }
  8%   { opacity: 1; }
  92%  { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

/* ── Root / hub node — position (left/top) is JS/physics-driven, pinned at fx/fy ── */
.ram-center {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) scale(1);
  width: 86px;
  height: 86px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(28, 18, 24, 0.28);
  backdrop-filter: blur(9px) saturate(1.3);
  -webkit-backdrop-filter: blur(9px) saturate(1.3);
  border: 3px solid rgba(255, 193, 92, 0.7);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 0 7px rgba(255, 193, 92, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
  pointer-events: auto;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  will-change: transform;
  z-index: 2;
}
.ram-center:hover { transform: translate(-50%, -50%) scale(1.07); }
.ram-center:active,
.ram-center.is-pressed { transform: translate(-50%, -50%) scale(0.93); }

.ram-center .ram-center-icon {
  font-size: 1.75rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.ram-center .ram-center-label {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--clr-text, #fbf1e6);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.5);
  max-width: 72px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* invite-to-open pulse ring */
.ram-center::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(255, 193, 92, 0.5);
  opacity: 0;
  transform: scale(1);
  pointer-events: none;
}
.ram-root:not(.is-open) .ram-center::after {
  animation: ram-invite-pulse 2.4s ease-out infinite;
}
@keyframes ram-invite-pulse {
  0%   { opacity: 0.55; transform: scale(1); }
  70%  { opacity: 0; transform: scale(1.5); }
  100% { opacity: 0; transform: scale(1.5); }
}

/* ── Action nodes — physics-positioned via left/top (JS, every tick) ──
   transform is left free for entrance/hover/press scale only, so the
   d3-force simulation's per-frame position writes never collide with
   CSS transitions. */
.ram-node {
  position: absolute;
  left: 50%;
  top: 46%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  cursor: grab;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.25);
  transition:
    transform 0.46s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    opacity 0.24s ease;
  will-change: left, top, transform, opacity;
  z-index: 3;
}
.ram-root.is-open .ram-node {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  transition-delay: var(--ram-delay, 0ms);
}
.ram-node:hover { transform: translate(-50%, -50%) scale(1.1); }
.ram-node:active,
.ram-node.is-pressed { cursor: grabbing; transform: translate(-50%, -50%) scale(0.92); }

/* ── Category ("group") nodes — Root -> Category -> Action hiyerarşisi
   opsiyonel olarak action.group verilirse devreye girer ── */
.ram-node.is-group .ram-node-circle {
  width: 52px;
  height: 52px;
  background: rgba(28, 18, 24, 0.24);
  border-color: rgba(255, 255, 255, 0.3);
}
.ram-node.is-group .ram-node-icon { font-size: 1.1rem; opacity: 0.85; }
.ram-node.is-group { cursor: default; }

.ram-node .ram-node-circle {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 30, 0.22);
  backdrop-filter: blur(7px) saturate(1.3);
  -webkit-backdrop-filter: blur(7px) saturate(1.3);
  border: 2.5px solid var(--ram-node-stroke, rgba(255, 255, 255, 0.4));
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.3),
    0 0 14px var(--ram-node-glow, rgba(255, 122, 89, 0.22)),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.ram-node:hover .ram-node-circle { border-color: var(--ram-node-stroke-hover, rgba(255, 255, 255, 0.6)); }

.ram-node .ram-node-icon {
  font-size: 1.45rem;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.45));
}

.ram-node .ram-node-label {
  margin-top: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-align: center;
  color: var(--clr-text, #fbf1e6);
  background: rgba(15, 12, 16, 0.3);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 6px rgba(0, 0, 0, 0.5);
}

.ram-node .ram-node-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--clr-accent, #ffc15c);
  color: #2a1a08;
  font-size: 0.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* ── Orbit chips — cost/reward "electrons" spinning around a hovered node ── */
.ram-node-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 6;
}
.ram-node.is-orbit-active .ram-node-orbit {
  opacity: 1;
  transform: scale(1);
}

.ram-orbit-pivot {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform: rotate(var(--orbit-angle, 0deg));
}
.ram-orbit-spin {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  animation: ram-orbit-rotate var(--orbit-duration, 7s) linear infinite;
}
.ram-node.is-disabled .ram-orbit-spin,
.ram-node:not(.is-orbit-active) .ram-orbit-spin {
  animation-play-state: paused;
}

.ram-orbit-chip {
  position: absolute;
  top: 0;
  left: 0;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.6rem;
  font-weight: 800;
  white-space: nowrap;
  background: rgba(18, 14, 16, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1.5px solid var(--orbit-stroke, rgba(255, 255, 255, 0.4));
  box-shadow: 0 0 8px var(--orbit-glow, rgba(255, 255, 255, 0.3)), 0 2px 6px rgba(0, 0, 0, 0.4);
  color: var(--clr-text, #fbf1e6);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  animation: ram-orbit-counter var(--orbit-duration, 7s) linear infinite;
}
.ram-node:not(.is-orbit-active) .ram-orbit-chip {
  animation-play-state: paused;
}

.ram-orbit-chip[data-variant="cost"] {
  --orbit-stroke: rgba(239, 111, 96, 0.7);
  --orbit-glow: rgba(239, 111, 96, 0.45);
  color: #ffd8d2;
}
.ram-orbit-chip[data-variant="reward"] {
  --orbit-stroke: rgba(134, 211, 158, 0.75);
  --orbit-glow: rgba(134, 211, 158, 0.45);
  color: #d9ffe6;
}

@keyframes ram-orbit-rotate {
  from { transform: rotate(0deg) translateX(var(--orbit-radius, 52px)); }
  to   { transform: rotate(360deg) translateX(var(--orbit-radius, 52px)); }
}
@keyframes ram-orbit-counter {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to   { transform: translate(-50%, -50%) rotate(-360deg); }
}

.ram-node.is-disabled .ram-node-circle {
  filter: grayscale(0.6);
  opacity: 0.55;
}
.ram-node.is-disabled .ram-node-label { opacity: 0.55; }
.ram-node.is-disabled { cursor: not-allowed; }

/* color variants for playful variety — set via data-color on node */
.ram-node[data-color="teal"]   { --ram-node-stroke: rgba(95,200,181,0.6);  --ram-node-stroke-hover: rgba(95,200,181,0.95);  --ram-node-glow: rgba(95,200,181,0.3); }
.ram-node[data-color="pink"]   { --ram-node-stroke: rgba(255,155,176,0.6); --ram-node-stroke-hover: rgba(255,155,176,0.95); --ram-node-glow: rgba(255,155,176,0.3); }
.ram-node[data-color="amber"]  { --ram-node-stroke: rgba(255,193,92,0.6);  --ram-node-stroke-hover: rgba(255,193,92,0.95);  --ram-node-glow: rgba(255,193,92,0.3); }
.ram-node[data-color="coral"]  { --ram-node-stroke: rgba(255,122,89,0.6);  --ram-node-stroke-hover: rgba(255,122,89,0.95);  --ram-node-glow: rgba(255,122,89,0.3); }
.ram-node[data-color="violet"] { --ram-node-stroke: rgba(139,108,255,0.6); --ram-node-stroke-hover: rgba(139,108,255,0.95); --ram-node-glow: rgba(139,108,255,0.3); }

/* ── Backdrop scrim — keeps scene visible, just dims slightly for focus ── */
.ram-scrim {
  position: absolute;
  inset: 0;
  background: rgba(10, 6, 10, 0);
  pointer-events: none;
  transition: background 0.25s ease;
}
.ram-root.is-open .ram-scrim {
  background: rgba(10, 6, 10, 0.06);
  pointer-events: auto;
}

/* ── Tooltip-style toast for disabled/locked nodes ── */
.ram-toast {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translate(-50%, 8px);
  background: rgba(20, 20, 30, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2px solid rgba(255, 193, 92, 0.6);
  border-radius: 14px;
  padding: 8px 14px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--clr-text, #fbf1e6);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
  z-index: 5;
}
.ram-toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ── Responsive scale-down on small screens ── */
@media (max-width: 480px) {
  .ram-center { width: 70px; height: 70px; }
  .ram-node .ram-node-circle { width: 52px; height: 52px; }
  .ram-node .ram-node-icon { font-size: 1.2rem; }
  .ram-node .ram-node-label { font-size: 0.54rem; padding: 2px 7px; }
  .ram-orbit-chip { font-size: 0.54rem; padding: 2px 6px; }
}

/* ── Mount container override (SynergyOS ayarlar > Eylem Gösterim Şekli) ──
   .action-cards varsayılan olarak grid'dir; radyal mod aktifken .ram-root'un
   position:absolute; inset:0 kurallarının çalışabilmesi için pozisyonlu ve
   yeterli yükseklikte bir kutuya çevrilir. */
.action-cards.action-cards-radial-mode {
  display: block;
  position: relative;
  min-height: 420px;
}
@media (max-width: 480px) {
  .action-cards.action-cards-radial-mode { min-height: 340px; }
}

@media (prefers-reduced-motion: reduce) {
  .ram-node, .ram-center, .ram-edge, .ram-edge-pulse, .ram-toast,
  .ram-orbit-spin, .ram-orbit-chip {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }
}
