/* =========================================================
  MoleLab Interaktif - assets/css/molecule.css
  ---------------------------------------------------------
  Visual dan animasi kimia:
  - molekul dan atom bola
  - ikatan molekul
  - timbangan massa
  - paket Avogadro dan partikel
  - tabung gas
  - grafik persentase massa
  - visual umum untuk mode Ar/Mr, mol, partikel, gas, massa
========================================================= */

/* =========================================================
  Molecule Renderer Base
========================================================= */

.molecule-canvas {
  width: 100%;
  height: 100%;
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.molecule-canvas::before {
  content: "";
  position: absolute;
  width: 520px;
  height: 520px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(96, 165, 250, 0.15), transparent 68%);
  z-index: -2;
}

.molecule-canvas::after {
  content: "";
  position: absolute;
  width: 340px;
  height: 340px;
  border-radius: var(--radius-full);
  background: radial-gradient(circle, rgba(250, 204, 21, 0.13), transparent 72%);
  z-index: -1;
  animation: moleculeGlow 4s ease-in-out infinite;
}

.molecule-structure {
  width: 620px;
  height: 420px;
  position: relative;
  display: block;
}

.molecule-atom {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--color-white);
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    inset -12px -12px 18px rgba(0, 0, 0, 0.25),
    inset 10px 10px 18px rgba(255, 255, 255, 0.28),
    0 18px 38px rgba(15, 23, 42, 0.18);
  font-size: var(--text-2xl);
  font-weight: 950;
  line-height: 1;
  transform: translate(-50%, -50%);
  animation: atomEnter 520ms var(--ease-bounce) both;
}

.molecule-atom small {
  position: absolute;
  left: 50%;
  bottom: -1.25rem;
  transform: translateX(-50%);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 900;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(255, 255, 255, 0.9);
}

