/* Riposante — cielo profondo, nebulose e stelle */

.rest-space {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(180deg, #03050c 0%, #060a16 35%, #0a1020 68%, #0e1428 100%);
}

html[data-theme="rest"] .rest-space { display: block; }
html[data-theme="rest"] body { background: transparent !important; }
html[data-theme="rest"] #market-bg { opacity: 1; }

/* Cielo profondo */
.rest-deep {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 50% 110%, rgba(20, 30, 70, 0.5), transparent 55%),
    radial-gradient(ellipse 90% 60% at 50% -20%, rgba(30, 40, 90, 0.25), transparent 50%);
}

/* Nebulose lente */
.rest-nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  animation: rest-nebula-drift 90s ease-in-out infinite alternate;
}
.rest-nebula-a {
  width: 70vw;
  height: 50vh;
  top: 8%;
  left: -10%;
  background: radial-gradient(ellipse, rgba(100, 70, 180, 0.35) 0%, rgba(60, 40, 140, 0.12) 45%, transparent 70%);
  animation-duration: 110s;
}
.rest-nebula-b {
  width: 55vw;
  height: 45vh;
  top: 35%;
  right: -8%;
  background: radial-gradient(ellipse, rgba(50, 120, 200, 0.28) 0%, rgba(30, 80, 160, 0.1) 50%, transparent 72%);
  animation-duration: 85s;
  animation-direction: alternate-reverse;
}
.rest-nebula-c {
  width: 45vw;
  height: 35vh;
  bottom: 15%;
  left: 25%;
  background: radial-gradient(ellipse, rgba(140, 100, 200, 0.2) 0%, rgba(80, 60, 160, 0.08) 55%, transparent 75%);
  animation-duration: 70s;
}

/* Campi stellari statici (CSS) */
.rest-stars {
  position: absolute;
  inset: 0;
  background-repeat: repeat;
}
.rest-stars-far {
  background-image:
    radial-gradient(1px 1px at 10% 15%, rgba(220, 230, 255, 0.5), transparent),
    radial-gradient(1px 1px at 25% 42%, rgba(200, 210, 240, 0.4), transparent),
    radial-gradient(1px 1px at 38% 8%, rgba(230, 235, 255, 0.45), transparent),
    radial-gradient(1px 1px at 52% 68%, rgba(210, 220, 250, 0.35), transparent),
    radial-gradient(1px 1px at 68% 22%, rgba(220, 230, 255, 0.4), transparent),
    radial-gradient(1px 1px at 82% 55%, rgba(200, 215, 245, 0.35), transparent),
    radial-gradient(1px 1px at 92% 12%, rgba(230, 235, 255, 0.45), transparent),
    radial-gradient(1px 1px at 15% 78%, rgba(210, 220, 250, 0.3), transparent),
    radial-gradient(1px 1px at 45% 88%, rgba(220, 230, 255, 0.35), transparent),
    radial-gradient(1px 1px at 72% 82%, rgba(200, 210, 240, 0.3), transparent);
  background-size: 280px 220px;
  opacity: 0.7;
}
.rest-stars-mid {
  background-image:
    radial-gradient(1.5px 1.5px at 18% 28%, rgba(240, 245, 255, 0.7), transparent),
    radial-gradient(1.5px 1.5px at 42% 18%, rgba(230, 240, 255, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 58% 48%, rgba(245, 248, 255, 0.65), transparent),
    radial-gradient(1.5px 1.5px at 75% 35%, rgba(235, 240, 255, 0.55), transparent),
    radial-gradient(1.5px 1.5px at 88% 72%, rgba(240, 245, 255, 0.6), transparent),
    radial-gradient(1.5px 1.5px at 32% 62%, rgba(230, 240, 255, 0.5), transparent),
    radial-gradient(1.5px 1.5px at 8% 52%, rgba(245, 248, 255, 0.55), transparent);
  background-size: 340px 280px;
  opacity: 0.85;
  animation: rest-stars-twinkle 8s ease-in-out infinite alternate;
}
.rest-stars-near {
  background-image:
    radial-gradient(2px 2px at 22% 38%, rgba(255, 255, 255, 0.85), transparent),
    radial-gradient(2px 2px at 55% 25%, rgba(255, 252, 245, 0.75), transparent),
    radial-gradient(2px 2px at 78% 58%, rgba(255, 255, 255, 0.8), transparent),
    radial-gradient(2px 2px at 35% 72%, rgba(255, 252, 245, 0.7), transparent),
    radial-gradient(2px 2px at 65% 85%, rgba(255, 255, 255, 0.75), transparent);
  background-size: 420px 360px;
  opacity: 0.9;
  animation: rest-stars-twinkle 5s ease-in-out infinite alternate-reverse;
}

/* Alone morbido */
.rest-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(120, 140, 220, 0.08), transparent 60%),
    radial-gradient(ellipse 80% 50% at 50% 100%, rgba(60, 80, 160, 0.06), transparent 55%);
  animation: rest-glow-pulse 45s ease-in-out infinite alternate;
}

@keyframes rest-nebula-drift {
  0% { transform: translate(0, 0) scale(1); opacity: 0.5; }
  50% { transform: translate(2%, -1.5%) scale(1.04); opacity: 0.62; }
  100% { transform: translate(-1.5%, 2%) scale(0.98); opacity: 0.52; }
}
@keyframes rest-stars-twinkle {
  0% { opacity: 0.75; }
  100% { opacity: 1; }
}
@keyframes rest-glow-pulse {
  0% { opacity: 0.85; }
  100% { opacity: 1; }
}

