/**
 * prediction-stack.css — floating multi-leg stack UI.
 *
 * ProbeEdge-only affordance (Vault + ImpulseEngine_v2). Loaded
 * alongside prediction-card.css (Push 2) so .prediction-card base
 * styling is already available.
 *
 * Z-index:
 *   Collapsed pill + expanded card:  9500 (desktop)
 *                                    10000 (mobile expanded only, while
 *                                    companion is hidden by JS)
 *   Scrim backdrop (mobile expanded): 9999
 *   Toast:                           10100 (above everything)
 *
 * Anchor:
 *   Desktop: bottom:120px right:28px — sits above companion's
 *            bottom:20 right:20 footprint with 20px clear gap.
 *   Mobile expanded: full-width bottom slab with scrim.
 *
 * Companion widget is left UNTOUCHED structurally. JS toggles its
 * display only while mobile-expanded, restoring on collapse/submit.
 */

/* ── Collapsed pill ───────────────────────────────────────────────── */
#pe-stack-pill{
  position:fixed;
  bottom:120px;
  right:28px;
  z-index:9500;
  min-width:180px;
  padding:10px 14px;
  display:flex;align-items:center;gap:8px;
  background:rgba(20,20,24,0.72);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  border:1px solid #C9A84C;
  border-radius:999px;
  box-shadow:inset 0 1px 0 rgba(255,255,255,0.04);
  color:#C9A84C;
  font-family:'DM Mono','Courier New',monospace;
  font-size:10px;letter-spacing:2px;
  cursor:pointer;
  transition:border-color 0.2s,box-shadow 0.2s,transform 0.15s,opacity 0.2s;
  user-select:none;
}
#pe-stack-pill:hover{
  border-color:#E8C96A;
  box-shadow:0 0 24px rgba(201,168,76,0.25),
             inset 0 1px 0 rgba(255,255,255,0.06);
}
#pe-stack-pill:active{transform:scale(0.98);}
#pe-stack-pill .pe-stack-pill-icon{font-size:13px;line-height:1;}
#pe-stack-pill .pe-stack-pill-count{color:#E8C96A;}
#pe-stack-pill .pe-stack-pill-cost{color:rgba(201,168,76,0.65);}

#pe-stack-pill.empty{
  border-color:rgba(201,168,76,0.3);
  color:rgba(201,168,76,0.55);
}
#pe-stack-pill.empty .pe-stack-pill-count{color:rgba(201,168,76,0.65);}

/* Pulse animation on arrival — triggered once per leg added. */
@keyframes pe-stack-pulse{
  0%   {box-shadow:inset 0 1px 0 rgba(255,255,255,0.04);}
  50%  {box-shadow:0 0 36px rgba(201,168,76,0.6),
                   inset 0 1px 0 rgba(255,255,255,0.10);
        border-color:#E8C96A;}
  100% {box-shadow:inset 0 1px 0 rgba(255,255,255,0.04);}
}
#pe-stack-pill.pulsing{animation:pe-stack-pulse 0.6s ease-out 1;}

/* ── Expanded card ─────────────────────────────────────────────────── */
#pe-stack-card{
  position:fixed;
  bottom:120px;
  right:28px;
  z-index:9500;
  width:360px;
  max-height:60vh;
  display:none;
  flex-direction:column;
  background:rgba(20,20,24,0.75);
  backdrop-filter:blur(18px);
  -webkit-backdrop-filter:blur(18px);
  border:1px solid #C9A84C;
  border-radius:12px;
  box-shadow:0 8px 48px rgba(0,0,0,0.55),
             inset 0 1px 0 rgba(255,255,255,0.05);
  overflow:hidden;
}
#pe-stack-card.open{display:flex;}