.molecule-atom-H {
  width: 78px;
  height: 78px;
  background: radial-gradient(circle at 32% 28%, #dbeafe, var(--atom-h) 50%, #1d4ed8 100%);
}

.molecule-atom-C {
  width: 104px;
  height: 104px;
  background: radial-gradient(circle at 32% 28%, #d1d5db, var(--atom-c) 54%, #020617 100%);
}

.molecule-atom-O {
  width: 112px;
  height: 112px;
  background: radial-gradient(circle at 32% 28%, #fecaca, var(--atom-o) 50%, #991b1b 100%);
}

.molecule-atom-N {
  width: 108px;
  height: 108px;
  background: radial-gradient(circle at 32% 28%, #bfdbfe, var(--atom-n) 50%, #172554 100%);
}

.molecule-atom-Na {
  width: 116px;
  height: 116px;
  background: radial-gradient(circle at 32% 28%, #fed7aa, var(--atom-na) 50%, #9a3412 100%);
}

.molecule-atom-Cl {
  width: 116px;
  height: 116px;
  background: radial-gradient(circle at 32% 28%, #bbf7d0, var(--atom-cl) 50%, #166534 100%);
}

.molecule-atom-Ca {
  width: 122px;
  height: 122px;
  background: radial-gradient(circle at 32% 28%, #e9d5ff, var(--atom-ca) 50%, #581c87 100%);
}

.molecule-atom-S {
  width: 112px;
  height: 112px;
  color: var(--text-main);
  background: radial-gradient(circle at 32% 28%, #fef9c3, var(--atom-s) 50%, #a16207 100%);
}

.molecule-atom-default {
  width: 100px;
  height: 100px;
  background: radial-gradient(circle at 32% 28%, #e2e8f0, var(--atom-default) 50%, #334155 100%);
}

.molecule-bond {
  position: absolute;
  height: 14px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), var(--molecule-bond));
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.6),
    0 8px 18px rgba(15, 23, 42, 0.18);
  transform-origin: left center;
  animation: bondGrow 420ms var(--ease-out) both;
}

.molecule-bond-double {
  height: 8px;
  box-shadow:
    0 -8px 0 rgba(15, 23, 42, 0.6),
    0 8px 18px rgba(15, 23, 42, 0.18);
}

.molecule-formula-badge {
  position: absolute;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  min-height: 56px;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-2xl);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-md);
  font-size: var(--text-3xl);
  font-weight: 950;
}

.molecule-formula-badge sub {
  font-size: 0.55em;
  margin-left: 1px;
}

.molecule-element-breakdown {
  position: absolute;
  left: var(--space-6);
  top: var(--space-6);
  display: grid;
  gap: var(--space-2);
  width: 220px;
}

.breakdown-chip {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 46px;
  padding: var(--space-2);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-sm);
  animation: popIn var(--duration-slow) var(--ease-out) both;
}

.breakdown-symbol {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--color-white);
  background: var(--gradient-primary);
  font-weight: 950;
}

.breakdown-chip strong {
  color: var(--text-main);
  font-size: var(--text-sm);
}

.breakdown-chip span {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
}

@keyframes moleculeGlow {
  0%, 100% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.55;
  }
}

@keyframes atomEnter {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes bondGrow {
  from {
    opacity: 0;
    transform: scaleX(0);
  }
  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* =========================================================
  Digital Scale / Mole Mass Mode
========================================================= */

.digital-scale {
  width: 420px;
  height: 360px;
  position: relative;
  display: grid;
  place-items: center;
  transform: translateY(-46px);
}

.scale-plate {
  width: 290px;
  height: 42px;
  position: absolute;
  top: 72px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #f8fafc 0%, #cbd5e1 54%, #64748b 100%);
  border: 2px solid rgba(15, 23, 42, 0.26);
  box-shadow:
    inset 0 8px 18px rgba(255, 255, 255, 0.55),
    0 20px 30px rgba(15, 23, 42, 0.18);
  z-index: 3;
}

.scale-plate::after {
  content: "";
  position: absolute;
  width: 210px;
  height: 20px;
  top: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.32);
}

.sample-pile {
  width: 112px;
  height: 54px;
  position: absolute;
  top: -44px;
  border-radius: 55% 45% 46% 54% / 45% 52% 48% 55%;
  background:
    radial-gradient(circle at 24% 36%, rgba(255, 255, 255, 0.6) 0 8%, transparent 9%),
    radial-gradient(circle at 72% 44%, rgba(255, 255, 255, 0.38) 0 7%, transparent 8%),
    linear-gradient(135deg, #93c5fd, #2563eb);
  box-shadow: var(--shadow-md);
  animation: sampleBounce 2.8s ease-in-out infinite;
}

.scale-body-large,
.digital-scale::before {
  content: "";
  width: 270px;
  height: 170px;
  position: absolute;
  top: 112px;
  border-radius: 34px 34px 24px 24px;
  background: linear-gradient(180deg, #475569 0%, #1e293b 48%, #020617 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: var(--shadow-xl);
  z-index: 1;
}

.scale-screen {
  width: 190px;
  min-height: 70px;
  position: absolute;
  top: 162px;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: var(--space-3);
  border-radius: var(--radius-xl);
  color: #86efac;
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.92), rgba(15, 23, 42, 0.96));
  border: 2px solid rgba(134, 239, 172, 0.22);
  box-shadow:
    inset 0 0 18px rgba(34, 197, 94, 0.14),
    0 10px 20px rgba(2, 6, 23, 0.28);
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: 950;
  letter-spacing: -0.05em;
}

.scale-screen::after {
  content: "MASSA";
  position: absolute;
  left: 50%;
  bottom: -1.25rem;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.55);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 900;
  letter-spacing: 0.16em;
}

.scale-base,
.digital-scale::after {
  content: "";
  width: 330px;
  height: 36px;
  position: absolute;
  bottom: 44px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.16);
  filter: blur(2px);
  z-index: 0;
}

