/* ==========================================================================
   THE WISE GUY · Hero Launch Suite & 5x3 Interactive Engine (Dark / Light 1:1)
   Supports 4 Live Modes: fusione | mission | ascensore | porte
   ========================================================================== */

:root,
:root[data-theme="dark"] {
  --hl-hud-bg: rgba(9, 12, 24, 0.84);
  --hl-hud-border: rgba(34, 211, 238, 0.34);
  --hl-hud-fg: #F8FAFC;
  --hl-hud-muted: #94A3B8;
  --hl-pill-bg: rgba(168, 85, 247, 0.16);
  --hl-pill-border: rgba(168, 85, 247, 0.48);
  --hl-plant-bg: #0B0816;
  --hl-plant-room: rgba(20, 15, 36, 0.92);
  --hl-plant-grid: rgba(255, 255, 255, 0.045);
  --hl-devbar-bg: rgba(10, 8, 20, 0.92);
}

:root[data-theme="light"] {
  --hl-hud-bg: rgba(255, 255, 255, 0.94);
  --hl-hud-border: rgba(14, 116, 144, 0.36);
  --hl-hud-fg: #0F172A;
  --hl-hud-muted: #475569;
  --hl-pill-bg: rgba(109, 40, 217, 0.09);
  --hl-pill-border: rgba(109, 40, 217, 0.38);
  --hl-plant-bg: #F8FAFC;
  --hl-plant-room: #FFFFFF;
  --hl-plant-grid: rgba(15, 23, 42, 0.055);
  --hl-devbar-bg: rgba(255, 255, 255, 0.95);
}

/* Mode visibility controller */
.hl-mode-panel { display: none; position: relative; z-index: 4; }
.hero-stage[data-hero-mode="fusione"] .hl-mode-fusione,
.hero-stage[data-hero-mode="mission"] .hl-mode-mission,
.hero-stage[data-hero-mode="ascensore"] .hl-mode-ascensore { display: block; width: 100%; }
.hero-stage:not([data-hero-mode="porte"]) .hl-legacy-doors-grid { display: none !important; }
.hero-stage:not([data-hero-mode="porte"]) { padding-top: 104px; padding-bottom: 48px; min-height: calc(100dvh - 10px); display: flex; align-items: center; }

/* ── 1. FUSIONE: Self-Identifying Mad-Libs H1 + Dual-Video X-Ray Stage ── */
.hl-fusione-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, 1.12fr);
  gap: 34px;
  align-items: center;
}
.hl-madlibs-box {
  margin: 14px 0 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-card);
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--fg-secondary);
}
.hl-select-wrap {
  display: inline-flex;
  align-items: center;
  position: relative;
  margin: 2px 3px;
  vertical-align: baseline;
  max-width: 100%;
  min-width: 0;
}
.hl-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--hl-pill-bg);
  color: var(--fg-primary);
  border: 1px solid var(--hl-pill-border);
  border-radius: 9px;
  padding: 3px 26px 3px 10px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  cursor: pointer;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s, background-color 0.2s;
}
.hl-select:hover, .hl-select:focus-visible {
  border-color: var(--accent-cyan);
  outline: none;
}
.hl-select-caret {
  position: absolute;
  right: 8px;
  pointer-events: none;
  font-size: 11px;
  color: var(--accent-violet);
}
.hl-power-h1 {
  margin: 0 0 12px;
  font-size: clamp(1.85rem, 3.1vw, 2.75rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.03em;
  color: var(--fg-primary);
}
.hl-entry-card {
  margin: 14px 0 18px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent-emerald);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}
.hl-entry-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-emerald);
}
.hl-entry-title {
  margin: 4px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--fg-primary);
}
.hl-entry-desc {
  margin: 0;
  font-size: 13.5px;
  color: var(--fg-secondary);
  line-height: 1.5;
}