/* ── UI vetro scuro su spazio ── */
html[data-theme="rest"] .borsa-access-gate,
html[data-theme="rest"] .illogico-section,
html[data-theme="rest"] .section,
html[data-theme="rest"] .illogico-hero {
  background: transparent !important;
  border-bottom-color: rgba(140, 160, 220, 0.1);
}
html[data-theme="rest"] .market-vignette {
  background:
    radial-gradient(ellipse 70% 50% at 50% 15%, rgba(100, 120, 200, 0.1), transparent 60%),
    radial-gradient(ellipse 80% 45% at 50% 90%, rgba(60, 80, 160, 0.08), transparent 55%);
}
html[data-theme="rest"] .illogico-hero-glow {
  background: radial-gradient(ellipse 55% 45% at 50% 30%, rgba(140, 160, 240, 0.15), transparent 70%);
}
html[data-theme="rest"] .illogico-hero-title {
  background: linear-gradient(135deg, #e8ecf8 0%, #a8c0f0 45%, #c4a0f0 100%);
  -webkit-background-clip: text;
  background-clip: text;
  filter: drop-shadow(0 0 24px rgba(140, 160, 240, 0.2));
}
html[data-theme="rest"] .logo { color: #a8c0f0; }
html[data-theme="rest"] .logo b { color: #c4a0f0; }

html[data-theme="rest"] .card-3d,
html[data-theme="rest"] .glass,
html[data-theme="rest"] .illogico-drawer,
html[data-theme="rest"] .fav-card,
html[data-theme="rest"] .borsa-access-card,
html[data-theme="rest"] .landing-scan-bar,
html[data-theme="rest"] .help-dialog {
  border-color: rgba(140, 160, 220, 0.22);
  box-shadow:
    0 12px 40px rgba(4, 8, 24, 0.4),
    inset 0 1px 0 rgba(180, 195, 240, 0.12);
}
html[data-theme="rest"] .card-3d::before,
html[data-theme="rest"] .glass::before {
  background: linear-gradient(
    145deg,
    rgba(180, 195, 240, 0.08) 0%,
    rgba(100, 120, 200, 0.04) 40%,
    transparent 68%
  );
}

html[data-theme="rest"] .theme-switch-btn.is-on {
  background: linear-gradient(145deg, #9ab8f0, #7a9ad8);
  color: #0c1020;
  box-shadow: 0 4px 16px rgba(120, 150, 220, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

html[data-theme="rest"] .ticker-chip {
  background: rgba(28, 34, 62, 0.58);
  border-color: rgba(140, 160, 220, 0.25);
  box-shadow: inset 0 1px 0 rgba(180, 195, 240, 0.1), 0 3px 12px rgba(4, 8, 24, 0.3);
}
html[data-theme="rest"] .ticker-chip-name { color: var(--muted); }

/* Zone scure → vetro spaziale */
html[data-theme="rest"] .illogico-viz,
html[data-theme="rest"] .illogico-viz-hero,
html[data-theme="rest"] .illogico-radar,
html[data-theme="rest"] .illogico-detail,
html[data-theme="rest"] .som-loading-overlay,
html[data-theme="rest"] .viz-tooltip {
  background: rgba(28, 34, 62, 0.55) !important;
  border-color: rgba(140, 160, 220, 0.2) !important;
  box-shadow: 0 8px 32px rgba(4, 8, 24, 0.4) !important;
}
html[data-theme="rest"] .illogico-viz-hero {
  box-shadow: 0 12px 44px rgba(4, 8, 24, 0.45) !important;
}
html[data-theme="rest"] .som-legend-rail {
  background: rgba(24, 30, 56, 0.65) !important;
  border-color: rgba(140, 160, 220, 0.18) !important;
  box-shadow: 0 4px 16px rgba(4, 8, 24, 0.35) !important;
}
html[data-theme="rest"] .som-scan-info,
html[data-theme="rest"] .som-scan-kpi,
html[data-theme="rest"] .som-scan-block,
html[data-theme="rest"] .som-guide-panel {
  background: rgba(28, 34, 62, 0.5) !important;
  border-color: rgba(140, 160, 220, 0.16) !important;
}
html[data-theme="rest"] details[open] > .drawer-sum {
  background: linear-gradient(90deg, color-mix(in srgb, var(--ds-a) 10%, transparent), rgba(28, 34, 62, 0.58)) !important;
}
html[data-theme="rest"] .drawer-sum {
  background: linear-gradient(90deg, color-mix(in srgb, var(--ds-a) 8%, transparent), rgba(24, 30, 56, 0.48)) !important;
}
html[data-theme="rest"] .illogico-drawer-body {
  background: rgba(20, 26, 48, 0.45) !important;
}
html[data-theme="rest"] .help-fab {
  background: linear-gradient(145deg, rgba(40, 50, 90, 0.7), rgba(28, 34, 62, 0.8)) !important;
  border-color: rgba(140, 160, 220, 0.25) !important;
  color: #a8c0f0 !important;
  box-shadow: 0 6px 20px rgba(4, 8, 24, 0.4) !important;
}
html[data-theme="rest"] .help-backdrop {
  background: rgba(4, 8, 20, 0.55) !important;
}
html[data-theme="rest"] .footer {
  background: rgba(18, 22, 42, 0.5);
  backdrop-filter: blur(16px);
  border-top-color: rgba(140, 160, 220, 0.12);
}
html[data-theme="rest"] .news-section,
html[data-theme="rest"] .hub-section,
html[data-theme="rest"] .modules-section {
  background: transparent;
}
html[data-theme="rest"] .fav-mini-chart,
html[data-theme="rest"] .fav-tbl-chart {
  background: rgba(20, 26, 48, 0.45);
  border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {
  .rest-nebula,
  .rest-stars-mid,
  .rest-stars-near,
  .rest-glow { animation: none !important; }
}