/* =========================================================
  AtomLab Interaktif - atom.css
  ---------------------------------------------------------
  File ini khusus untuk visual mode Atom:
  - area simulasi atom
  - canvas atom
  - nucleus / inti atom
  - proton, neutron, elektron visual
  - electron shell dan electron cloud
  - particle tray
  - element name dan stability text
  - animasi visual atom
========================================================= */

/* =========================================================
  Atom Lab Panel
========================================================= */

.atom-lab-panel::before,
.atom-lab-panel::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: var(--radius-full);
  z-index: 0;
}

.atom-lab-panel::before {
  width: 420px;
  height: 420px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -52%);
  background: radial-gradient(circle, rgba(96, 165, 250, 0.18), transparent 68%);
}

.atom-lab-panel::after {
  width: 260px;
  height: 260px;
  right: -90px;
  top: 110px;
  background: radial-gradient(circle, rgba(250, 204, 21, 0.18), transparent 70%);
}

.element-name-display {
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  top: 104px;
  z-index: 6;
  color: var(--accent-orange);
  font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl));
  font-weight: 950;
  text-align: center;
  letter-spacing: -0.04em;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.74);
}

.stability-text {
  position: absolute;
  left: var(--space-4);
  right: var(--space-4);
  bottom: 156px;
  z-index: 7;
  margin: 0;
  font-size: clamp(var(--text-2xl), 3vw, var(--text-3xl));
  font-weight: 950;
  text-align: center;
  letter-spacing: -0.03em;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(255, 255, 255, 0.78);
}

/* =========================================================
  Atom Canvas
========================================================= */

.atom-canvas {
  width: 560px;
  height: 560px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  isolation: isolate;
}

.atom-canvas::before {
  content: "";
  position: absolute;
  inset: 42px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.62), transparent 66%);
  z-index: -2;
}

.atom-canvas::after {
  content: "";
  position: absolute;
  inset: 98px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(15, 23, 42, 0.05), transparent 58%);
  z-index: -1;
}

.atom-canvas-small {
  transform: scale(0.78);
  transform-origin: center;
}

/* =========================================================
  Electron Cloud & Shells
========================================================= */

.electron-cloud {
  position: absolute;
  width: 365px;
  height: 365px;
  border-radius: var(--radius-full);
  background:
    radial-gradient(circle at 50% 50%, rgba(37, 99, 235, 0.66) 0%, rgba(59, 130, 246, 0.46) 32%, rgba(129, 140, 248, 0.20) 56%, transparent 74%),
    radial-gradient(circle at 34% 38%, rgba(255, 255, 255, 0.28), transparent 24%);
  filter: blur(0.3px);
  opacity: 0.45;
  z-index: 1;
  transition:
    opacity var(--duration-normal) var(--ease-out),
    transform var(--duration-normal) var(--ease-out);
  animation: cloudPulse 4s ease-in-out infinite;
}

.electron-shell {
  position: absolute;
  display: none;
  border: 3px dashed rgba(29, 78, 216, 0.76);
  border-radius: var(--radius-full);
  z-index: 2;
  opacity: 0.92;
  box-shadow: 0 0 22px rgba(37, 99, 235, 0.08);
}

.electron-shell.shell-1 {
  width: 168px;
  height: 168px;
}

.electron-shell.shell-2 {
  width: 280px;
  height: 280px;
}

.electron-shell.shell-3 {
  width: 400px;
  height: 400px;
}

.atom-canvas.is-shell-model .electron-shell {
  display: block;
}

.atom-canvas.is-shell-model .electron-cloud {
  display: none;
}

.atom-canvas.is-cloud-model .electron-shell {
  display: none;
}

.atom-canvas.is-cloud-model .electron-cloud {
  display: block;
}

@keyframes cloudPulse {
  0%, 100% {
    transform: scale(1);
    filter: blur(0.3px);
  }
  50% {
    transform: scale(1.025);
    filter: blur(0.8px);
  }
}

/* =========================================================
  Nucleus & Particles
========================================================= */

.nucleus {
  width: 176px;
  height: 176px;
  position: absolute;
  z-index: 5;
  border-radius: var(--radius-full);
}

.nucleus::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 58%);
  z-index: -1;
}

.nucleus.is-empty::after {
  content: "×";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--color-yellow-500);
  font-size: 5.5rem;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 4px 14px rgba(234, 88, 12, 0.18);
}

.nucleus-particle {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 0, 0, 0.34);
  box-shadow:
    inset -10px -10px 14px rgba(0, 0, 0, 0.27),
    inset 8px 8px 12px rgba(255, 255, 255, 0.7),
    0 6px 14px rgba(15, 23, 42, 0.18);
  transform: translate(-50%, -50%);
  animation: particlePop var(--duration-slow) var(--ease-out);
}

