/* ═══════════════════════════════════════════════════════
   Dice Panel Engine — Shared CSS
   Universal panel chrome, docks, tabs, 3D dice cubes.
   Extracted from itgc1.css for use across all Relay screens.
   ═══════════════════════════════════════════════════════ */

/* ── Slide-in animation (shared by panels + dice) ── */
@keyframes rp-slide-in { from { opacity: 0; transform: translateX(40px) scale(.97); } to { opacity: 1; transform: translateX(0) scale(1); } }

/* ── Dock Zone Layout ── */
.dock-zone-middle { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.dock-zone-top, .dock-zone-bottom { display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
.dock-zone-left, .dock-zone-right { display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden; }
.dock-zone:empty { display: none; }
.dock-zone-left > .dp-window, .dock-zone-right > .dp-window { min-height: 80px; }
.dock-zone-top > .dp-window, .dock-zone-bottom > .dp-window { min-height: 60px; }

/* ── Window Chrome ── */
.dp-window {
  position: fixed; z-index: 6000;
  background: rgba(17,24,34,.97);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid color-mix(in srgb, var(--dp-color, var(--accent, #3b82f6)) 30%, rgba(255,255,255,.08));
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0,0,0,.7), 0 0 0 1px rgba(255,255,255,.03), inset 0 1px 0 rgba(255,255,255,.05);
  display: flex; flex-direction: column; overflow: hidden;
  min-width: 240px; min-height: 100px;
  animation: rp-slide-in .25s cubic-bezier(.16,1,.3,1) both;
}
.dp-window { will-change: transform, opacity, left, top; }
.dp-window.dp-dragging { opacity: .88; box-shadow: 0 12px 40px rgba(0,0,0,.7); transition: none; transform: scale(1.01); }

/* Docked panels */
.dp-window.dp-docked { transition: none; }
.dp-window.dp-docked {
  animation: none;
  background: rgba(17,24,34,.92);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid color-mix(in srgb, var(--dp-color, #3b82f6) 20%, rgba(255,255,255,.06));
  box-shadow: 0 8px 32px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
}
.dp-window.dp-dock-left  { border-radius: 0 14px 14px 0; border-left: none; }
.dp-window.dp-dock-right { border-radius: 14px 0 0 14px; border-right: none; }
.dp-window.dp-dock-top   { border-radius: 0 0 14px 14px; border-top: none; }
.dp-window.dp-dock-bottom { border-radius: 14px 14px 0 0; border-bottom: none; }
.dock-zone-left > .dp-window + .dp-window,
.dock-zone-right > .dp-window + .dp-window { border-top: 1px solid var(--border, #1e2a3a); }
.dock-zone-top > .dp-window + .dp-window,
.dock-zone-bottom > .dp-window + .dp-window { border-top: 1px solid var(--border, #1e2a3a); }

/* ── Header / Drag Handle ── */
.dp-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; min-height: 32px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--dp-color, #3b82f6) 8%, transparent) 0%, color-mix(in srgb, var(--dp-color, #3b82f6) 2%, transparent) 100%);
  border-bottom: 1px solid var(--border, #1e2a3a);
  cursor: grab; user-select: none; flex-shrink: 0;
  border-left: 3px solid var(--dp-color, #3b82f6);
}
.dp-header:active { cursor: grabbing; }
.dp-icon { font-size: 14px; flex-shrink: 0; }
.dp-title { font-size: 11px; font-weight: 700; color: var(--text, #e0e6ed); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dp-mode-tag {
  font-size: 7px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
  color: var(--dp-color, rgba(200,215,230,.4));
  background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.05);
  border-radius: 2px; padding: 0 4px; line-height: 16px; flex-shrink: 0;
}

/* ── Window Controls ── */
.dp-ctrl {
  width: 20px; height: 18px; display: flex; align-items: center; justify-content: center;
  font-size: 11px; line-height: 1; cursor: pointer;
  color: rgba(200,215,230,.5); background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06); border-radius: 3px;
  transition: all .15s; flex-shrink: 0;
}
.dp-ctrl:hover { color: #fff; background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); }
.dp-close:hover { color: #ef4444; background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.25); }

/* ── Dock Preview Zones ── */
.dp-dock-preview {
  position: fixed; z-index: 5999; pointer-events: none;
  background: rgba(59,130,246,.08);
  border: 2px dashed rgba(59,130,246,.4);
  border-radius: 8px;
  transition: all .15s cubic-bezier(.16,1,.3,1);
}
.dp-dock-preview-left   { top: 38px; left: 0; width: 240px; bottom: 0; border-left: none; border-radius: 0 8px 8px 0; }
.dp-dock-preview-right  { top: 38px; right: 0; width: 420px; bottom: 0; border-right: none; border-radius: 8px 0 0 8px; }
.dp-dock-preview-top    { top: 38px; left: 0; right: 0; height: 200px; border-top: none; border-radius: 0 0 8px 8px; }
.dp-dock-preview-bottom { bottom: 0; left: 0; right: 0; height: 200px; border-bottom: none; border-radius: 8px 8px 0 0; }

.dp-dice-btn { font-size: 10px; }

/* ── Tab Bar ── */
.dp-tab-bar { display: flex; gap: 1px; flex: 1; overflow-x: auto; overflow-y: hidden; min-width: 0; scrollbar-width: none; }
.dp-tab-bar::-webkit-scrollbar { display: none; }
.dp-tab {
  display: flex; align-items: center; gap: 4px; padding: 2px 10px;
  font-size: 10px; color: rgba(200,215,230,.45); cursor: pointer;
  border-radius: 4px 4px 0 0; white-space: nowrap; transition: all .12s;
  border-bottom: 2px solid transparent; flex-shrink: 0;
}
.dp-tab:hover { color: rgba(200,215,230,.8); background: rgba(255,255,255,.03); }
.dp-tab-active {
  color: var(--text, #e0e6ed);
  border-bottom-color: var(--dp-tab-color, var(--dp-color, #3b82f6));
  background: rgba(255,255,255,.04);
}
.dp-tab-solo { cursor: grab; }
.dp-tab-icon { font-size: 11px; }
.dp-tab-label { font-weight: 600; }
.dp-tab-close {
  font-size: 12px; color: rgba(200,215,230,.3); cursor: pointer;
  margin-left: 2px; line-height: 1; padding: 0 2px;
}
.dp-tab-close:hover { color: #ef4444; }

.dp-tab-preview {
  position: fixed; z-index: 5999; pointer-events: none;
  background: rgba(59,130,246,.12);
  border: 2px solid rgba(59,130,246,.5);
  border-radius: 6px;
  transition: all .1s ease;
}

/* ── Body ── */
.dp-body { flex: 1; overflow: auto; min-height: 0; position: relative; padding: 8px 10px; }
.dp-docked .dp-body { overflow: auto; padding: 0; }
.dp-body::-webkit-scrollbar { width: 4px; }
.dp-body::-webkit-scrollbar-thumb { background: rgba(59,130,246,.2); border-radius: 2px; }

/* ── Resize Handles ── */
.dp-resize { position: absolute; z-index: 5; }
.dp-resize-se { bottom: 0; right: 0; width: 14px; height: 14px; cursor: se-resize; }
.dp-resize-se::after { content: ''; position: absolute; bottom: 3px; right: 3px; width: 8px; height: 8px; border-right: 2px solid rgba(255,255,255,.12); border-bottom: 2px solid rgba(255,255,255,.12); }
.dp-window:hover .dp-resize-se::after { border-color: rgba(59,130,246,.35); }
.dp-resize-e { top: 32px; right: 0; bottom: 14px; width: 5px; cursor: e-resize; }
.dp-resize-s { bottom: 0; left: 14px; right: 14px; height: 5px; cursor: s-resize; }
.dp-dock-left .dp-resize-s, .dp-dock-right .dp-resize-s { cursor: s-resize; }
.dp-dock-top .dp-resize-e, .dp-dock-bottom .dp-resize-e { display: none; }

/* ── 3D Dice Cubes ── */
.dice-cube {
  position: fixed; z-index: 5500;
  width: 44px; height: 44px;
  cursor: pointer; user-select: none;
  transform-style: preserve-3d;
  perspective: 300px;
  transition: transform .25s cubic-bezier(.16,1,.3,1);
}
.dice-cube:hover { transform: translateY(-4px) scale(1.12) rotateX(-5deg) rotateY(10deg); }
@keyframes dice-float { 0%,100% { filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); } 50% { filter: drop-shadow(0 6px 12px rgba(0,0,0,.4)); } }
.dice-cube:not(:hover):not(.dice-wall):not(.dice-matrix) { animation: dice-float 3s ease-in-out infinite; }

.dice-face {
  position: absolute; width: 44px; height: 44px;
  border-radius: 6px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  backface-visibility: hidden;
  overflow: hidden;
}
.dice-front {
  background: linear-gradient(135deg, var(--dice-color, #3b82f6), color-mix(in srgb, var(--dice-color, #3b82f6) 70%, #000));
  box-shadow: 0 4px 16px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.2);
  border: 1px solid rgba(255,255,255,.15);
  transform: translateZ(22px);
}
.dice-back { background: color-mix(in srgb, var(--dice-color, #3b82f6) 50%, #000); transform: rotateY(180deg) translateZ(22px); }
.dice-top { background: color-mix(in srgb, var(--dice-color, #3b82f6) 85%, #fff); transform: rotateX(90deg) translateZ(22px); }
.dice-bottom { background: color-mix(in srgb, var(--dice-color, #3b82f6) 30%, #000); transform: rotateX(-90deg) translateZ(22px); }
.dice-left { background: color-mix(in srgb, var(--dice-color, #3b82f6) 45%, #000); transform: rotateY(-90deg) translateZ(22px); }
.dice-right { background: color-mix(in srgb, var(--dice-color, #3b82f6) 65%, #000); transform: rotateY(90deg) translateZ(22px); }

.dice-icon { font-size: 16px; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.dice-label { font-size: 7px; font-weight: 700; color: rgba(255,255,255,.8); letter-spacing: .3px; text-transform: uppercase; }

.dice-cube.dice-wall { animation: none; }
.dice-cube.dice-wall .dice-front {
  box-shadow: 0 2px 8px rgba(0,0,0,.4), 0 0 8px 1px color-mix(in srgb, var(--dice-color, #3b82f6) 40%, transparent);
}

.dice-cube.dice-matrix {
  position: absolute; z-index: 50;
  animation: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.4));
}
.dice-cube.dice-matrix:hover { transform: translateY(-3px) scale(1.15); }

@keyframes dice-pulse-glow {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,.6), 0 0 0 0 var(--dice-pulse-color, #a855f7); }
  50% { box-shadow: 0 4px 16px rgba(0,0,0,.6), 0 0 16px 6px var(--dice-pulse-color, #a855f7); }
}
.dice-cube.dice-pulse .dice-front { animation: dice-pulse-glow 0.8s ease infinite; }


/* ═══════════════════════════════════════════════════════
   Panel Variants (Track R / R-step 2)
   Declarative specializations of the dp-window chrome. A caller opts in via
   createDicePanel(id, { variant: 'inspector', ... }); the engine applies the
   matching class and the rules below take effect. These rules must stay
   app-agnostic so any module can use them.
   ═══════════════════════════════════════════════════════ */

/* ── Inspector variant: right-side lane docked inside the app workspace ── */
.dp-window.dp-variant-inspector {
  position: fixed !important;
  top: 38px !important;
  right: 0 !important;
  bottom: 0 !important;
  left: auto !important;
  width: 560px !important;
  height: auto !important;
  max-height: none !important;
  border-radius: 0 !important;
  border-right: none !important;
  border-top: none !important;
  border-bottom: none !important;
  border-left: 1px solid color-mix(in srgb, var(--dp-color, #3b82f6) 18%, rgba(255,255,255,.08)) !important;
  box-shadow: -12px 0 32px rgba(0,0,0,.45);
  background: rgba(17,24,34,.93);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: none !important;
}
.dp-window.dp-variant-inspector .dp-header {
  cursor: default;
  border-left: none;
  background: linear-gradient(180deg, rgba(255,255,255,.03) 0%, transparent 100%);
}
.dp-window.dp-variant-inspector .dp-dice-btn,
.dp-window.dp-variant-inspector .dp-resize {
  display: none;
}

@media (max-width: 1200px) {
  .dp-window.dp-variant-inspector {
    top: 38px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    width: auto !important;
    height: 55vh !important;
    border-left: none !important;
    border-bottom: 1px solid color-mix(in srgb, var(--dp-color, #3b82f6) 18%, rgba(255,255,255,.08)) !important;
    box-shadow: 0 12px 32px rgba(0,0,0,.45);
  }
}


/* ═══════════════════════════════════════════════════════
   Panel Body States (Track R / R-step 3)
   Shared visual language for the three canonical panel body states.
   Rendered by renderEmptyState() and renderLoading() in
   core/ui/dice-panel-engine.js. App-agnostic -- no module-specific
   selectors or copy. Any consumer of the dice-panel engine can use
   these classes directly without calling the helpers.
   ═══════════════════════════════════════════════════════ */

/* Empty state: shown when the panel has no content to display because
   of a missing prerequisite (e.g. no control selected, no data loaded).
   Explains what the user should do to populate the panel. */
.dp-body-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  color: var(--muted, rgba(200, 215, 230, 0.5));
  font-size: 13px;
  text-align: center;
  min-height: 120px;
  height: 100%;
  box-sizing: border-box;
}
.dp-body-empty-title {
  font-weight: 500;
  color: var(--text, rgba(200, 215, 230, 0.85));
}
.dp-body-empty-hint {
  font-size: 11px;
  opacity: 0.65;
  max-width: 280px;
  line-height: 1.5;
}

/* Loading state: shown while the panel's content is being prepared
   (async module import, data fetch, etc.). Replaced with real content
   once the work resolves. */
.dp-body-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  color: var(--muted, rgba(200, 215, 230, 0.5));
  font-size: 12px;
  text-align: center;
  min-height: 100px;
  height: 100%;
  box-sizing: border-box;
}
.dp-body-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in srgb, var(--accent, #3b82f6) 15%, transparent);
  border-top-color: var(--accent, #3b82f6);
  border-radius: 50%;
  animation: dp-body-loading-spin 0.8s linear infinite;
}
.dp-body-loading-label {
  opacity: 0.8;
  letter-spacing: 0.2px;
}
@keyframes dp-body-loading-spin {
  to { transform: rotate(360deg); }
}

/* Error state: shown when the panel's setup fails (async import error,
   data fetch failure, etc.). Red-accented title; optional monospace
   message line for the exception detail; optional hint for recovery. */
.dp-body-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 24px;
  color: var(--muted, rgba(200, 215, 230, 0.5));
  font-size: 13px;
  text-align: center;
  min-height: 120px;
  height: 100%;
  box-sizing: border-box;
}
.dp-body-error-title {
  font-weight: 600;
  color: var(--danger, #ef4444);
  font-size: 13px;
  letter-spacing: 0.2px;
}
.dp-body-error-message {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: color-mix(in srgb, var(--danger, #ef4444) 85%, transparent);
  max-width: 360px;
  word-break: break-word;
  line-height: 1.5;
}
.dp-body-error-hint {
  font-size: 11px;
  opacity: 0.65;
  max-width: 280px;
  line-height: 1.5;
}
