/* ==========================================================================
   Inspection Modal Overlay & Split-View Data Panel (Milestone M4)
   ========================================================================== */

:root {
  --modal-cat-color: #38bdf8;
  --modal-cat-glow: rgba(56, 189, 248, 0.4);
}

#modal-inspection,
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.26s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.26s;
}

#modal-inspection.hidden,
.modal-overlay.hidden {
  display: none !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
}

.modal-container {
  position: relative;
  z-index: 2;
  width: 90vw;
  max-width: 1040px;
  height: 82vh;
  max-height: 680px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75), 0 0 35px var(--modal-cat-glow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(1) translateY(0);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease;
}

#modal-inspection.open .modal-container,
.modal-overlay.open .modal-container {
  animation: modalEnter 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(14px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Close Button */
.modal-close {
  position: absolute;
  top: 16px;
  right: 18px;
  width: 38px;
  height: 38px;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #ffffff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.2s ease;
  outline: none;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: rgba(239, 68, 68, 0.85);
  border-color: #ef4444;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.5);
  transform: scale(1.08);
}

/* Split-View Body */
.modal-body {
  display: flex;
  width: 100%;
  height: 100%;
}

/* Left Column: 3D Atomic Model Viewport */
.modal-atom-view {
  flex: 1.25;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.6) 0%, rgba(11, 15, 25, 0.98) 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

#atom-canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  outline: none;
  cursor: grab;
}

#atom-canvas:active {
  cursor: grabbing;
}

/* HUD Controls Overlay on 3D Viewport */
.atom-hud-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 30px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  z-index: 5;
  user-select: none;
}

.hud-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  outline: none;
}

.hud-btn:hover,
.hud-btn:focus-visible {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.hud-btn.active,
.hud-btn[aria-pressed="true"] {
  background: var(--modal-cat-color, #38bdf8);
  color: #0b0f19;
  border-color: var(--modal-cat-color, #38bdf8);
  box-shadow: 0 0 12px var(--modal-cat-glow);
}

.hud-btn-group {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 16px;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.hud-btn-group .hud-btn {
  border: none;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
}

/* Right Column: Scientific Property Data Sheet */
.modal-data-sheet {
  flex: 1;
  padding: 30px 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.modal-data-sheet::-webkit-scrollbar {
  width: 6px;
}
.modal-data-sheet::-webkit-scrollbar-track {
  background: transparent;
}
.modal-data-sheet::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Data Header */
.data-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding-bottom: 14px;
}

.atom-number {
  font-size: 22px;
  font-weight: 700;
  color: var(--modal-cat-color, #38bdf8);
}

.atom-symbol {
  font-size: 38px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
}

.atom-name {
  font-size: 24px;
  font-weight: 600;
  color: #f8fafc;
  margin: 0;
}

/* Data Grid Rows */
.data-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(30, 41, 59, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 13px;
}

.data-row .label {
  color: #94a3b8;
  font-weight: 500;
}

.data-row .value {
  font-weight: 600;
  color: #ffffff;
}

.data-row .font-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: #38bdf8;
}

/* State & Category Badges */
.badge-state {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-state.state-gas {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-state.state-liquid {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}

.badge-state.state-solid {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.badge-state.state-unknown {
  background: rgba(148, 163, 184, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Shell Breakdown Section */
.shell-breakdown {
  margin-top: 4px;
}

.shell-title {
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.shell-bars-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Interactive Shell Progress Bars */
.shell-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  outline: none;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.shell-bar:hover,
.shell-bar:focus-visible,
.shell-bar.active-shell {
  background: rgba(56, 189, 248, 0.14);
  border-color: var(--modal-cat-color, #38bdf8);
  box-shadow: 0 0 12px var(--modal-cat-glow);
  transform: translateX(4px);
}

.shell-label {
  width: 58px;
  font-weight: 500;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.shell-bar:hover .shell-label,
.shell-bar:focus-visible .shell-label,
.shell-bar.active-shell .shell-label {
  color: #ffffff;
  font-weight: 700;
}

.shell-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.shell-fill {
  height: 100%;
  background: var(--modal-cat-color, #38bdf8);
  border-radius: 4px;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.shell-bar:hover .shell-fill,
.shell-bar:focus-visible .shell-fill,
.shell-bar.active-shell .shell-fill {
  box-shadow: 0 0 8px var(--modal-cat-color, #38bdf8);
  filter: brightness(1.25);
}

.shell-count {
  width: 28px;
  text-align: right;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 700;
  color: #ffffff;
}

/* Responsive Stacking (< 860px or portrait orientation) */
@media (max-width: 860px) {
  .modal-container {
    width: 95vw;
    height: 90vh;
    max-height: none;
  }

  .modal-body {
    flex-direction: column;
  }

  .modal-atom-view {
    flex: 1;
    min-height: 280px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }

  .modal-data-sheet {
    flex: 1.2;
    padding: 20px;
  }

  .atom-hud-controls {
    bottom: 12px;
    padding: 4px 10px;
    gap: 8px;
  }
}

/* Layout Switcher HUD Compact Layout: avoids obscuring Actinide row elements (e.g. Uranium Z=92) */
.bottom-controls {
  bottom: 8px !important;
}

.bottom-controls .layout-btn-group {
  padding: 3px 6px !important;
  gap: 6px !important;
}

.bottom-controls .layout-btn {
  padding: 4px 10px !important;
  font-size: 11px !important;
}

