/* ======================================================================
   PREMIUM FEATURES - 6 Luxury Interactions
   ======================================================================
   1. Luxury Number Wheels (KPI)
   2. Fault Beacon System
   3. Card-to-Detail Morph
   4. Thread Spool Time Scrubber
   5. Shift Atmosphere System
   6. Report Studio / Export Ritual
   ====================================================================== */

/* ======= 1. LUXURY NUMBER WHEELS ======= */
.kpi-wheel {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  height: 1.2em;
  line-height: 1.2em;
  vertical-align: bottom;
}

.kpi-wheel-digit {
  display: inline-block;
  height: 1.2em;
  overflow: hidden;
  position: relative;
}

.kpi-wheel-column {
  display: flex;
  flex-direction: column;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.kpi-wheel-column span {
  display: block;
  height: 1.2em;
  line-height: 1.2em;
  text-align: center;
  font-variant-numeric: tabular-nums lining-nums;
}

/* Separator chars like / , . rendered at full size inline */
.kpi-wheel-sep {
  display: inline-block;
  text-align: center;
  opacity: 0.7;
  font-weight: 600;
  padding: 0 0.05em;
  vertical-align: baseline;
}

.kpi-wheel-digit.kpi-wheel-enter {
  animation: kpiWheelReveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes kpiWheelReveal {
  0% { transform: translateY(40%); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}


/* ======= 2. FAULT BEACON SYSTEM ======= */
.node-card.fault-beacon {
  position: relative;
}

.node-card.fault-beacon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  animation: faultBeaconPulse 2.5s ease-in-out infinite;
  border: 1.5px solid transparent;
}

@keyframes faultBeaconPulse {
  0%, 100% {
    box-shadow: 0 0 6px 1px rgba(239, 68, 68, 0.08),
                inset 0 0 4px rgba(239, 68, 68, 0.03);
    border-color: rgba(239, 68, 68, 0.08);
  }
  50% {
    box-shadow: 0 0 22px 6px rgba(239, 68, 68, 0.14),
                inset 0 0 10px rgba(239, 68, 68, 0.06);
    border-color: rgba(239, 68, 68, 0.2);
  }
}

.node-card.watch-beacon::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  animation: watchBeaconPulse 3s ease-in-out infinite;
  border: 1px solid transparent;
}

@keyframes watchBeaconPulse {
  0%, 100% {
    box-shadow: 0 0 4px 1px rgba(245, 158, 11, 0.06);
    border-color: rgba(245, 158, 11, 0.06);
  }
  50% {
    box-shadow: 0 0 16px 4px rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.14);
  }
}

/* Alert beacon capsule */
.fault-beacon-capsule {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(30, 10, 10, 0.95), rgba(40, 12, 12, 0.92));
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 16px;
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4),
              0 0 30px rgba(239, 68, 68, 0.08),
              inset 0 1px 0 rgba(255, 255, 255, 0.04);
  animation: beaconCapsuleIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: auto;
  cursor: pointer;
  max-width: 320px;
}

.fault-beacon-capsule.dismissing {
  animation: beaconCapsuleOut 0.35s cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

@keyframes beaconCapsuleIn {
  0% { transform: translateX(120%) scale(0.9); opacity: 0; }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes beaconCapsuleOut {
  0% { transform: translateX(0) scale(1); opacity: 1; }
  100% { transform: translateX(120%) scale(0.85); opacity: 0; }
}

.fault-beacon-capsule .beacon-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
  animation: beaconDotPulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes beaconDotPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
}

.fault-beacon-capsule .beacon-text {
  font-size: 12px;
  font-weight: 600;
  color: #fca5a5;
  line-height: 1.4;
}

.fault-beacon-capsule .beacon-text small {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: rgba(252, 165, 165, 0.6);
  margin-top: 1px;
}

/* Light mode beacon capsule */
html:not(.dark) .fault-beacon-capsule {
  background: linear-gradient(135deg, rgba(254, 226, 226, 0.97), rgba(254, 202, 202, 0.95));
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 20px rgba(239, 68, 68, 0.06);
}
html:not(.dark) .fault-beacon-capsule .beacon-text { color: #b91c1c; }
html:not(.dark) .fault-beacon-capsule .beacon-text small { color: rgba(185, 28, 28, 0.6); }


/* ======= 3. CARD-TO-DETAIL MORPH ======= */
.morph-overlay {
  position: fixed;
  z-index: 250;
  pointer-events: none;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.95), rgba(10, 18, 32, 0.92));
  border: 1px solid rgba(57, 200, 255, 0.15);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04),
              0 20px 60px rgba(0, 0, 0, 0.5),
              0 0 40px rgba(57, 200, 255, 0.06);
  overflow: hidden;
  will-change: transform, width, height, opacity;
}