.falling-sample {
  position: absolute;
  top: -40px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--primary);
  box-shadow: 0 0 14px rgba(37, 99, 235, 0.32);
  animation: fallingSample 1.1s var(--ease-in-out) both;
}

@keyframes sampleBounce {
  0%, 100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-6px) rotate(1deg);
  }
}

@keyframes fallingSample {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(170px) scale(1);
  }
}

/* =========================================================
  Avogadro Package / Particle Mode
========================================================= */

.avogadro-package-area {
  width: 620px;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: var(--space-5);
}

.avogadro-package {
  width: 170px;
  height: 150px;
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-3xl);
  color: var(--color-white);
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.35), transparent 28%),
    var(--gradient-warning);
  box-shadow: var(--shadow-xl), var(--shadow-glow-yellow);
  overflow: hidden;
  animation: packagePop 480ms var(--ease-bounce) both;
}

.avogadro-package::before {
  content: "";
  position: absolute;
  left: -12%;
  right: -12%;
  top: -28px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.38);
}

.avogadro-package span {
  font-size: var(--text-2xl);
  font-weight: 950;
}

.avogadro-package strong {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 950;
}

.avogadro-package.package-half {
  background:
    linear-gradient(90deg, var(--color-orange-500) 0 50%, rgba(249, 115, 22, 0.28) 50% 100%);
}

.avogadro-package.package-empty {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow-md);
}

.particle-cloud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.molar-particle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), transparent 28%),
    var(--primary);
  box-shadow: 0 0 16px rgba(37, 99, 235, 0.45);
  animation: particleDrift 4s ease-in-out infinite;
}

.molar-particle.is-gold {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.9), transparent 28%),
    var(--warning);
  box-shadow: 0 0 16px rgba(250, 204, 21, 0.48);
}

.molar-particle.is-green {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), transparent 28%),
    var(--success);
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.42);
}

@keyframes packagePop {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.72);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes particleDrift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.82;
  }
  50% {
    transform: translate(14px, -22px) scale(1.12);
    opacity: 1;
  }
}

/* =========================================================
  Gas Volume Mode
========================================================= */

.gas-cylinder-large {
  width: 260px;
  height: 430px;
  position: relative;
  display: block;
  overflow: hidden;
  border: 7px solid rgba(30, 64, 175, 0.86);
  border-radius: 44px 44px 68px 68px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.28) 38%, rgba(255, 255, 255, 0.62)),
    rgba(255, 255, 255, 0.42);
  box-shadow:
    inset 0 0 38px rgba(255, 255, 255, 0.45),
    var(--shadow-xl),
    var(--shadow-glow-blue);
}

.gas-cylinder-large::before {
  content: "";
  position: absolute;
  left: -8%;
  right: -8%;
  top: -22px;
  height: 52px;
  border-radius: 50%;
  border: 7px solid rgba(30, 64, 175, 0.86);
  background: rgba(255, 255, 255, 0.86);
  z-index: 4;
}

.gas-cylinder-large::after {
  content: "LITER";
  position: absolute;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  color: rgba(30, 64, 175, 0.72);
  font-size: var(--text-sm);
  font-weight: 950;
  letter-spacing: 0.16em;
  z-index: 5;
}

.gas-fill-large {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 54%;
  background:
    radial-gradient(circle at 30% 10%, rgba(255, 255, 255, 0.32), transparent 26%),
    linear-gradient(180deg, rgba(96, 165, 250, 0.38), rgba(37, 99, 235, 0.72));
  transition: height var(--duration-extra-slow) var(--ease-out);
  animation: gasPulse 3.2s ease-in-out infinite;
}

.gas-fill-large::before {
  content: "";
  position: absolute;
  left: -10%;
  right: -10%;
  top: -22px;
  height: 44px;
  border-radius: 50%;
  background: rgba(147, 197, 253, 0.7);
}

.gas-bubbles span {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  z-index: 3;
  bottom: 26%;
  animation: gasBubbleRise 3.4s ease-in-out infinite;
}