/* X-Ray Dual Video Stage */
.hl-xray-wrap { display: flex; flex-direction: column; gap: 10px; }
.hl-xray-viewport {
  position: relative;
  aspect-ratio: 16 / 9.4;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-elevated);
  background: #070A14;
  user-select: none;
  touch-action: pan-y;
  --xray-pct: 46%;
}
.hl-video-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hl-video-layer video, .hl-video-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.hl-layer-after {
  clip-path: inset(0 0 0 var(--xray-pct));
}
.hl-hud-corner {
  position: absolute;
  top: 12px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--hl-hud-bg);
  border: 1px solid var(--hl-hud-border);
  color: var(--hl-hud-fg);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  backdrop-filter: blur(10px);
  z-index: 5;
}
.hl-hud-corner--left { left: 12px; border-color: rgba(245, 158, 11, 0.55); }
.hl-hud-corner--right { right: 12px; border-color: var(--hl-hud-border); }
.hl-hud-bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}
.hl-chip-group { display: flex; flex-wrap: wrap; gap: 6px; max-width: 47%; }
.hl-hud-chip {
  padding: 4px 9px;
  border-radius: 7px;
  background: var(--hl-hud-bg);
  border: 1px solid var(--border-medium);
  color: var(--hl-hud-fg);
  font-size: 11px;
  font-weight: 600;
  backdrop-filter: blur(8px);
}
.hl-hud-chip--warn { border-color: rgba(245, 158, 11, 0.5); }
.hl-hud-chip--ok { border-color: rgba(16, 185, 129, 0.55); }

/* Draggable Laser Blade */
.hl-xray-beam {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--xray-pct);
  width: 3px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #A855F7 0%, #22D3EE 50%, #10B981 100%);
  box-shadow: 0 0 22px 3px rgba(34, 211, 238, 0.72);
  z-index: 6;
  pointer-events: none;
}
.hl-xray-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: var(--hl-hud-bg);
  border: 2px solid #22D3EE;
  color: var(--hl-hud-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.hl-xray-beam-tag {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--hl-hud-bg);
  border: 1px solid var(--hl-hud-border);
  color: var(--accent-cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.hl-xray-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 7;
  margin: 0;
}
.hl-sector-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}
.hl-sector-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.hl-sec-pill {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-medium);
  background: var(--bg-card);
  color: var(--fg-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
}
.hl-sec-pill.is-active, .hl-sec-pill:hover {
  border-color: var(--accent-cyan);
  background: var(--accent-cyan-soft);
  color: var(--fg-primary);
}

/* ── 2. MISSION CONTROL & 3. ASCENSORE HERO STAGES ── */
.hl-deck-card {
  border-radius: 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  box-shadow: var(--shadow-elevated);
  padding: 22px;
}
.hl-act-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}
.hl-act-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  cursor: pointer;
  transition: all 0.18s;
}
.hl-act-btn.is-active {
  border-color: var(--accent-cyan);
  background: var(--accent-cyan-soft);
  color: var(--fg-primary);
}
.hl-mission-body, .hl-ascensore-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 22px;
  align-items: center;
}
.hl-tg-phone {
  border-radius: 18px;
  padding: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-card);
}
.hl-tg-approve-btn {
  width: 100%;
  margin-top: 12px;
  padding: 11px 16px;
  border-radius: 11px;
  border: 1px solid var(--accent-emerald);
  background: var(--accent-emerald-soft);
  color: var(--fg-primary);
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.18s;
}
.hl-tg-approve-btn:hover, .hl-tg-approve-btn.is-approved {
  background: #10B981;
  color: #04130D;
}
.hl-floor-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--fg-secondary);
  cursor: pointer;
  text-align: left;
}
.hl-floor-btn.is-active {
  border-color: var(--accent-violet);
  background: var(--accent-violet-soft);
  color: var(--fg-primary);
}