.morph-overlay.morph-expanding {
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    width 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    height 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.2s ease;
}

.morph-overlay-content {
  padding: 16px;
  opacity: 0.9;
}

.morph-overlay-content .morph-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--lux-accent, #39c8ff);
  margin-bottom: 4px;
}

.morph-overlay-content .morph-status {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.6;
}

/* Light mode morph */
html:not(.dark) .morph-overlay {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.95));
  border-color: rgba(37, 99, 235, 0.15);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 40px rgba(37, 99, 235, 0.06);
}


/* ======= 4. THREAD SPOOL TIME SCRUBBER ======= */
.spool-scrubber {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  user-select: none;
  -webkit-user-select: none;
}

.spool-body {
  position: relative;
  width: 100%;
  height: 36px;
  cursor: pointer;
}

.spool-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 3px;
  transform: translateY(-50%);
}

.spool-track-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, rgba(57, 200, 255, 0.15), rgba(57, 200, 255, 0.5));
  border-radius: 3px;
  transition: width 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 8px rgba(57, 200, 255, 0.15);
}

.spool-handle {
  position: absolute;
  top: 50%;
  width: 20px;
  height: 20px;
  background: radial-gradient(circle at 40% 35%, #fff 0%, #d0e8ff 30%, #39c8ff 70%, #0284c7 100%);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: grab;
  box-shadow: 0 2px 10px rgba(57, 200, 255, 0.3),
              0 0 20px rgba(57, 200, 255, 0.1),
              inset 0 1px 2px rgba(255, 255, 255, 0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 2;
}

.spool-handle:hover {
  transform: translate(-50%, -50%) scale(1.15);
  box-shadow: 0 2px 14px rgba(57, 200, 255, 0.4),
              0 0 30px rgba(57, 200, 255, 0.15),
              inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.spool-handle:active,
.spool-handle.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 2px 18px rgba(57, 200, 255, 0.5),
              0 0 40px rgba(57, 200, 255, 0.2),
              inset 0 1px 2px rgba(255, 255, 255, 0.5);
}

.spool-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.3s ease, transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.spool-icon.spinning {
  animation: spoolSpin 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes spoolSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spool-ticks {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.spool-tick {
  position: absolute;
  top: 50%;
  width: 1px;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-50%);
  transition: background 0.2s ease;
}

.spool-tick.active {
  background: rgba(57, 200, 255, 0.4);
  height: 12px;
}

.spool-tick-label {
  position: absolute;
  top: calc(50% + 12px);
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(148, 163, 184, 0.4);
  transform: translateX(-50%);
  transition: color 0.2s ease;
  white-space: nowrap;
}

.spool-tick-label.active {
  color: rgba(57, 200, 255, 0.8);
}

.spool-range-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--lux-accent, #39c8ff);
  letter-spacing: 0.04em;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}


/* ======= 5. SHIFT ATMOSPHERE SYSTEM ======= */
:root {
  --atm-tint: transparent;
  --atm-intensity: 0;
}

.shift-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: var(--atm-tint);
  opacity: var(--atm-intensity);
  transition: background 8s ease, opacity 8s ease;
  mix-blend-mode: soft-light;
}


/* ======= 6. REPORT STUDIO / EXPORT RITUAL ======= */
.report-studio-overlay {
  position: fixed;
  inset: 0;
  z-index: 350;
  background: rgba(4, 8, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease;
}

.report-studio-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.report-studio-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(57, 200, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(57, 200, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0;
  animation: blueprintReveal 0.8s ease 0.1s forwards;
}

@keyframes blueprintReveal {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

.report-studio-pages {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  perspective: 800px;
}

.report-studio-page {
  width: 120px;
  height: 160px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(30px) rotateX(-15deg);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.report-studio-page.assembled {
  animation: pageAssemble 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pageAssemble {
  0% { opacity: 0; transform: translateY(30px) rotateX(-15deg) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) rotateX(0) scale(1); }
}

.report-studio-page-lines {
  width: 70%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.report-studio-page-line {
  height: 3px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 2px;
}

.report-studio-page-line:nth-child(1) { width: 60%; }
.report-studio-page-line:nth-child(2) { width: 90%; }
.report-studio-page-line:nth-child(3) { width: 75%; }
.report-studio-page-line:nth-child(4) { width: 45%; }
.report-studio-page-line:nth-child(5) { width: 85%; }

.report-studio-status {
  position: relative;
  z-index: 1;
  margin-top: 32px;
  text-align: center;
}

.report-studio-title {
  font-size: 16px;
  font-weight: 700;
  color: rgba(226, 232, 240, 0.9);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.report-studio-sub {
  font-size: 11px;
  color: rgba(148, 163, 184, 0.4);
  letter-spacing: 0.04em;
}

.report-studio-progress {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 3px;
  margin-top: 20px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.report-studio-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--lux-accent, #39c8ff), #22d3ee);
  border-radius: 3px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 0 10px rgba(57, 200, 255, 0.3);
}

.report-studio-seal {
  position: relative;
  z-index: 1;
  margin-top: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(57, 200, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5) rotate(-20deg);
}

.report-studio-seal.stamped {
  animation: sealStamp 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes sealStamp {
  0% { opacity: 0; transform: scale(2) rotate(-20deg); }
  50% { opacity: 1; transform: scale(0.9) rotate(5deg); }
  100% { opacity: 1; transform: scale(1) rotate(0deg); }
}

.report-studio-seal svg {
  width: 28px;
  height: 28px;
  color: var(--lux-accent, #39c8ff);
}

.report-studio-overlay.complete .report-studio-title {
  color: var(--lux-accent, #39c8ff);
}

.report-studio-close {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 2;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: rgba(148, 163, 184, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
}

.report-studio-close:hover {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(226, 232, 240, 0.8);
}

/* Light mode report studio */
html:not(.dark) .report-studio-overlay {
  background: rgba(248, 250, 252, 0.95);
}
html:not(.dark) .report-studio-title { color: #1e293b; }
html:not(.dark) .report-studio-sub { color: #64748b; }
html:not(.dark) .report-studio-page {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(241,245,249,0.8));
  border-color: rgba(0,0,0,0.08);
}
html:not(.dark) .report-studio-grid {
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.03) 1px, transparent 1px);
}


/* ======= PENCIL RENAME ICON ======= */
.nc-rename-pencil {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: rgba(148, 163, 184, 0.4);
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-left: 4px;
  padding: 0;
  vertical-align: middle;
}
.nc-rename-pencil:hover {
  color: var(--lux-accent, #39c8ff);
  background: rgba(57, 200, 255, 0.08);
}
html:not(.dark) .nc-rename-pencil:hover {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
}


/* ======= UNIFIED MODAL STYLING ======= */
.acxa-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.acxa-modal-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Consistent modal card */
.premium-modal,
#nodeExportModal .bg-surface-800\/80,
#nodeExportModal > div > div,
.report-modal-content,
[id$="Modal"] .bg-surface-800,
[id$="Modal"] .bg-surface-800\/80 {
  background: linear-gradient(165deg, rgba(14, 20, 32, 0.97), rgba(10, 16, 26, 0.96)) !important;
  border: 1px solid rgba(57, 200, 255, 0.1) !important;
  border-radius: 20px !important;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.5),
              0 0 60px rgba(57, 200, 255, 0.04),
              inset 0 1px 0 rgba(255, 255, 255, 0.05) !important;
  backdrop-filter: blur(24px) saturate(1.3) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.3) !important;
}

html:not(.dark) .premium-modal,
html:not(.dark) #nodeExportModal .bg-surface-800\/80,
html:not(.dark) #nodeExportModal > div > div,
html:not(.dark) .report-modal-content,
html:not(.dark) [id$="Modal"] .bg-surface-800,
html:not(.dark) [id$="Modal"] .bg-surface-800\/80 {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.97)) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.15),
              inset 0 1px 0 rgba(255, 255, 255, 0.9) !important;
}

/* Consistent modal backdrop */
#nodeExportModal,
[id$="Modal"][style*="display: block"],
[id$="Modal"][style*="display:block"] {
  background: rgba(4, 8, 16, 0.6) !important;
  backdrop-filter: blur(6px) !important;
  -webkit-backdrop-filter: blur(6px) !important;
}

html:not(.dark) #nodeExportModal,
html:not(.dark) [id$="Modal"][style*="display: block"],
html:not(.dark) [id$="Modal"][style*="display:block"] {
  background: rgba(15, 23, 42, 0.4) !important;
}