.gas-bubbles span:nth-child(1) { left: 28%; animation-delay: 0ms; }
.gas-bubbles span:nth-child(2) { left: 52%; animation-delay: 520ms; width: 13px; height: 13px; }
.gas-bubbles span:nth-child(3) { left: 68%; animation-delay: 1040ms; width: 22px; height: 22px; }
.gas-bubbles span:nth-child(4) { left: 38%; animation-delay: 1560ms; width: 11px; height: 11px; }

@keyframes gasPulse {
  0%, 100% {
    filter: saturate(1) brightness(1);
  }
  50% {
    filter: saturate(1.14) brightness(1.04);
  }
}

@keyframes gasBubbleRise {
  0% {
    opacity: 0;
    transform: translateY(60px) scale(0.68);
  }
  20% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translateY(-210px) scale(1.15);
  }
}

/* =========================================================
  Mass Percent / Composition Visuals
========================================================= */

.mass-percent-chart {
  width: min(680px, 100%);
  min-height: 430px;
  display: grid;
  grid-template-columns: 320px 1fr;
  align-items: center;
  gap: var(--space-8);
  padding: var(--space-6);
}

.composition-donut {
  width: 270px;
  height: 270px;
  position: relative;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: conic-gradient(var(--primary) 0 50%, var(--accent-purple) 50% 80%, var(--warning) 80% 100%);
  box-shadow: var(--shadow-xl), var(--shadow-glow-purple);
  animation: popIn 520ms var(--ease-bounce) both;
}

.composition-donut::before {
  content: "";
  width: 150px;
  height: 150px;
  position: absolute;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.composition-donut strong {
  position: relative;
  z-index: 1;
  color: var(--text-main);
  font-size: var(--text-4xl);
  line-height: 1;
}

.composition-bars-large {
  display: grid;
  gap: var(--space-4);
}

.composition-bar-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 82px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-sm);
}

.composition-symbol-large {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  color: var(--color-white);
  background: var(--gradient-primary);
  font-size: var(--text-xl);
  font-weight: 950;
}

.composition-bar-large-track {
  height: 18px;
  border-radius: var(--radius-full);
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.composition-bar-large-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--gradient-primary);
  transition: width 720ms var(--ease-out);
}

.composition-percent-value {
  color: var(--text-main);
  font-weight: 950;
  text-align: right;
}

.percent-molecule-preview {
  position: absolute;
  left: var(--space-8);
  bottom: var(--space-8);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-2xl);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow-md);
}

.percent-molecule-preview .mini-atom {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  color: var(--color-white);
  background: var(--primary);
  font-size: var(--text-xs);
  font-weight: 950;
}

/* =========================================================
  Generic Scientific Visual Helpers
========================================================= */

.science-caption {
  position: absolute;
  left: 50%;
  bottom: var(--space-5);
  transform: translateX(-50%);
  max-width: 72%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-full);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-sm);
  font-size: var(--text-sm);
  font-weight: 850;
  text-align: center;
}

.visual-value-card {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-4);
  border-radius: var(--radius-2xl);
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.74);
  box-shadow: var(--shadow-md);
  text-align: center;
}

.visual-value-card span {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 850;
}

.visual-value-card strong {
  color: var(--primary);
  font-size: var(--text-3xl);
  line-height: 1;
}

/* =========================================================
  Responsive Lock Friendly
========================================================= */

@media (max-width: 900px) {
  .molecule-structure {
    width: 620px;
    height: 420px;
  }

  .digital-scale {
    width: 420px;
    height: 360px;
  }

  .gas-cylinder-large {
    width: 260px;
    height: 430px;
  }

  .mass-percent-chart {
    grid-template-columns: 320px 1fr;
  }
}

@media (max-width: 520px) {
  .molecule-atom-H {
    width: 78px;
    height: 78px;
  }

  .molecule-atom-C,
  .molecule-atom-O,
  .molecule-atom-N,
  .molecule-atom-default {
    width: 108px;
    height: 108px;
  }
}