/* ── 4. INTERACTIVE ENGINE SECTION (#dalla-radiografia-al-cielo) ── */
.hl-engine-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 26px;
  margin-top: 28px;
  align-items: start;
}
.twg-plant-svg { width: 100%; height: auto; display: block; }
.twg-plant-board { fill: var(--hl-plant-bg); stroke: var(--border-medium); stroke-width: 1.2; }
.twg-plant-gridline { stroke: var(--hl-plant-grid); stroke-width: 1; }
.twg-plant-toplabel { fill: var(--fg-muted); font-size: 10.5px; font-weight: 700; letter-spacing: 0.1em; font-family: var(--font-mono); }
.twg-plant-room-box { fill: var(--hl-plant-room); stroke-width: 1.4; }
.twg-plant-room-code { fill: var(--fg-primary); font-size: 11px; font-weight: 800; letter-spacing: 0.06em; font-family: var(--font-mono); }
.twg-plant-room-sub { fill: var(--fg-secondary); font-size: 11.5px; font-weight: 500; }
.twg-plant-pill { fill: var(--bg-subtle); stroke: var(--border-subtle); }
.twg-plant-pill-txt { font-size: 10px; font-weight: 700; font-family: var(--font-mono); }
.twg-plant-centerbadge { fill: var(--hl-hud-bg); stroke-width: 1.5; }
.twg-plant-centertxt, .twg-plant-brandtxt { font-size: 10px; font-weight: 800; letter-spacing: 0.07em; font-family: var(--font-mono); }
@keyframes twgScanSweep { 0%, 100% { transform: translateX(-160px); } 50% { transform: translateX(160px); } }
.twg-plant-laser { animation: twgScanSweep 4.2s ease-in-out infinite; }

.hl-size-tabs { display: inline-flex; gap: 6px; padding: 4px; border-radius: 12px; background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.hl-size-tab { padding: 7px 13px; border-radius: 9px; border: 0; background: transparent; color: var(--fg-secondary); font-size: 12.5px; font-weight: 700; cursor: pointer; }
.hl-size-tab.is-active { background: var(--cta-bg); color: var(--cta-fg); }

.hl-mod-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.hl-mod-card { padding: 9px 11px; border-radius: 10px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hl-lvl-badge { padding: 2px 7px; border-radius: 6px; font-size: 10.5px; font-weight: 700; background: var(--accent-violet-soft); color: var(--accent-violet); flex-shrink: 0; }

/* Real 84-Module Stacked Bar Chart */
.hl-chart-card { margin-top: 30px; padding: 22px; border-radius: 20px; background: var(--bg-card); border: 1px solid var(--border-medium); }
.hl-bar-row { display: grid; grid-template-columns: 210px minmax(0, 1fr) 44px; gap: 12px; align-items: center; padding: 7px 8px; border-radius: 10px; cursor: pointer; transition: background 0.15s; }
.hl-bar-row:hover, .hl-bar-row.is-active { background: var(--bg-subtle); }
.hl-bar-track { height: 14px; border-radius: 999px; background: var(--bg-subtle); overflow: hidden; display: flex; }
.hl-seg-L1 { background: #10B981; }
.hl-seg-L2 { background: #22D3EE; }
.hl-seg-L3 { background: #A855F7; }
.hl-seg-L4 { background: #F59E0B; }

/* DEV Director Switcher Bar (v2-dev only, avoids bottom-right Alfred launcher) */
.hl-dev-bar {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  max-width: calc(100vw - 230px);
  border-radius: 14px;
  background: var(--hl-devbar-bg);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-elevated);
  backdrop-filter: blur(14px);
}
.hl-dev-btn {
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}
.hl-dev-btn.is-active { background: var(--accent-violet); color: #FFFFFF; border-color: var(--accent-violet); }

.hl-mode-mission .twg-plant-svg { max-height: 215px; }
.hl-mode-mission .hl-deck-card { padding: 18px 20px; margin-bottom: 34px; }

@media (max-width: 980px) {
  .hero-stage:not([data-hero-mode="porte"]) { padding-top: 88px; padding-bottom: 36px; min-height: auto; }
  .hl-fusione-grid, .hl-mission-body, .hl-ascensore-grid, .hl-engine-grid { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .hl-madlibs-box { padding: 12px; font-size: 14px; overflow: hidden; }
  .hl-select-wrap { display: flex; width: 100%; margin: 4px 0; }
  .hl-select { font-size: 13.5px; }
  .hl-power-h1 { font-size: 1.68rem; }
  .hl-chip-group { max-width: 49%; }
  .hl-hud-chip { font-size: 10px; padding: 3px 6px; }
  .hl-act-rail { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hl-mod-grid { grid-template-columns: minmax(0, 1fr); }
  .hl-bar-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .hl-dev-bar { left: 10px; right: auto; max-width: calc(100vw - 20px); bottom: 16px; padding: 6px 8px; }
  .hl-dev-bar.is-expanded { bottom: 76px; right: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .twg-plant-laser { animation: none; }
}
