/* ==========================================================================
   Floating Reference Cards
   Draggable, closable, stackable entity cards for quick reference.
   ========================================================================== */

.floating-card-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
}

.floating-card {
  position: absolute;
  pointer-events: auto;
  width: 320px;
  max-height: 400px;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- Header (drag handle) ---------- */

.floating-card-header {
  cursor: grab;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
  user-select: none;
  flex-shrink: 0;
}

.floating-card-header:active {
  cursor: grabbing;
}

.floating-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  min-width: 0;
}

.floating-card-title > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.floating-card-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.floating-card-close:hover {
  color: var(--text-primary);
}

/* ---------- Body ---------- */

.floating-card-body {
  padding: 0.75rem;
  overflow-y: auto;
  flex: 1;
  font-size: 0.85rem;
  min-height: 0;
}

.floating-card-body p {
  margin: 0 0 0.5rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.floating-card-body .badge {
  font-size: 0.7rem;
}

.fc-type-badge {
  font-size: 0.65rem;
}

/* ---------- Field rows ---------- */

.fc-field {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.fc-field-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.fc-field-value {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.fc-stat-summary {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-primary);
}

/* ---------- Image in cards ---------- */

.fc-image {
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

/* ---------- Clock visual ---------- */

.fc-clock-visual {
  display: flex;
  gap: 3px;
  margin: 0.5rem 0;
}

.fc-clock-segment {
  width: 20px;
  height: 20px;
  border: 2px solid var(--text-muted);
  border-radius: 3px;
  background: transparent;
}

.fc-clock-filled {
  background: var(--accent-red);
  border-color: var(--accent-red);
}

/* ---------- Entity link styling ---------- */

.entity-link {
  color: var(--info);
  cursor: pointer;
  text-decoration: underline dotted;
}

.entity-link:hover {
  text-decoration: underline solid;
  color: #93c5fd;
}

/* ---------- Quick view button ---------- */

.quick-view-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  vertical-align: middle;
}

.quick-view-btn:hover {
  color: var(--info);
}

/* ---------- Responsive: full-width on small screens ---------- */

@media (max-width: 480px) {
  .floating-card {
    width: calc(100vw - 2rem);
    left: 1rem !important;
  }
}

/* ==========================================================================
   Rollable-table floating cards (tables app + main app quick-roll)
   Wider than the default card to fit matrix columns; full interactive table.
   ========================================================================== */
.floating-card-rollable-table { width: 420px; max-height: 72vh; }

.fc-rollable-table { display: flex; flex-direction: column; gap: 0.6rem; }
.fc-table-desc { margin: 0; color: var(--text-secondary); font-size: 0.85rem; }
.fc-roll-btn { align-self: flex-start; white-space: nowrap; }
.fc-roll-banner {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--accent-red-bg); border: 1px solid var(--accent-red);
  border-radius: 6px; padding: 0.35rem 0.6rem;
}
.fc-roll-die { font-family: var(--font-mono); font-weight: 600; color: var(--accent-red); white-space: nowrap; }
.fc-roll-text { color: var(--text-primary); font-size: 0.9rem; }
.fc-table-source {
  font-size: 0.75rem; color: var(--text-muted);
  border-top: 1px dashed var(--border-primary); padding-top: 0.4rem;
}
.fc-table-source a { color: var(--text-secondary); text-decoration: underline; }
.fc-table-rows { overflow-x: auto; }

/* Float button — sits alongside roll/pin in table card actions */
.float-table-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.15rem; line-height: 1;
  display: inline-flex; align-items: center;
}
.float-table-btn:hover { color: var(--accent-red); }

/* Roll chain inside a floated table card (table-ref following) */
.fc-roll-banner { flex-wrap: wrap; row-gap: 0.3rem; }
.fc-chain-step { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.fc-chain-arrow { color: var(--accent-red); font-weight: 700; margin: 0 0.2rem; }