.pe-stack-head{
  display:flex;align-items:center;justify-content:space-between;
  padding:14px 16px 10px;
  border-bottom:1px solid rgba(201,168,76,0.12);
}
.pe-stack-head-title{
  font-family:'Cinzel',serif;
  font-size:11px;letter-spacing:4px;
  color:#C9A84C;
}
.pe-stack-head-close{
  background:none;border:1px solid rgba(255,255,255,0.12);
  color:rgba(255,255,255,0.55);
  font-family:'DM Mono','Courier New',monospace;
  font-size:10px;letter-spacing:2px;
  padding:4px 10px;cursor:pointer;
  transition:color 0.15s,border-color 0.15s;
}
.pe-stack-head-close:hover{color:#C9A84C;border-color:rgba(201,168,76,0.45);}

.pe-stack-body{
  flex:1;overflow-y:auto;
  padding:10px 14px;
  min-height:40px;
}
.pe-stack-empty{
  padding:18px 6px;
  font-family:'Cormorant Garamond',serif;
  font-style:italic;
  font-size:13px;color:rgba(255,255,255,0.4);
  text-align:center;
  line-height:1.5;
}

.pe-stack-leg{
  display:grid;grid-template-columns:1fr auto auto;gap:8px;
  align-items:center;
  padding:10px 6px;
  border-bottom:1px dashed rgba(255,255,255,0.06);
}
.pe-stack-leg:last-child{border-bottom:none;}
.pe-stack-leg-text{
  font-family:'DM Mono','Courier New',monospace;
  font-size:10px;letter-spacing:1px;
  color:rgba(255,255,255,0.82);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  min-width:0;
}
.pe-stack-leg-conf{
  font-family:'DM Mono','Courier New',monospace;
  font-size:9px;letter-spacing:1px;
  color:#C9A84C;
}
.pe-stack-leg-cost{
  font-family:'DM Mono','Courier New',monospace;
  font-size:9px;letter-spacing:1px;
  color:rgba(201,168,76,0.75);
}
.pe-stack-leg-remove{
  background:none;border:none;
  color:rgba(255,255,255,0.25);
  font-size:14px;line-height:1;
  cursor:pointer;padding:2px 6px;
  transition:color 0.15s;
  grid-column:3;justify-self:end;
}
.pe-stack-leg-remove:hover{color:#FF3355;}

.pe-stack-foot{
  padding:12px 16px 14px;
  border-top:1px solid rgba(201,168,76,0.12);
  background:rgba(8,8,12,0.45);
}
.pe-stack-stat{
  display:flex;justify-content:space-between;
  font-family:'DM Mono','Courier New',monospace;
  font-size:9px;letter-spacing:2px;
  padding:3px 0;
}
.pe-stack-stat-lbl{color:rgba(255,255,255,0.35);}
.pe-stack-stat-val{color:#C9A84C;}
.pe-stack-stat.highlight .pe-stack-stat-val{color:#E8C96A;font-size:11px;letter-spacing:1px;}
.pe-stack-stat-sub{
  font-family:'DM Mono','Courier New',monospace;
  font-size:7px;letter-spacing:2px;
  color:rgba(255,255,255,0.35);
  text-align:right;
  margin-top:-1px;margin-bottom:6px;
}

.pe-stack-actions{margin-top:10px;display:flex;flex-direction:column;gap:6px;}
.pe-stack-submit{
  padding:12px;
  background:#C9A84C;color:#04030A;border:none;
  font-family:'Cinzel',serif;
  font-size:10px;letter-spacing:4px;
  cursor:pointer;transition:background 0.15s;
  width:100%;
}
.pe-stack-submit:hover:not(:disabled){background:#E8C96A;}
.pe-stack-submit:disabled{opacity:0.4;cursor:not-allowed;}
.pe-stack-clear{
  background:none;border:none;
  color:rgba(255,255,255,0.4);
  font-family:'DM Mono','Courier New',monospace;
  font-size:8px;letter-spacing:2px;
  text-decoration:underline;text-underline-offset:3px;
  cursor:pointer;padding:4px;
  transition:color 0.15s;
}
.pe-stack-clear:hover{color:#FF3355;}

/* ── Scrim — MOBILE EXPANDED ONLY (per architect spec 2d) ─────────── */
/* Desktop expand has no scrim; companion stays visible. On mobile
   the expanded slab covers viewport bottom and the scrim dims the
   page above it. */
#pe-stack-scrim{
  display:none;
  position:fixed;inset:0;
  background:rgba(2,2,6,0.55);
  backdrop-filter:blur(4px);
  -webkit-backdrop-filter:blur(4px);
  z-index:9999;
}
@media (max-width:640px){
  #pe-stack-scrim.open{display:block;}
  #pe-stack-pill{
    bottom:96px;right:16px;
    min-width:160px;padding:9px 12px;
    font-size:9.5px;
  }
  #pe-stack-card{
    left:0;right:0;bottom:0;
    width:auto;max-height:75vh;
    border-radius:12px 12px 0 0;
    z-index:10000;
  }
}

/* ── Fly-to-stack ghost animation ─────────────────────────────────── */
.pe-stack-ghost{
  position:fixed;
  pointer-events:none;
  z-index:9600;
  will-change:transform,opacity;
  transition:transform 400ms cubic-bezier(0.22,1,0.36,1),
             opacity  400ms cubic-bezier(0.22,1,0.36,1);
  background:rgba(20,20,24,0.85);
  border:1px solid #C9A84C;
  border-radius:10px;
  padding:10px 14px;
  font-family:'DM Mono','Courier New',monospace;
  font-size:10px;letter-spacing:1px;
  color:rgba(255,255,255,0.85);
  max-width:260px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  box-shadow:0 8px 24px rgba(0,0,0,0.4);
}
.pe-stack-ghost.arrived{opacity:0;transform:scale(0.3);}

/* Reduced motion respects */
@media (prefers-reduced-motion:reduce){
  .pe-stack-ghost{transition:opacity 200ms linear;}
  #pe-stack-pill.pulsing{animation:none;outline:2px solid #E8C96A;outline-offset:2px;}
}

/* ── Tappable card affordance ─────────────────────────────────────── */
[data-pe-stack-tap="true"]{cursor:pointer;transition:transform 0.15s;}
[data-pe-stack-tap="true"]:hover{transform:translateY(-1px);}
[data-pe-stack-tap="true"]:active{transform:translateY(0);}

/* ── Insufficient-credits modal ───────────────────────────────────── */
#pe-stack-nocredit{
  display:none;
  position:fixed;inset:0;z-index:10100;
  align-items:center;justify-content:center;
  background:rgba(2,2,6,0.75);
  backdrop-filter:blur(6px);
  -webkit-backdrop-filter:blur(6px);
}
#pe-stack-nocredit.open{display:flex;}
.pe-stack-nocredit-body{
  background:rgba(20,20,24,0.92);
  border:1px solid #C9A84C;
  border-radius:12px;
  padding:28px 32px;
  max-width:420px;
  text-align:center;
  font-family:'Cinzel',serif;
}
.pe-stack-nocredit-head{
  font-size:12px;letter-spacing:4px;
  color:#FF3355;margin-bottom:14px;
}
.pe-stack-nocredit-msg{
  font-family:'Cormorant Garamond',serif;
  font-size:16px;color:rgba(255,255,255,0.82);
  line-height:1.5;margin-bottom:18px;
}
.pe-stack-nocredit-cta{
  background:#C9A84C;color:#04030A;
  font-family:'Cinzel',serif;font-size:10px;letter-spacing:4px;
  border:none;padding:12px 28px;cursor:pointer;
  margin-right:8px;
}
.pe-stack-nocredit-cta:hover{background:#E8C96A;}
.pe-stack-nocredit-close{
  background:none;border:1px solid rgba(255,255,255,0.15);
  color:rgba(255,255,255,0.55);
  font-family:'DM Mono','Courier New',monospace;
  font-size:10px;letter-spacing:2px;
  padding:10px 18px;cursor:pointer;
}
.pe-stack-nocredit-close:hover{color:#fff;border-color:rgba(255,255,255,0.35);}