.nucleus-particle.is-proton {
  background: radial-gradient(circle at 30% 30%, #fed7aa 0 12%, var(--proton-color) 30%, var(--proton-dark) 100%);
}

.nucleus-particle.is-neutron {
  background: radial-gradient(circle at 30% 30%, #e5e7eb 0 12%, var(--neutron-color) 34%, var(--neutron-dark) 100%);
}

.orbit-electron {
  position: absolute;
  width: 24px;
  height: 24px;
  z-index: 6;
  border-radius: var(--radius-full);
  border: 1px solid rgba(0, 0, 0, 0.34);
  background: radial-gradient(circle at 32% 30%, #bfdbfe 0 12%, var(--electron-color) 36%, var(--electron-dark) 100%);
  box-shadow:
    inset -5px -5px 8px rgba(0, 0, 0, 0.24),
    inset 4px 4px 7px rgba(255, 255, 255, 0.78),
    0 5px 12px rgba(37, 99, 235, 0.22);
  transform: translate(-50%, -50%);
  animation: electronPop var(--duration-slow) var(--ease-out);
}

@keyframes particlePop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes electronPop {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

/* =========================================================
  Particle Trays
========================================================= */

.particle-tray {
  width: 205px;
  height: 98px;
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1rem 1rem;
  border-radius: 14px 14px 38px 38px;
  color: var(--color-white);
  font-size: var(--text-2xl);
  font-weight: 950;
  letter-spacing: -0.03em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.24),
    0 14px 28px rgba(15, 23, 42, 0.22);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition:
    transform var(--duration-fast) var(--ease-out),
    filter var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out);
}

.particle-tray:hover {
  transform: translateY(-5px);
  filter: saturate(1.08) brightness(1.03);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 20px 36px rgba(15, 23, 42, 0.28);
}

.particle-tray:active {
  cursor: grabbing;
  transform: translateY(-2px) scale(0.99);
}

.particle-tray::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -16px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.38);
  background: rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 6px 16px rgba(255, 255, 255, 0.18);
}

.tray-proton {
  background: linear-gradient(180deg, #f97316 0%, #c2410c 58%, #7c2d12 100%);
}

.tray-neutron {
  background: linear-gradient(180deg, #64748b 0%, #334155 54%, #111827 100%);
}

.tray-electron {
  background: linear-gradient(180deg, #3b82f6 0%, #1d4ed8 56%, #172554 100%);
}

.tray-samples {
  position: absolute;
  top: -30px;
  left: 50%;
  z-index: 2;
  width: 132px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  transform: translateX(-50%);
  pointer-events: none;
}

.tray-samples .particle-dot {
  width: 31px;
  height: 31px;
}

.tray-samples .electron-dot {
  width: 25px;
  height: 25px;
}

/* =========================================================
  Atom State Visual Modifiers
========================================================= */

.atom-lab-panel.is-stable .atom-canvas::before {
  background: radial-gradient(circle, rgba(34, 197, 94, 0.2), transparent 66%);
}

.atom-lab-panel.is-unstable .atom-canvas::before {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.16), transparent 66%);
}

.atom-lab-panel.is-positive-ion .atom-canvas::after {
  background: radial-gradient(circle, rgba(249, 115, 22, 0.12), transparent 58%);
}

.atom-lab-panel.is-negative-ion .atom-canvas::after {
  background: radial-gradient(circle, rgba(37, 99, 235, 0.14), transparent 58%);
}

/* =========================================================
  Responsive Atom Visuals
========================================================= */

@media (max-width: 1120px) {
  .atom-canvas {
    width: 520px;
    height: 520px;
  }

  .electron-shell.shell-1 {
    width: 158px;
    height: 158px;
  }

  .electron-shell.shell-2 {
    width: 260px;
    height: 260px;
  }

  .electron-shell.shell-3 {
    width: 370px;
    height: 370px;
  }

  .electron-cloud {
    width: 340px;
    height: 340px;
  }
}

@media (max-width: 760px) {
  .element-name-display {
    top: 132px;
    font-size: var(--text-3xl);
  }

  .stability-text {
    bottom: 300px;
    font-size: var(--text-2xl);
  }

  .atom-canvas {
    width: 460px;
    height: 460px;
    transform: scale(0.82);
  }

  .atom-canvas-small {
    transform: scale(0.68);
  }

  .electron-shell.shell-1 {
    width: 146px;
    height: 146px;
  }

  .electron-shell.shell-2 {
    width: 236px;
    height: 236px;
  }

  .electron-shell.shell-3 {
    width: 330px;
    height: 330px;
  }

  .electron-cloud {
    width: 300px;
    height: 300px;
  }

  .nucleus {
    width: 160px;
    height: 160px;
  }

  .nucleus-particle {
    width: 40px;
    height: 40px;
  }

  .orbit-electron {
    width: 22px;
    height: 22px;
  }

  .particle-tray {
    width: 230px;
    max-width: calc(100vw - 3rem);
  }
}

@media (max-width: 520px) {
  .atom-canvas {
    width: 420px;
    height: 420px;
    transform: scale(0.72);
  }

  .atom-canvas-small {
    transform: scale(0.62);
  }

  .element-name-display {
    top: 145px;
    font-size: var(--text-2xl);
  }

  .stability-text {
    bottom: 304px;
    font-size: var(--text-xl);
  }

  .particle-tray {
    height: 88px;
    font-size: var(--text-xl);
  }

  .tray-samples {
    top: -25px;
  }

  .tray-samples .particle-dot {
    width: 27px;
    height: 27px;
  }

  .tray-samples .electron-dot {
    width: 22px;
    height: 22px;
  }
}
